How to track scroll percentage, scroll depth with Mixpanel Analytics

Want to be able to track when a user has scrolled a certain amount down the page?

Well, thanks to it’s rather easy.

I’ve just made a fork of Jquery-scrolldepth on Github here:

When the user scrolls to 25, 50, 75 and 90% of the way down the page, the following javascript will be called:

mixpanel.track(labelPrefix + label);

where label is either “25%”, “50%”, “75%” or “90%” and labelPrefix is “” (empty string) by default.

How to implement:

1. Make sure jQuery is included on your page
2. Make sure the scroll depth script is in included on your page
3. Make sure the Mixpanel tracking script is in the <head> tag
4. Call this function to initialise the tracking script:

$(function() {

5. That’s it! If you want to pass a label prefix, change the line above to:

 $.scrollDepth({labelPrefix:"myPrefix "});

About Phil Smithson

Ultrarunner & CTO. Passions include Mobile app development, Scrum, Kanban, Wordpress and Symfony.

Leave a Reply

Your email address will not be published. Required fields are marked *