Add <GoogleAnalytics /> component

This commit is contained in:
Eric Jinks 2017-07-06 12:19:14 +10:00
parent e5fa9941eb
commit 58bd948871

View file

@ -0,0 +1,16 @@
import React from 'react'
import { Route } from 'react-router-dom'
export default () => (
<Route
path='/'
render={({ location }) => {
// Assumes google analytics code already added to index.html
if (typeof window.ga === 'function') {
window.ga('set', 'page', location.pathname + location.search)
window.ga('send', 'pageview')
}
return null
}}
/>
)