Skip to content

Commit ff7728c

Browse files
committed
feat: add Google Tag Manager to marketing website using Next.js Script component
1 parent 4da9c3a commit ff7728c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from "react"
22
import type { Metadata } from "next"
3+
import Script from "next/script"
34
import { Inter } from "next/font/google"
45
import { SEO } from "@/lib/seo"
56
import { ogImageUrl } from "@/lib/og"
@@ -97,6 +98,30 @@ export default function RootLayout({ children }: { children: React.ReactNode })
9798
/>
9899
</head>
99100
<body className={inter.className}>
101+
{/* Google Tag Manager Script */}
102+
<Script
103+
id="google-tag-manager"
104+
strategy="afterInteractive"
105+
dangerouslySetInnerHTML={{
106+
__html: `
107+
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
108+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
109+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
110+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
111+
})(window,document,'script','dataLayer','GTM-M2JZHV8N');
112+
`,
113+
}}
114+
/>
115+
{/* Google Tag Manager (noscript) */}
116+
<noscript>
117+
<iframe
118+
src="https://www.googletagmanager.com/ns.html?id=GTM-M2JZHV8N"
119+
height="0"
120+
width="0"
121+
style={{ display: "none", visibility: "hidden" }}
122+
/>
123+
</noscript>
124+
{/* End Google Tag Manager (noscript) */}
100125
<div itemScope itemType="https://schema.org/WebSite">
101126
<link itemProp="url" href={SEO.url} />
102127
<meta itemProp="name" content={SEO.name} />

0 commit comments

Comments
 (0)