diff --git a/src/components/GoogleAnalytics.js b/src/components/GoogleAnalytics.js new file mode 100644 index 0000000..fb9a87b --- /dev/null +++ b/src/components/GoogleAnalytics.js @@ -0,0 +1,16 @@ +import React from 'react' +import { Route } from 'react-router-dom' + +export default () => ( + { + // 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 + }} + /> +)