Skip to content

Commit b90aa93

Browse files
joelgriffithclaude
andauthored
feat(website): add Google Tag Manager for GA4 (#9)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a83299b commit b90aa93

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎website/src/app/layout.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@ export const metadata: Metadata = {
2626
// Applies the saved theme to <html> before first paint so there is no flash.
2727
const themeInit = `(function(){try{var t=localStorage.getItem("theme");if(t==="light"||t==="dark"){document.documentElement.setAttribute("data-theme",t);}}catch(e){}})();`;
2828

29+
// Google Tag Manager container (GA4 is configured inside it).
30+
const GTM_ID = 'GTM-TR7P7M8P';
31+
const gtagInit = `window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag('js',new Date());`;
32+
2933
export default function RootLayout({ children }: { children: React.ReactNode }) {
3034
return (
3135
// suppressHydrationWarning: themeInit stamps data-theme on <html> before
3236
// hydration, so the attribute legitimately differs from the SSR output.
3337
<html lang="en" className={`${dmSans.variable} ${fraunces.variable}`} suppressHydrationWarning>
3438
<head>
3539
<script dangerouslySetInnerHTML={{ __html: themeInit }} />
40+
<script async src={`https://www.googletagmanager.com/gtm.js?id=${GTM_ID}`} />
41+
<script dangerouslySetInnerHTML={{ __html: gtagInit }} />
3642
</head>
3743
<body className="font-sans antialiased">
3844
<SiteNav />

0 commit comments

Comments
 (0)