37 lines
1.2 KiB
Markdown
37 lines
1.2 KiB
Markdown
|
|
### Overview
|
||
|
|
Basic wrapped around Google Analytics APIs. Should work for both Node and Electron apps.
|
||
|
|
|
||
|
|
### Installation
|
||
|
|
|
||
|
|
```bash
|
||
|
|
npm install --save jibo-analytics
|
||
|
|
```
|
||
|
|
|
||
|
|
### Usage
|
||
|
|
|
||
|
|
#### analytics.event(eventCategory, eventAction, extraParameters [optional])
|
||
|
|
|
||
|
|
| Parameter | Type | Description | Example | Optional |
|
||
|
|
|-----------|------|-------------|---|---|
|
||
|
|
| **eventCategory** | String | Category of the event | `"toolbar"` | false |
|
||
|
|
| **eventAction** | String | Name of the event action | `"play"` | false |
|
||
|
|
| **extrasParameters** | Object | If you want to track extra meta data for the event add the fields/values here. | `{mode: "local"}` | true |
|
||
|
|
|
||
|
|
Example:
|
||
|
|
```js
|
||
|
|
import analytics from 'jibo-analytics';
|
||
|
|
|
||
|
|
analytics.init('UA-*', "<unique-user-id>");
|
||
|
|
analytics.event('toolbar', 'play', {
|
||
|
|
mode: 'local'
|
||
|
|
});
|
||
|
|
```
|
||
|
|
|
||
|
|
### Reference
|
||
|
|
- [Working with the Measurement Protocol](https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide)
|
||
|
|
- [Google Hit Builder Playground](https://ga-dev-tools.appspot.com/hit-builder/). Use the following example:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
v=1&t=event&tid=UA-12345678-9&cid=fa15259f-b078-466f-bf3b-ba0479b008fd&ec=toolbar&ea=play&el=local
|
||
|
|
```
|