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).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"web_root": "<web_root>",
"measurement_id": "<measurement_id>"
},
"name": "scaffold_ga4_nextjs_tracking"
}
}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 |