Skip to content

Commit 67ec0de

Browse files
committed
Add GA code
1 parent 0bdfc91 commit 67ec0de

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/app/layout.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { type Metadata } from 'next'
2+
import Script from 'next/script'
23

34
import '@/styles/tailwind.css'
45

@@ -10,8 +11,28 @@ export const metadata: Metadata = {
1011
}
1112

1213
export default function Layout({ children }: { children: React.ReactNode }) {
14+
const gaId = 'G-FN7FNMGXNM'
15+
1316
return (
1417
<html lang="en" className="h-full bg-sky-900 text-base antialiased">
18+
<head>
19+
{gaId && (
20+
<>
21+
<Script
22+
src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`}
23+
strategy="afterInteractive"
24+
/>
25+
<Script id="google-analytics" strategy="afterInteractive">
26+
{`
27+
window.dataLayer = window.dataLayer || [];
28+
function gtag(){window.dataLayer.push(arguments);}
29+
gtag('js', new Date());
30+
gtag('config', '${gaId}');
31+
`}
32+
</Script>
33+
</>
34+
)}
35+
</head>
1536
<body className="flex min-h-full flex-col">{children}</body>
1637
</html>
1738
)

0 commit comments

Comments
 (0)