2018-03-29 15:03:28 +00:00
|
|
|
import React from 'react'
|
|
|
|
import Document, { Head, Main, NextScript } from 'next/document'
|
|
|
|
import flush from 'styled-jsx/server'
|
|
|
|
|
|
|
|
import { GA_TRACKING_ID } from '../lib/gtag'
|
|
|
|
|
|
|
|
export default class extends Document {
|
|
|
|
static getInitialProps ({ renderPage }) {
|
|
|
|
const { html, head, errorHtml, chunks } = renderPage()
|
|
|
|
const styles = flush()
|
|
|
|
return { html, head, errorHtml, chunks, styles }
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<html>
|
|
|
|
<Head>
|
|
|
|
{/* Global Site Tag (gtag.js) - Google Analytics */}
|
|
|
|
<script
|
|
|
|
async
|
|
|
|
src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`}
|
|
|
|
/>
|
|
|
|
<script
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: `
|
|
|
|
window.dataLayer = window.dataLayer || [];
|
|
|
|
function gtag(){dataLayer.push(arguments);}
|
|
|
|
gtag('js', new Date());
|
|
|
|
|
|
|
|
gtag('config', '${GA_TRACKING_ID}');
|
2018-12-17 16:34:32 +00:00
|
|
|
`
|
|
|
|
}}
|
2018-03-29 15:03:28 +00:00
|
|
|
/>
|
|
|
|
</Head>
|
|
|
|
<body>
|
|
|
|
<Main />
|
|
|
|
<NextScript />
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|