Add Google Analytics tracking to website (#61)

* Add Google Analytics tracking to website

- Add GA script tags to layout.tsx head section
- Remove @next/third-parties dependency from package.json
- Use measurement ID G-7NBBNJNNQ7 for tracking

* Fix Google Analytics integration for static export

- Use Next.js Script component instead of inline scripts
- Add 'afterInteractive' strategy for optimal loading
- GA scripts now properly included in static build output
This commit is contained in:
Jatin K Malik
2026-01-19 23:38:44 -08:00
committed by GitHub
parent 7426055336
commit 35c091f09b
2 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -49,4 +49,4 @@
"prettier": "^3.3.2",
"prettier-plugin-tailwindcss": "^0.6.5"
}
}
}
+14
View File
@@ -2,6 +2,7 @@ import "@/styles/globals.css";
import React from "react";
import { GeistSans } from "geist/font/sans";
import { type Metadata } from "next";
import Script from "next/script";
import { ThemeProvider } from "@/components/theme-provider";
export const viewport = {
@@ -145,6 +146,19 @@ export default function RootLayout({
/>
</head>
<body>
{/* Google tag (gtag.js) */}
<Script
src="https://www.googletagmanager.com/gtag/js?id=G-7NBBNJNNQ7"
strategy="afterInteractive"
/>
<Script id="google-analytics" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-7NBBNJNNQ7');
`}
</Script>
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
{children}
</ThemeProvider>