Fixes: SPA page tracking
This commit is contained in:
23
server/pages/components/Analytics.js
Normal file
23
server/pages/components/Analytics.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// @flow
|
||||
import * as React from 'react';
|
||||
|
||||
function Analytics() {
|
||||
if (!process.env.GOOGLE_ANALYTICS_ID) return null;
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
|
||||
ga('create', '${process.env.GOOGLE_ANALYTICS_ID}', 'auto');
|
||||
ga('send', 'pageview');
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
<script async src="https://www.google-analytics.com/analytics.js" />
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
export default Analytics;
|
||||
@@ -4,7 +4,7 @@ import { Helmet } from 'react-helmet';
|
||||
import styled from 'styled-components';
|
||||
import breakpoint from 'styled-components-breakpoint';
|
||||
import { TopNavigation, BottomNavigation } from './Navigation';
|
||||
import Analytics from '../../../shared/components/Analytics';
|
||||
import Analytics from './Analytics';
|
||||
import GlobalStyles from '../../../shared/styles/globals';
|
||||
import prefetchTags from '../../utils/prefetchTags';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user