Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I want to track scrolling on my website since it's a long page (rather than multiple pages). I saw several different methods, with and without an underscore for trackEvent, with and without spaces between commas

 <script>  ...
...   ...
  ga('create', 'UA-45440410-1', 'example.com');   ga('send',
 'pageview');

 _gaq.push([‘_trackEvent’, ‘Consumption’, ‘Article Load’, ‘[URL]’, 100, true]); 
 _gaq.push([‘_trackEvent’, ‘Consumption’, ‘Article Load’, ‘[URL]’, 75, false]);
 _gaq.push([‘_trackEvent’, ‘Consumption’, ‘Article Load’, ‘[URL]’, 50, false]);
 _gaq.push([‘_trackEvent’, ‘Consumption’, ‘Article Load’, ‘[URL]’, 25, false]);

 </script>

It takes a day for counts to load with Google Analytics, otherwise I would just tweak and test right now.

share|improve this question
1  
There's a lot of articles covering how to track scrolling, particularly with jQuery - search in Google for: google analytics track scroll depth. –  dan Nov 13 '13 at 0:30

2 Answers 2

The easiest way to track scroll depth in Google Analytics is with this plugin. It tracks 25, 50, 75, and 100% scroll points out of the box. Disclosure: I'm the author of it :)

share|improve this answer

Here is an article that provides Google Analytics event tracking code to track the lowest point on the page that a user has scrolled. So this is a little different than your suggested solution of tracking 4 distinct scroll points.

It requires JQuery and these lines of JavaScript pasted in after the analytics script:

<script type="text/javascript">
// Scroll reach tracking (WTFPL licensed) by Robert Kingston - http://www.optimisationbeacon.com/
// Cookie functions from Quirks Mode by Scott Andrew - http://www.scottandrew.com/
function mkScrCookie(e,t,n){if(n){var r=new Date;r.setTime(r.getTime()+n*24*60*60*1e3);var i="; expires="+r.toGMTString()}else var i="";document.cookie=e+"="+t+i+"; path=/"}function rdScrCookie(e){var t=e+"=";var n=document.cookie.split(";");for(var r=0;r<n.length;r++){var i=n[r];while(i.charAt(0)==" ")i=i.substring(1,i.length);if(i.indexOf(t)==0)return i.substring(t.length,i.length)}return null}function rmScrCookie(e){mkScrCookie(e,"",-1)}jQuery(document).ready(function(){try{var e=parseInt(rdScrCookie("scrReach"));if(e!=undefined&&document.referrer.indexOf("//"+document.location.hostname)>-1){_gaq.push(["_trackEvent","scroll reach","viewport: "+jQuery(window).height()+"x"+jQuery(window).width(),document.referrer.toString(),e]);rmScrCookie("scrReach")}}catch(t){}var n=jQuery(document).height();var r=jQuery(window).height();var i=jQuery(window).scrollTop();var s=Math.round(r/n*100);mkScrCookie("scrReach",s);var o=/MSIE (5|6|7|8)(.*Trident)?/g;if(!o.test(navigator.userAgent)){jQuery(document).scroll(function(){n=jQuery(document).height();r=jQuery(window).height();i=jQuery(window).scrollTop();var e=i+r;var t=Math.round(e/n*100);if(t>s){s=t;mkScrCookie("scrReach",t)}})}})</script>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.