Segment Scroll Depth is a script that tracks how far users are scrolling on a page, and sends track events to Segment. The events can be sent to any Segment integration, including Google Analytics.
Segment Scroll Depth is a fork of Scroll Depth.
-
Make sure Segment is installed on your site and that the Google Analytics integratoin is enabled.
-
Add
segment-scroll-depth.js
orsegment-scroll-depth.min.js
to your scripts folder. -
Add the following code to any page where you want to track scroll depths as events in Segment.
<script src="path-to-script/segment-scroll-depth.min.js"></script>
<script>
jQuery(function() {
jQuery.scrollDepth();
});
</script>
(Where path-to-script
is the location of the script.)
That's it!
This script will send a tracking event to Segment when users scroll to 25%, 50%, 75%, and 100% of a page's length.
The integrations
property tells Segment where to send these events. By default it is set to send only to Google Analytics, but you can change this to your preference.
Bug reports and code contributions are welcome. Please see contributing.md.
Twitter: @grigoriy_kogan Web: GKogan.co
Licensed under the MIT and GPL licenses.