From 04a87216ad8413f0e90021278e52dc7bf97865a0 Mon Sep 17 00:00:00 2001 From: oratis Date: Sat, 27 Jun 2026 21:09:10 +0800 Subject: [PATCH] feat(analytics): add Google Analytics 4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 0 of the GTM plan ("没数据=盲飞") needs an analytics feedback loop. The GSC verification meta and README hero from #31/#32 cover the rest; this adds the missing piece — GA4. - Analytics.tsx: GA4 via next/script (afterInteractive). Production-only so dev/preview traffic never pollutes the data; public measurement ID baked as default with NEXT_PUBLIC_GA_ID override, matching the hardcoded-default + env pattern used for SITE_URL in lib/seo. - layout: render at the end of . Co-Authored-By: Claude Opus 4.8 --- src/app/[locale]/layout.tsx | 2 ++ src/components/Analytics.tsx | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/components/Analytics.tsx diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index 7a5a6f17..25626ac9 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -10,6 +10,7 @@ import "../globals.css"; import Providers from "../providers"; import Header from "@/components/layout/Header"; import Footer from "@/components/layout/Footer"; +import { Analytics } from "@/components/Analytics"; const inter = Inter({ subsets: ["latin"] }); @@ -112,6 +113,7 @@ export default async function LocaleLayout({