Skip to content

Commit 7846e51

Browse files
committed
feat: add Google Tag Manager to website
- Add GTM script tag in head section as high as possible - Add GTM noscript fallback immediately after body opening tag - Use container ID GTM-M2JZHV8N as specified - Implement in root layout for site-wide coverage - Follow Google's implementation guidelines and Next.js best practices
1 parent b45252d commit 7846e51

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

apps/web-roo-code/src/app/layout.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,33 @@ export default function RootLayout({ children }: { children: React.ReactNode })
4545
return (
4646
<html lang="en" suppressHydrationWarning>
4747
<head>
48+
{/* Google Tag Manager */}
49+
<script
50+
dangerouslySetInnerHTML={{
51+
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
52+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
53+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
54+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
55+
})(window,document,'script','dataLayer','GTM-M2JZHV8N');`,
56+
}}
57+
/>
58+
{/* End Google Tag Manager */}
4859
<link
4960
rel="stylesheet"
5061
type="text/css"
5162
href="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/devicon.min.css"
5263
/>
5364
</head>
5465
<body className={inter.className}>
66+
{/* Google Tag Manager (noscript) */}
67+
<noscript>
68+
<iframe
69+
src="https://www.googletagmanager.com/ns.html?id=GTM-M2JZHV8N"
70+
height="0"
71+
width="0"
72+
style={{ display: "none", visibility: "hidden" }}></iframe>
73+
</noscript>
74+
{/* End Google Tag Manager (noscript) */}
5575
<div itemScope itemType="https://schema.org/WebSite">
5676
<link itemProp="url" href="https://roocode.com" />
5777
<meta itemProp="name" content="Roo Code" />

0 commit comments

Comments
 (0)