Tracking snippets for Google Analytics and Piwik / Matomo
Instead of adding the Google Analytics and Matomo / Piwik snippets to all your html pages, you can just use this library to include them in your Javascript code.
Using npm
:
$ npm install --save trackings
Using yarn
:
$ yarn add trackings
trackings
can be used as a CommonJS module, AMD (with Require.js) or as a plain old Javacript global.
import { GoogleAnalytics, Matomo } from './trackings.js';
new GoogleAnalytics('UA-xxxxxx-xx'),
new Matomo({
trackerUrl : '//mysite.com/stats/',
siteId : 1
});
<script src="trackings.js"></script>
new trackings.GoogleAnalytics('UA-xxxxxx-xx'),
new trackings.Matomo({
trackerUrl : '//mysite.com/stats/',
siteId : 1
});
new GoogleAnalytics('UA-xxxxxx-xx'),
new trackings.Matomo({
trackerUrl : '//mysite.com/stats/',
siteId : 1
});
MIT © Hay Kranen