Analytics (#582)

* gtm > ga

* Record pageviews in SPA

* Remove home-rolled tracking in favor of autotrack

* cleanup
This commit is contained in:
Tom Moor
2018-02-10 23:23:50 -08:00
committed by GitHub
parent bd84a73b20
commit 4cc7338534
8 changed files with 148 additions and 28 deletions

View File

@ -1,24 +1,20 @@
// @flow
import React from 'react';
import * as React from 'react';
function Analytics() {
const id = process.env.GOOGLE_ANALYTICS_ID;
if (!id) return null;
if (!process.env.GOOGLE_ANALYTICS_ID) return null;
return (
<span>
<script src={`https://www.googletagmanager.com/gtag/js?id=${id}`} />
<React.Fragment>
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${id}');
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
`,
}}
/>
</span>
<script async src="https://www.google-analytics.com/analytics.js" />
</React.Fragment>
);
}