Add <GoogleAnalytics /> component
This commit is contained in:
parent
e5fa9941eb
commit
58bd948871
1 changed files with 16 additions and 0 deletions
16
src/components/GoogleAnalytics.js
Normal file
16
src/components/GoogleAnalytics.js
Normal 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
|
||||
}}
|
||||
/>
|
||||
)
|
||||
Loading…
Add table
Reference in a new issue