Created
September 16, 2011 14:52
-
-
Save Swizec/1222278 to your computer and use it in GitHub Desktop.
Simple script to see how far users scroll on a website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
$.waypoints.settings.scrollThrottle = 30; | |
try { | |
mpmetrics = new MixpanelLib("<api_key>"); | |
} catch(err) { | |
var null_fn = function () {}; | |
mpmetrics = { | |
track: null_fn, | |
track_funnel: null_fn, | |
track_links: null_fn, | |
register: null_fn, | |
register_once: null_fn, | |
register_funnel: null_fn, | |
identify: null_fn | |
}; | |
} | |
$(".entry p").each(function (i, el) { | |
$(el).waypoint(function (event, direction) { | |
if (direction === "down") { | |
mpmetrics.track("Paragraph "+i, {url: window.location.href, | |
index: i}); | |
} | |
}, {offset: 'bottom-in-view'}); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment