@strg/behave-tracking-client-plugins
v0.5.2
Published
STRG.BeHave - Tracking Client base plugins
Downloads
174
Readme
BeHave Tracking Plugins
This library contains standard BeHave tracking plugins, it is intended to use the plugins in the customer implementations and not standalone, they require BeHave Tracking Client Library
Getting Started
Prerequisites
plugin.scroll.js
The library is better known as breakpointmeter, it tracks the scroll depth in combination with BeHave Tracking Client Library
.
How to use:
config
const config = {
ARTICLE_SELECTOR: 'article',
}
init
import { createScrollTracking } from '@strg-behave/tracking-client-plugins'
const scrollTracking = createScrollTracking()
scrollTracking.on('breakpoint', (event) => myTracker.track(event))
register
const articleElement = [] // Cast to array and pick first found
.concat(config.ARTICLE_SELECTOR)
.map(selector => document.querySelector(selector))
.filter(el => !!el)
.shift()
if (articleElement) {
scrollTracking.scrollDepth(articleElement, {
eventKey: 'breakpoint.content.percent.max',
})
}
plugin.referrer.js
This plugin tracks the window.referrer
URL
How to use:
init
import { createReferrerTracking } from '@strg-behave/tracking-client-plugins'
const referrerTracking = createReferrerTracking()
referrerTracking.on('referrer', (event) => myTracker.track(event))
plugin.url.js
This plugin tracks the window.location
URL
How to use:
init
import { createUrlTracking } from '@strg-behave/tracking-client-plugins'
const urlTracking = createUrlTracking()
urlTracking.on('url', (event) => myTracker.track(event))
Development
Installation
npm install
Testing
npm run test
Coverage Report
Starts an interactive http server on port 8888
.
npm run coverage
ESLint
To check the code syntax integrity according to our ESLint specification run:
npm run lint
To autofix code syntax integrity run:
npm run lint:fix
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository. To increase a version and tag in GIT run:
npm version major|minor|patch
Authors
- Ralf Traunsteiner - plugin implementations
- Nils Müller - library