scaffold_ga4_nextjs_tracking
Set up Google Analytics 4 for a Next.js app by writing GoogleAnalytics.tsx, wiring layout.tsx, and configuring the measurement ID in .env.local.
Instructions
Scaffold GA4 for a Next.js app: write GoogleAnalytics.tsx, wire layout.tsx, and set NEXT_PUBLIC_GA_MEASUREMENT_ID in .env.local (when mode=env). web_root must be the Next.js package root (directory containing package.json).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | env | |
| dry_run | No | ||
| web_root | Yes | ||
| consent_gated | No | ||
| measurement_id | Yes | ||
| layout_relative | No | src/app/layout.tsx |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |