Skip to content

Commit 7362256

Browse files
committed
fix: use next/script component for Google Tag Manager to resolve linting error
1 parent 7846e51 commit 7362256

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react"
22
import type { Metadata } from "next"
33
import { Inter } from "next/font/google"
4+
import Script from "next/script"
45

56
import { Providers } from "@/components/providers"
67

@@ -45,17 +46,6 @@ export default function RootLayout({ children }: { children: React.ReactNode })
4546
return (
4647
<html lang="en" suppressHydrationWarning>
4748
<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 */}
5949
<link
6050
rel="stylesheet"
6151
type="text/css"
@@ -79,6 +69,19 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
7969
<Providers>
8070
<Shell>{children}</Shell>
8171
</Providers>
72+
{/* Google Tag Manager */}
73+
<Script
74+
id="google-tag-manager"
75+
strategy="afterInteractive"
76+
dangerouslySetInnerHTML={{
77+
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
78+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
79+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
80+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
81+
})(window,document,'script','dataLayer','GTM-M2JZHV8N');`,
82+
}}
83+
/>
84+
{/* End Google Tag Manager */}
8285
</body>
8386
</html>
8487
)

0 commit comments

Comments
 (0)