Skip to content

Commit 64f5928

Browse files
committed
ga
1 parent 0b2a3fe commit 64f5928

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.

app/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Metadata } from "next";
22
import { Inter, JetBrains_Mono } from "next/font/google";
33
import "./globals.css";
4+
import GoogleAnalytics from "../components/GoogleAnalytics";
45

56
const inter = Inter({
67
variable: "--font-inter",
@@ -26,6 +27,7 @@ export default function RootLayout({
2627
<body
2728
className={`${inter.variable} ${jetbrainsMono.variable} antialiased`}
2829
>
30+
<GoogleAnalytics />
2931
{children}
3032
</body>
3133
</html>

components/GoogleAnalytics.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use client';
2+
3+
import Script from 'next/script';
4+
5+
const GA_TRACKING_ID = 'G-B84V644JQH';
6+
7+
export default function GoogleAnalytics() {
8+
return (
9+
<>
10+
<Script
11+
src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`}
12+
strategy="afterInteractive"
13+
/>
14+
<Script id="google-analytics" strategy="afterInteractive">
15+
{`
16+
window.dataLayer = window.dataLayer || [];
17+
function gtag(){dataLayer.push(arguments);}
18+
gtag('js', new Date());
19+
gtag('config', '${GA_TRACKING_ID}');
20+
`}
21+
</Script>
22+
</>
23+
);
24+
}

0 commit comments

Comments
 (0)