Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save liesislukas/6e63a13aaa586bb7aeb323d71d8b140c to your computer and use it in GitHub Desktop.
Save liesislukas/6e63a13aaa586bb7aeb323d71d8b140c to your computer and use it in GitHub Desktop.
const ReactGA = require('react-ga');
ReactGA.initialize('UA-00000000000-1');
const _route_change_handler = (location) => {
ReactGA.set({page: location.pathname});
ReactGA.pageview(location.pathname);
};
export default (
<Route
component={ AppContainer }
onChange={(prevState, nextState, replace) => {
_route_change_handler(nextState.location);
return true;
}}
onEnter={(nextState) => {
_route_change_handler(nextState.location);
return true;
}}
>
<Route path='*' component={ PageContainer }/>
</Route>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment