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:
+1
-1
@@ -49,4 +49,4 @@
|
||||
"prettier": "^3.3.2",
|
||||
"prettier-plugin-tailwindcss": "^0.6.5"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user