From 724c87f01f768d0d9c36057145437293b915fa5d Mon Sep 17 00:00:00 2001 From: Reed Dadoune Date: Sat, 25 Aug 2018 18:27:33 -0700 Subject: [PATCH] fix(analytics): Use gtag --- src/App.tsx | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index d20cdff..491b30a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -37,16 +37,20 @@ const App: React.SFC = ({ author, siteName, googleAnalytics }) => { href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700" type="text/css" /> + {addAnalytics && ( + )} @@ -55,10 +59,12 @@ const App: React.SFC = ({ author, siteName, googleAnalytics }) => { { - const ga = typeof window !== 'undefined' && (window as any).ga; - if (ga) { - ga('set', 'page', location.pathname + location.search); - ga('send', 'pageview'); + const gtag = + typeof window !== 'undefined' && (window as any).gtag; + if (addAnalytics && gtag) { + gtag('config', googleAnalytics, { + page_path: location.pathname + location.search, + }); } return null; }}