From 58bd948871b3062a2d533153e8489d2746c1fcf6 Mon Sep 17 00:00:00 2001 From: Eric Jinks Date: Thu, 6 Jul 2017 12:19:14 +1000 Subject: [PATCH] Add component --- src/components/GoogleAnalytics.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/components/GoogleAnalytics.js 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 + }} + /> +)