Skip to content

Instantly share code, notes, and snippets.

@Swizec
Created September 16, 2011 14:52
Show Gist options
  • Save Swizec/1222278 to your computer and use it in GitHub Desktop.
Save Swizec/1222278 to your computer and use it in GitHub Desktop.
Simple script to see how far users scroll on a website
(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