Skip to content

Instantly share code, notes, and snippets.

@caefer
Created October 5, 2011 04:01
Show Gist options
  • Save caefer/1263597 to your computer and use it in GitHub Desktop.
Save caefer/1263597 to your computer and use it in GitHub Desktop.
(function() {
$.fn.extend({
scrolltracker: function(step) {
var maxDepth;
maxDepth = 0;
return this.scroll(function() {
var depth;
depth = Math.floor($(this).scrollTop() / step);
if (depth > maxDepth) {
maxDepth = depth;
return _gaq.push(['_trackEvent', 'ScrollDepth', depth * step]);
}
});
}
});
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment