GA SPA integration

This commit is contained in:
SleepWalker
2016-11-20 14:01:57 +02:00
parent 251a1237b4
commit e0a1f0c845
2 changed files with 19 additions and 10 deletions

View File

@@ -87,6 +87,19 @@ function restoreScroll() {
}, 200);
}
browserHistory.listen(trackPageView);
function trackPageView(location) {
const ga = window.ga;
if (!ga) {
return;
}
ga('set', 'page', location.pathname + location.search);
ga('send', 'pageview');
}
/* global process: false */
if (process.env.NODE_ENV !== 'production') {
// some shortcuts for testing on localhost