feat: 接入 Google Analytics (G-LVVXH3TL04)

This commit is contained in:
jackyu66git
2026-07-02 15:57:36 +08:00
parent 6530b20172
commit 35f1b7ffb3
+15
View File
@@ -1,5 +1,6 @@
import type { Metadata } from "next";
import { cookies, headers } from "next/headers";
import Script from "next/script";
import { DM_Sans, Fraunces } from "next/font/google";
import TabBar from "@/components/TabBar";
import LanguageSwitcher from "@/components/LanguageSwitcher";
@@ -41,6 +42,20 @@ export default async function RootLayout({
lang={lang}
className={`${fraunces.variable} ${dmSans.variable} h-full antialiased`}
>
<head>
<Script
src="https://www.googletagmanager.com/gtag/js?id=G-LVVXH3TL04"
strategy="afterInteractive"
/>
<Script id="google-analytics" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-LVVXH3TL04');
`}
</Script>
</head>
<body className={`min-h-full flex flex-col ${isInternal ? "" : "pb-16"} bg-cream dark:bg-[#1E1A14] text-ink dark:text-[#F3EFE8]`}>
<I18nProvider>
<main className="flex-1 max-w-2xl mx-auto w-full px-5 pt-8 pb-4 relative">