ReduxGTM
Google Tag Manager integration for Redux and ngrx/store
![CircleCI](https://img.shields.io/circleci/project/github/rangle/redux-gtm.svg?style=flat-square)
Getting Started
Prerequisites
Installation
With npm:
npm install --save redux-gtm
With yarn:
yarn add redux-gtm
How it Works
import reducer from './reducer';
import { createStore, applyMiddleware } from 'redux';
import { createMiddleware } from 'redux-gtm';
const eventDefinitions = {
'SOME_REDUX_ACTION_TYPE': { eventName: 'some-gtm-custom-event' },
};
const analyticsMiddleware = createMiddleware(eventDefinitions);
const store = createStore(reducer, applyMiddleware(analyticsMiddleware));
Now, whenever your application dispatches SOME_REDUX_ACTION_TYPE
,
ReduxGTM will emit some-gtm-custom-event
to Google Tag Manager.
Notes
- When mapping actions to events, each action type must be mapped to a
valid eventDefinition.
Examples
API
License
This project is licensed under the MIT License - see
the LICENSE file for details