Skip to content

Instantly share code, notes, and snippets.

@caefer
Created October 5, 2011 03:56
Show Gist options
  • Save caefer/1263587 to your computer and use it in GitHub Desktop.
Save caefer/1263587 to your computer and use it in GitHub Desktop.
## jQuery extension that tracks the current scroll depth
$.fn.extend
scrolltracker: (step) ->
maxDepth = 0
this.scroll ->
depth = Math.floor($(this).scrollTop() / step)
if depth > maxDepth
maxDepth = depth
_gaq.push(['_trackEvent', 'ScrollDepth', depth * step]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment