Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/njakob/gtag

Simple Google Analytics wrapper for Redux
https://github.com/njakob/gtag

Last synced: 17 days ago
JSON representation

Simple Google Analytics wrapper for Redux

Awesome Lists containing this project

README

        


gtag


Simple Google Analytics wrapper for Redux


Build Status
NPM version
Conventional Commits

## Installation

```
$ npm install @njakob/gtag
```

```
$ yarn add @njakob/gtag
```

## Usage

### Redux

```js
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
import * as gtag from '@njakob/gtag';

const yourEnhancers = compose(
applyMiddleware(
gtag.middleware({ gaTrackingID: 'YOUR_TRACKING_ID' }),
// Other middlewares
),
);

const store = createStore(yourReducer, yourEnhancers);
```

```js
store.dispatch(gtag.trackPageViewAction('/'))
```

### Server side

```js
import { getSnippet } from '@njakob/gtag';

export default () => `






${gtag.getSnippet()}

`;
```

## Changelog

See [changelog](CHANGELOG).

## License

[MIT License](LICENSE)