netlify-cms-react-starter/src/components/GoogleAnalytics.js
2017-07-06 12:19:14 +10:00

16 lines
405 B
JavaScript

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
}}
/>
)