Guest User

Untitled

a guest
Apr 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. def google_analytics_real_bounce_rate_fix(timeout = 10)
  2. name = "NoBounce"
  3. msg = "Over #{timeout} seconds"
  4. ms = timeout * 1000
  5.  
  6. <<-JS
  7. function disqualifyAsBounce() {
  8. pageTracker._trackEvent('#{name}', '#{name}', '#{msg}');
  9. }
  10. setTimeout("disqualifyAsBounce()", #{ms});
  11. JS
  12. end
  13.  
  14. # Usage:
  15. # Output the method's return value RIGHT AFTER the call to '_trackPageView'.
  16. # Example - Your JS has to look like this (variables may vary):
  17. #
  18. # <script type="text/javascript">
  19. # try {
  20. # var pageTracker = _gat._getTracker("UA-XXXXXXX-XX");
  21. # pageTracker._trackPageview();
  22. # function disqualifyAsBounce() {
  23. # pageTracker._trackEvent('NoBounce', 'NoBounce', 'Over 10 seconds');
  24. # }
  25. # setTimeout("disqualifyAsBounce()", 10000);
  26. #
  27. # } catch(err) {}
  28. # </script>
Add Comment
Please, Sign In to add comment