This commit is contained in:
Kalle (Sendou)
2021-01-12 01:35:40 +02:00
parent 004c468b49
commit d2059079d3

View File

@@ -7,6 +7,8 @@ import Document, {
NextScript,
} from "next/document";
const GA_TRACKING_ID = "UA-163861331-1";
class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const initialProps = await Document.getInitialProps(ctx);
@@ -17,7 +19,25 @@ class MyDocument extends Document {
render() {
return (
<Html>
<Head />
<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}', {
page_path: window.location.pathname,
});
`,
}}
/>
</Head>
<body>
<ColorModeScript />
<Main />