Remove the previous historical Google Analytics code

This commit is contained in:
david_bai
2025-07-05 08:25:50 +08:00
parent 3560e0a3d7
commit 98e1e6ace6
-18
View File
@@ -14,7 +14,6 @@ export default async function RootLayout({
params: { lang: string };
}>) {
const messages = await getDictionary(lang);
const googleAnalyticsId = process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS;
return (
<html lang={lang} className="h-full" suppressHydrationWarning>
@@ -32,23 +31,6 @@ export default async function RootLayout({
<div className="flex-1">{children}</div>
<Footer messages={messages} lang={lang} />
</ThemeProvider>
{googleAnalyticsId && (
<>
<Script
src={`https://www.googletagmanager.com/gtag/js?id=${googleAnalyticsId}`}
strategy="afterInteractive" // The script executes after the page is interactive.
/>
<Script id="google-analytics" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${googleAnalyticsId}');
`}
</Script>
</>
)}
</body>
</html>
);