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; }}