Skip to content

Commit

Permalink
feat: Add Google Tag Manager
Browse files Browse the repository at this point in the history
SC-1719
  • Loading branch information
mdt2 committed Jun 12, 2023
1 parent 1cfc63d commit d71a8a5
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/pages/_document.page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,29 @@ import { Html, Head, Main, NextScript } from 'next/document';
export default function Document() {
return (
<Html lang="en">
<Head />
<Head>
{/* eslint-disable-next-line @next/next/next-script-for-ga */}
<script
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: `
(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','GTM-KQ53HCR');
`,
}}
/>
</Head>
<body>
<Main />
<NextScript />
<noscript
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: `<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KQ53HCR" height="0" width="0" style="display:none;visibility:hidden"></iframe>`,
}}
/>
</body>
</Html>
);
Expand Down

0 comments on commit d71a8a5

Please sign in to comment.