Skip to content

Commit

Permalink
change to google tag manager (deepset-ai#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
PiffPaffM committed Sep 10, 2021
1 parent 36d3b01 commit f4ebe26
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@ class MyDocument extends Document {
return (
<Html>
<Head>
<script
async
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}`}
/>
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}', {
page_path: window.location.pathname,
});
(function(w,d,s,l,i){
w[l]=w[l]||[];
w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})
(window,document,'script','dataLayer','${process.env.NEXT_PUBLIC_GOOGLE_TAG_ANALYTICS}');
`,
}}
/>
</Head>
<body>
<noscript dangerouslySetInnerHTML={{ __html: `<iframe src="https://www.googletagmanager.com/ns.html?id=${process.env.NEXT_PUBLIC_GOOGLE_TAG_ANALYTICS}"
height="0" width="0" style="display:none;visibility:hidden"></iframe>`}}></noscript>
<Main />
<NextScript />
</body>
Expand Down

0 comments on commit f4ebe26

Please sign in to comment.