0.0.1 • Published 6 years ago

@njakob/gtag v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Installation

$ npm install @njakob/gtag
$ yarn add @njakob/gtag

Usage

Redux

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);
store.dispatch(gtag.trackPageViewAction('/'))

Server side

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

export default () => `<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
  </head>
  <body>
    <div id="react-root"></div>
    ${gtag.getSnippet()}
  </body>
</html>`;

Changelog

See changelog.

License

MIT License

0.0.1

6 years ago