test.ical.ly | getting the web by the balls

Jan/12

5

A tiny jQuery plugin to track the users scroll depth in Google Analytics

Do you have pages that are very long and you’re not sure if the user even reaches that far down to discover all of it? Do you want a statistic of how deep users are actually scrolling down your page?

Using Google Analytics Event Tracking this can be quite simple so I wrote a small jQuery plugin.

It’s really simple to do. Here’s the plugin in CoffeeScript.

Which will expand to this Javascript code.

Basically it attaches a callback to the scroll event that fires off a Google Analytics Event for the last biggest scroll depth that is measured. To not spam your Google Analytics account the measuring is limited to configurable steps.

With the following code you can start tracking scroll depths for every 500 pixels.

Now you should be able to open up the events tab in your Google Analytics account and see how many events were fired for each scroll depth.

· ·



<<

>>

Theme Design by devolux.nh2.me