Repository URL to install this package:
|
Version:
1.4.3 ▾
|
| src |
| state |
| views |
| package.json |
| index.js |
| README.md |
A redux/redux-saga connector that provides actions, reducers and sagas for interacting with Google Tag Manager. It communicates with the Tag Manager through the "Data Layer".
CI/CD: https://builder.internal.doodle-test.com/job/stack/job/web-tagmanager/
yarn install @doodle/tagmanager
Add tagmanager script:
<html> <head> <!-- other head stuff --> <%- include(`${nodeModulesPath}/@doodle/tagmanager/views/head.ejs`); %> </head> <body> <%- include(`${nodeModulesPath}/@doodle/tagmanager/views/body.ejs`); %> <!-- other body stuff --> </body> </html>
Include the tagManagerSaga in your app‘s rootSaga:
// root saga import { all, call } from 'redux-saga/effects'; import { tagManagerSaga } from '@doodle/tagmanager'; export default function* rootSaga(options = {}) { yield all([ /* ... other sagas */ call(tagManagerSaga, options.tagManager), ]); }
Dispatch action that pushes values into the dataLayer:
dispatch( pushDataLayer({ event: 'gtmEvent', eventCategory: 'userInteraction', eventNonInteraction: 'False', eventAction: 'userLogin', }, { pageType: 'somePage' }) );
If you want to wait until the tracking actually finished before moving on, you can wait for the tracking call.
This is especially useful when you want to track clicks to links that cause navigation to another page (since the tracking might potentially get lost if the new page is loaded before the tracking call has finished).
dispatch( pushDataLayerAndWait({ event: 'gtmEvent', eventCategory: 'userInteraction', eventNonInteraction: 'False', eventAction: 'userLogin', }, { pageType: 'somePage' }) );
See also the JSDoc in the action definitions.
yarn
yarn start
yarn build
yarn test
Note: This requires a globally installed gulp (e.g. via yarn global add gulp).
The publish task does two things:
npm publish.For bumping version, there are three different options:
(1) Per default, the patch version will be bumped:
# e.g. 2.1.7 → 2.1.8 gulp publish
(2) You can define which type of version bump you want to do:
# e.g. 2.1.7 → 3.0.0 gulp publish --type major
(3) Define the exact version to bump to:
# e.g. 2.1.7 → 4.0.2 gulp publish --pkg-version 4.0.2