redux-beacon-matomo-tag-manager
Version:
Matomo (formerly Piwik) tag manager integration for redux-beacon.
47 lines (35 loc) • 3.3 kB
Markdown
# redux-beacon-matomo-tag-manager
[](https://npmjs.org/package/redux-beacon-matomo-tag-manager) [](https://npmjs.org/package/redux-beacon-matomo-tag-manager) [](https://github.com/dbartholomae/redux-beacon-matomo-tag-manager/issues) [](https://app.fossa.io/projects/git%2Bgithub.com%2Fdbartholomae%2Fredux-beacon-matomo-tag-manager?ref=badge_shield) [](https://circleci.com/gh/dbartholomae/workflows/redux-beacon-matomo-tag-manager/tree/master) [](https://codecov.io/gh/dbartholomae/redux-beacon-matomo-tag-manager) [](https://david-dm.org/dbartholomae/redux-beacon-matomo-tag-manager) [](https://david-dm.org/dbartholomae/redux-beacon-matomo-tag-manager?type=dev) [](https://greenkeeper.io/) [](https://github.com/semantic-release/semantic-release#badge)
Matomo (formerly Piwik) tag manager integration for [redux-beacon](https://rangle.gitbook.io/redux-beacon/).
## Installation
Download node at [nodejs.org](http://nodejs.org) and install it, if you haven't already.
```sh
npm install redux-beacon-matomo-tag-manager --save
```
## Usage
1. Sign up for or install [Matomo Tag Manager](https://matomo.org/docs/tag-manager/) and create a new web container.
2. Add the Matomo Tag Manager container snippet to your site.
3. Install [redux-beacon](https://rangle.gitbook.io/redux-beacon/) in your app
4. Use this library to connect redux-beacon to the tag manager
```typescript
import { applyMiddleware, createStore } from 'redux'
import { createMiddleware } from 'redux-beacon'
import MatomoTagManager from 'redux-beacon-matomo-tag-manager'
const ACTION_TYPE = 'ACTION_TYPE'
// Set up which actions should trigger which events or variables
const eventsMap = {
[ACTION_TYPE]: () => ({
event: 'integrationTestEvent'
})
}
// Create the middleware
const matomoTagManager = MatomoTagManager()
const matomoTagManagerMiddleware = createMiddleware(eventsMap, matomoTagManager)
const store = createStore((state = {}) => state, applyMiddleware(matomoTagManagerMiddleware))
// When you dispatch an action, the middleware will trigger the event
store.dispatch({
type: ACTION_TYPE
})
```
## Thanks
Thanks to [Matomo](https://matomo.org) for supporting this project by providing an analytics property for integration testing this library.