Skip to content

Commit

Permalink
feat(homepage): add google tag management in _document
Browse files Browse the repository at this point in the history
  • Loading branch information
ben196888 committed Sep 25, 2023
1 parent eb8cb03 commit 058c02f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion homepage/src/pages/_document.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Html, Head, Main, NextScript } from 'next/document';
import { GTM_ID } from '../lib/gtm';

export default function Document({ locale }) {
return (
<Html lang={locale}>
<Html>
<Head>
<meta charSet="utf-8" />
<link
Expand Down Expand Up @@ -35,10 +36,25 @@ export default function Document({ locale }) {
src="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/js/fontawesome.min.js"
defer
></script>
{/* <!-- Google tag (gtag.js) --> */}
<script
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_ID});`,
}}
/>
</Head>
<body id="page-top">
<Main />
<NextScript />
<noscript
dangerouslySetInnerHTML={{
__html: `<iframe src="https://www.googletagmanager.com/ns.html?id=${GTM_ID}" height="0" width="0" style="display: none; visibility: hidden;" />`,
}}
/>
</body>
</Html>
);
Expand Down

0 comments on commit 058c02f

Please sign in to comment.