https://github.com/hay/trackings
Tracking snippets for Google Analytics and Piwik / Matomo
https://github.com/hay/trackings
google-analytics javascript matomo npm piwik snippet tracking
Last synced: 7 months ago
JSON representation
Tracking snippets for Google Analytics and Piwik / Matomo
- Host: GitHub
- URL: https://github.com/hay/trackings
- Owner: hay
- License: mit
- Created: 2018-05-20T10:24:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-20T10:35:25.000Z (over 7 years ago)
- Last Synced: 2025-03-19T06:41:49.340Z (7 months ago)
- Topics: google-analytics, javascript, matomo, npm, piwik, snippet, tracking
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# trackings
> Tracking snippets for Google Analytics and Piwik / MatomoInstead 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.
## Install
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.
## Usage
### ES6
```javascript
import { GoogleAnalytics, Matomo } from './trackings.js';new GoogleAnalytics('UA-xxxxxx-xx'),
new Matomo({
trackerUrl : '//mysite.com/stats/',
siteId : 1
});
```### Old style ES5
```html```
```javascript
new trackings.GoogleAnalytics('UA-xxxxxx-xx'),new trackings.Matomo({
trackerUrl : '//mysite.com/stats/',
siteId : 1
});
```## API
### GoogleAnalytics(id)
```javascript
new GoogleAnalytics('UA-xxxxxx-xx'),
```### Matomo({ trackerUrl, siteId })
```javascript
new trackings.Matomo({
trackerUrl : '//mysite.com/stats/',
siteId : 1
});
```## License
MIT © [Hay Kranen](http://www.haykranen.nl)