diff --git a/src/index.ejs b/src/index.ejs index e66c4a6..9c364cd 100644 --- a/src/index.ejs +++ b/src/index.ejs @@ -29,16 +29,12 @@ } %> - - + + + <% } %> diff --git a/src/index.js b/src/index.js index 8c5d79b..2f08abb 100644 --- a/src/index.js +++ b/src/index.js @@ -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