: How can I track scrolling in a Google Analytics custom report? I want to track scrolling on my website since it's a long page (rather than multiple pages). I saw several different methods,
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.
More posts by @Barnes591
2 Comments
Sorted by latest first Latest Oldest Best
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 :)
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 - www.optimisationbeacon.com/ // Cookie functions from Quirks Mode by Scott Andrew - 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>
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.