Google Analytics Scroll
Auto-track scroll depth for Google Analytics.
Installation
npm install ga-track-scroll
or
yarn add ga-track-scroll
Usage
import 'ga-track-scroll'
Once the user starts scrolling it will send events to Google Analytics:
-
category
: scroll -
action
:document.location.toString()
-
label
: "Scrolled X%" (25/50/75/100) (There's also a simpleScrolled
event the first time the user scrolls) -
value
: X (25/50/75/100)
It does also fire a custom event on the DOM:
document.addEventListener('user:scroll', event => {
const { amount } = event.detail; // Can be 25/50/75/100
});