@njakob/gtag

0.0.1 • Public • Published

gtag

Simple Google Analytics wrapper for Redux

Build Status NPM version Conventional Commits

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

Readme

Keywords

none

Package Sidebar

Install

npm i @njakob/gtag

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • njakob