Skip to content

Commit

Permalink
add the google tag manager
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanshipf committed Jan 30, 2024
1 parent 5e27413 commit b921407
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,30 @@ export default function RootLayout({
<meta name="version" content={buildConfig.commitId} />
<link rel="manifest" href="/site.webmanifest"></link>
<script src="/serviceWorkerRegister.js" defer></script>
{/* 插入 GTM 的 <head> 部分代码 */}
<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-PLMWKRSN');
`,
}}
></script>
</head>
<body>{children}</body>
<body>
<noscript
dangerouslySetInnerHTML={{
__html: `
<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PLMWKRSN"
height="0" width="0" style="display:none;visibility:hidden"></iframe>
`,
}}
></noscript>
{children}
</body>
</html>
);
}

0 comments on commit b921407

Please sign in to comment.