Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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