UNPKG

2.2 kBMarkdownView Raw
1Measurement Framework
2=======
3[![NPM Version][npm-image]][npm-url]
4![Stability][stability-image]
5
6Collection of Javascript code to implement a browser based measurement
7system for websites. Its created of several functions that integrate
8with Google Tag Manager, Google Analytics and jQuery.
9
10
11
12## Install
13
14
15
16## Functions
17* AjaxComplete (jQuery)
18* Client ID Setter for Google Analytics
19* Content Engagement
20* Custom Task in GA
21* DomReady
22* KlarnaCheckout Hooks
23* Kudakeru (Tracking code for the
24* Iframe to Parent Messages
25* SendHitTask for GA
26* User Trail
27
28
29## Usage
30
31
32### User Trail
33It uses a cookie to store a users action on a webpage and let you map
34thoose actions to a particular state in the user journey using a function.
35
36### Content Engagement
37The module is created to measure users based on "engaged" time and not actual
38time. Engaged time is defined as the time a user clicks, scrolls, moving the mouse
39or using the keyboard. Its heavily inspired by
40[Simo Ahava's script from 2016](https://www.simoahava.com/analytics/track-content-engagement-via-gtm/) but can
41trigger multiple events, should be a little bit more precise and gready.
42
43```javascript
44import MeasurementFramework, {contentEngaged} from "measurement-framework"
45
46let eventName = "Content Viewed"
47let secondsToTrigger = 12
48
49contentEngaged(eventName, secondsToTrigger, function (dataLayerPush) {
50 dataLayerPush.debugText = "Target time for Content Viewed is 12 seconds."
51})
52
53MeasurementFramework.init()
54```
55
56The script could also be used to measure Real Time on site.
57
58
59## Building with rollup
60Rollup and other javascript compilers doesn't support removing unused
61methods form classes. This is why the measurement framework i built on
62running several functions instead of importing a class to hold them.
63Internally these uses the MeasurementFramework class to hold state and
64to orcestrate between classes. This makes the package nice and tight.
65
66[npm-image]: https://img.shields.io/npm/v/measurement-framework.svg
67[npm-url]: https://npmjs.org/package/measurement-framework
68[stability-image]: https://img.shields.io/badge/stability-experimental-orange.svg
69[stability-url]: https://github.com/mijohansen/measurement-framework
70