Skip to content

Commit

Permalink
Add custom document and analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyis committed Apr 16, 2018
1 parent 5b2ed6f commit 8a0d96d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions pages/_document.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import Document, { Head, Main, NextScript } from 'next/document'

export default class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx)
return { ...initialProps }
}

render() {
return (
<html>
<Head>
<style>{`body { margin: 0 } /* custom! */`}</style>
</Head>
<body className="custom_class">
<Main />
<NextScript />
<script
async
src="https://www.googletagmanager.com/gtag/js?id=UA-117491914-1"
/>
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-117491914-1');
`
}}
/>
</body>
</html>
)
}
}

0 comments on commit 8a0d96d

Please sign in to comment.