2.0.3 • Published 2 years ago

mpanalytics v2.0.3

Weekly downloads
142
License
MIT
Repository
github
Last release
2 years ago

mpanalytics

Simple wrapper around google analytics measurement protocol, supporting both nodejs and browsers thanks to superagent.

For testing please provide your own property id in test/config.js

Example

import mpanalytics from 'mpanalytics';

const tracker = mpanalytics.create({
	tid: 'UA-...',
	cid: 'my anonymous client identifier',
	sampleRate: 100,
});

tracker.pageview({
	hostname: 'example.com',
	page: '/home',
}, function (err) {
	console.log(err);
});

track events

tracker.event({
	category: 'foo',
	action: 'bar',
});

Options

mpanalytics.create supports the following options:

  • cid: Client ID (pseudonymously identifies a particular user/device)
  • tid: Tracking ID / Web Property ID
  • sampleRate: Only send a sample based on cid+tid, 0 to 100 (default)

Chrome apps

The policy definition in your manifest.json might look like:

"content_security_policy": "script-src 'self' https://www.google-analytics.com; object-src 'self'",

Tested on

  • iOS 9.3
  • Chrome 49
2.0.3

2 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.0

4 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago