npm

npm’s 2019 JavaScript ecosystem survey analysis is now available! Get your copy here »

react-router-google-analytics

1.0.4 • Public • Published

NPM Version Build Status

react-router-google-analytics

The react router implementation for Google Analytics, server side rendring ready.

How to use

install

npm install react-router-google-analytics --save

setup

in your universal.js.

import Ga from 'react-router-google-analytics';

.
.
.

export function createClientApp(store, history, trackingCode, env) {
  const ga  = Ga(trackingCode);

  return (
    <Provider store={store}>
      <Router
         history={history}
         onUpdate={() => env === 'production' && ga('send', 'pageview', location.pathname)}
         >
        {routes}
      </Router>
    </Provider>
  );
}

export function createServerApp(store, props) {
  return (
    <Provider store={store}>
      <RouterContext {...props} />
    </Provider>
  );
}

install

npm i react-router-google-analytics

Downloadsweekly downloads

13

version

1.0.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability