Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryanburnette/google-analytics-scroll-events
https://github.com/ryanburnette/google-analytics-scroll-events
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ryanburnette/google-analytics-scroll-events
- Owner: ryanburnette
- License: isc
- Created: 2018-02-23T21:30:55.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-23T23:40:31.000Z (almost 7 years ago)
- Last Synced: 2024-11-19T19:52:25.814Z (3 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Google Analytics Scroll Events
A browser JavaScript library for binding Google Analytics events to the window
scrolling to an element.## Use Case
I often have clients make requests to build elements that reduce the height of
a page. In many cases I suspected that most users were willing to scroll which
made the element superfluous. If users are willing to scroll to some content
further down the page, what's the point of adding complexity to move content
closer to the top?This lets you create data on how often a user scrolls to a certain point in the
content.## Usage
```
npm install google-analytics-scroll-events
``````javascript
const addEvent = require('google-analytics-scroll-events')addEvent('Body',1,'body')
addEvent('Foo Element',2,'.foo')
addEvent('Bar Element',3,'#bar')
```## API
### `createGoogleAnalyticsScrollEvent(label,value,selector)`
Adds an event which will fire when the window scrolls past the selected
element. Events only fire once.- `label` A label that will be used as a key for JavaScript objects and as the
`eventLabel` in the Google Analytics event
- `value` The `eventValue` in the Google Analytics event
- `selector` A selector to be used by `document.querySelector` for the element
that must be scrolled to in order to fire the Google Analytics eventRefer to the [documentation for Google Analytics events][1].
[1]: https://developers.google.com/analytics/devguides/collection/analyticsjs/events