Skip to content

Instantly share code, notes, and snippets.

@ortense
Last active August 29, 2015 14:00
Show Gist options
  • Save ortense/d01dfd27fc595f1e8c4f to your computer and use it in GitHub Desktop.
Save ortense/d01dfd27fc595f1e8c4f to your computer and use it in GitHub Desktop.
Google Analytics Track Scroll End
(function($){
var $window = $(window),
$document = $(document),
scrollEnd = function(){
if(($window.height() + $window.scrollTop() + 20) >= $document.height()){
ga("send", "event", "scroll", document.location.pathname, "100%");
$window.off("scroll", scrollEnd);
}
};
$window.on("scroll", scrollEnd);
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment