nextjs-vercel-analytics
Skill1 starsChanged 5 months agoMITView on GitHub
Add privacy-safe Vercel Web Analytics to Next.js apps, including pageview setup, typed client and server custom events, strict no-PII payload rules, App Router or Pages Router placement, and local verification. Use when a user asks to add, implement, instrument, review, or fix Vercel analytics, Vercel Web Analytics, analytics custom events, product tracking, funnel tracking, frontend or backend event tracking, or analytics privacy in a Next.js repo.
In this repository15 other files it gives its agents.
- clarify-before-buildSkill
- client-requirements-to-planSkill
- codebase-prune-reviewSkill
- docker-disk-cleanupSkill
- error-logging-instrumentationSkill
- feature-design-preflightSkill
- frontend-design-qualitySkill
- full-app-reviewSkill
- laptop-currency-maintenanceSkill
- pr-production-gateSkill
- repo-technical-documentationSkill
- repo-testing-setupSkill
- security-threat-modelSkill
- test-readiness-preflightSkill
- user-action-coverage-reviewSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
19 rules. About 0 are common, 7 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Use this skill to implement Vercel Web Analytics in a Next.js repo with a typed, privacy-safe event contract shared by frontend and backend …
- Distinctive: line 18
Read repo instructions: root AGENTS.md, repo-local AGENTS.md, package manager files, and existing test commands.
- Distinctive: line 22
Search existing instrumentation before adding anything:
- Very specific: line 24
Check current official Vercel docs and latest stable @vercel/analytics version at implementation time.
- Distinctive: line 31
Use the repo's package manager.
- Distinctive: line 33
Update package manifest and lockfile together.
- Very specific: line 41
Prefer an existing convention.
- Very specific: line 47
Read references/event-contract.md before designing event names or properties.
- Distinctive: line 52
Do not double-count the same business event on both sides.
- Distinctive: line 55
Never send names, emails, phone numbers, raw user IDs, tenant IDs, tokens, session IDs, IPs, addresses, exact URLs with query strings, raw …
- Distinctive: line 56
Prefer coarse enums, booleans, counts, durations, plan tiers, source surfaces, role labels, and result categories.
- Very specific: line 57
Read references/privacy-and-security.md before adding properties.
- Very specific: line 60
Use $feature-design-preflight before implementing analytics for nontrivial flows, funnels, auth, billing, admin portals, uploads, AI, …
- Very specific: line 61
Use $security-threat-model for analytics payload/privacy review before push-readiness.
- Very specific: line 62
Use $frontend-design-quality if analytics changes require UI controls, banners, dashboards, consent surfaces, or visible tracking state.
- Very specific: line 66
Read references/verification-checklist.md and run the repo's canonical local/container gate.
- Very specific: line 90
Read references/event-contract.md for the shared typed event model.
- Very specific: line 91
Read references/privacy-and-security.md for payload and abuse-path rules.
- Very specific: line 92
Read references/verification-checklist.md for tests and local validation.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Next.js Vercel Analytics
Purpose
Use this skill to implement Vercel Web Analytics in a Next.js repo with a typed, privacy-safe event contract shared by frontend and backend tracking. Default scope is analytics only: pageviews plus custom client/server events.
Out of scope unless explicitly requested: Speed Insights, OpenTelemetry, tracing, runtime log drains, dashboards, alerts, third-party analytics, and querying analytics data from Vercel.
Required Starting Point
Before editing code:
- Read repo instructions: root
AGENTS.md, repo-localAGENTS.md, package manager files, and existing test commands. - Identify router mode:
- App Router:
app/layout.*orsrc/app/layout.* - Pages Router:
pages/_app.*orsrc/pages/_app.*
- App Router:
- Search existing instrumentation before adding anything:
rg -n "@vercel/analytics|Analytics|track\\(|analytics|telemetry|posthog|plausible|segment|gtag|dataLayer" .
- Check current official Vercel docs and latest stable
@vercel/analyticsversion at implementation time. Do not rely on model memory for version freshness. - Confirm that Web Analytics is enabled, or must be enabled, in the target Vercel project dashboard.
- Confirm whether custom events are expected. If yes, ask whether the Vercel project has the required custom-event entitlement. Current Vercel docs state Web Analytics is available on all plans, while custom events require Pro or Enterprise.
Implementation Workflow
- Install package.
- Use the repo's package manager.
- Install latest stable
@vercel/analytics. - Update package manifest and lockfile together.
- Add pageview analytics.
- App Router: import
{ Analytics }from@vercel/analytics/nextin the root layout and render<Analytics />near the end of<body>. - Pages Router: import
{ Analytics }from@vercel/analytics/nextin_appand render<Analytics />with the app shell. - Preserve existing layout structure, providers, metadata, and server/client component boundaries.
- App Router: import
- Create typed analytics module.
- Prefer an existing convention. If none exists, use
src/lib/analytics/orlib/analytics/. - Provide at least:
AnalyticsEventNameAnalyticsEventPropertiestrackClientEvent(eventName, properties)trackServerEvent(eventName, properties)
- Read
references/event-contract.mdbefore designing event names or properties.
- Prefer an existing convention. If none exists, use
- Instrument flows with intent and outcome separation.
- Frontend events represent user intent or UI interaction, such as button clicked, form started, filter applied, or CTA selected.
- Backend events represent authoritative outcomes, such as signup completed, invite accepted, purchase completed, file processed, or mutation failed safely.
- Do not double-count the same business event on both sides. Use frontend for interaction intent and server for confirmed outcomes.
- Keep payloads strict no-PII.
- Never send names, emails, phone numbers, raw user IDs, tenant IDs, tokens, session IDs, IPs, addresses, exact URLs with query strings, raw prompts, free text, filenames, document contents, or error stacks.
- Prefer coarse enums, booleans, counts, durations, plan tiers, source surfaces, role labels, and result categories.
- Read
references/privacy-and-security.mdbefore adding properties.
- Security and planning gates.
- Use
$feature-design-preflightbefore implementing analytics for nontrivial flows, funnels, auth, billing, admin portals, uploads, AI, storage, or sensitive workflows. - Use
$security-threat-modelfor analytics payload/privacy review before push-readiness. - Use
$frontend-design-qualityif analytics changes require UI controls, banners, dashboards, consent surfaces, or visible tracking state.
- Use
Verification
Read references/verification-checklist.md and run the repo's canonical local/container gate.
Minimum proof:
- Typecheck/build pass.
- Unit tests for event name/property validation and no-PII guard helpers.
- Integration tests for server-side tracking wrappers or route/action instrumentation.
- Browser/E2E coverage for changed user actions.
- Network or module-mock verification that expected analytics calls are made without sensitive payloads.
gitleaksbefore push.$security-threat-modelreview completed for changed analytics surfaces.
Example Requests
This skill should trigger for prompts like:
- "Add Vercel analytics tracking to this Next.js app."
- "Instrument signup and purchase flows with Vercel custom events."
- "Review this app's Vercel analytics for PII leakage."
- "Connect frontend CTA events with backend successful mutation events."
- "Add typed Vercel Web Analytics events to the admin portal."
References
- Read
references/event-contract.mdfor the shared typed event model. - Read
references/privacy-and-security.mdfor payload and abuse-path rules. - Read
references/verification-checklist.mdfor tests and local validation. - Official docs to check during implementation:
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

