data-layer-events
Version:
Push clean events onto Google Tag Manager's dataLayer
39 lines (23 loc) • 1.24 kB
Markdown
# data-layer-events
This package pushes [Google Analytics type events](https://developers.google.com/analytics/devguides/collection/analyticsjs/events) onto [Google Tag Manager's dataLayer variable](https://developers.google.com/tag-manager/devguide#datalayer). It cleans up after each push by `null`-ing keys that aren't used and supports `nonInteraction` events.
## Setup
Setup Google Tag Manager Variables for:
- `genericCategory`
- `genericAction`
- `genericLabel`
- `genericValue`
- `genericNonInteraction`
For example:

Then create a Trigger for `genericEvent`. Like this:

Finally create Tag that combines all of these. Like this:

## Usage
```js
dataLayer = require('data-layer-events');
// Fire a normal, interaction event
dataLayer.event('Category', 'Action', 'Label', 'Value');
// Fire a non-interaction event
dataLayer.nonInteractionEvent('Category', 'Action', 'Label', 'Value');
```