ga-track-scroll

Google Analytics Scroll Tracking helper


Keywords
browser, ga, analytics, scroll
License
MIT
Install
npm install ga-track-scroll@2.3.0

Documentation

Google Analytics Scroll

NPM

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 simple Scrolled 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
});