Add google analytics scripts

This commit is contained in:
Hazem Krimi
2021-01-15 18:58:05 +01:00
parent 29b8ad07f5
commit 37953d4ea6
+26 -1
View File
@@ -1,4 +1,4 @@
import Document from 'next/document'; import Document, { Html, Head, Main, NextScript } from 'next/document';
import { ServerStyleSheet } from 'styled-components'; import { ServerStyleSheet } from 'styled-components';
class Doc extends Document { class Doc extends Document {
@@ -26,6 +26,31 @@ class Doc extends Document {
sheet.seal(); sheet.seal();
} }
} }
render() {
return (
<Html>
<Head>
<script async src='https://www.googletagmanager.com/gtag/js?id=G-FMD81GLKS3'></script>
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-FMD81GLKS3');
`
}}
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
} }
export default Doc; export default Doc;