PostHog Next.js Integrator
Integrates PostHog analytics into Next.js App Router applications — instrumentation setup, feature flags, event capture, user identification, and error tracking.
Skill summary
Copy-ready skill file
Paste this into your assistant rules file
Recommended targets: CLAUDE.md, .cursorrules, .windsurfrules, AGENTS.md, .clinerules
# PostHog Next.js Integrator ## Purpose Integrates PostHog analytics into Next.js App Router applications — instrumentation setup, feature flags, event capture, user identification, and error tracking. ## When to Use - **"add PostHog"** — Covers set up PostHog in Next.js. - **"PostHog integration"** — Covers configure feature flags. - **"analytics setup Next.js"** — Covers implement event tracking. - **"feature flags"** — Covers set up PostHog in Next.js. - **"PostHog Next.js"** — Covers configure feature flags. - **"instrument client"** — Covers implement event tracking. ### CLAUDE.md ```markdown # PostHog Next.js Integrator — AI Assistant Rules # Place this file in your project root as CLAUDE.md Integrates PostHog analytics into Next.js App Router applications — instrumentation setup, feature flags, event capture, user identification, and error tracking. ``` ## Operating Instructions 1. Start from the decision the data has to support, and write that decision down 2. Inventory the events that already exist before proposing any new ones 3. Define the event name, trigger and properties using the naming scheme already in use 4. Instrument, then verify the payload in the network tab rather than in the dashboard 5. Check for double-firing, missing events, and events firing on the wrong element 6. Document what each event is for and who reads it ## Example Prompts - "Integrate PostHog into our Next.js app with feature flags." - "Set up session recording and autocapture for our dashboard." ## Verification Checklist - [ ] Every new event has a name, a trigger and a property list - [ ] The event fires exactly once per intended action, verified in the network log - [ ] The name follows the existing taxonomy instead of starting a new spelling - [ ] The reporting queries were updated, so the new data is actually visible - [ ] The skill file is placed at `CLAUDE.md` in the project root - [ ] Tested with Claude to confirm the rules load and fire ## Integration Guide Combine with **Copywriter** to A/B test analytics-driven messaging, or with **CRO Optimizer** to optimize conversion funnels. ## Primary Use Cases - Set up PostHog in Next.js - Configure feature flags - Implement event tracking ## Difficulty **Intermediate** — assumes you already work in this area; read the rules before pasting them in.
With the PostHog Next.js Integrator rules in CLAUDE.md, ask:
“add PostHog”
The assistant then takes on set up posthog in next.js — the approach, the checks and the shape of the answer are fixed by the file before the first token is written.
What it is for
- Set up PostHog in Next.js
- Configure feature flags
- Implement event tracking
6 ways to trigger it
Skills in this category begin with the decision the data has to support, then work backwards to the events that decision needs. They treat naming conventions, property configuration and duplicate firing as first-class problems, because a dashboard that quietly double-counts is worse than no dashboard — it gets trusted.
Practices that matter in Analytics work
- Name events after what the user did, not after the class or component that handled it. User-facing names survive refactors.
- Keep one event taxonomy across the product. Two spellings of the same action split every report.
- Check for double-firing after any component remount. It is the most common silent data bug.
- Validate against raw records before trusting a chart. Spot-check one number against the source row.
- Treat a dashboard as a product with users: it needs an owner, a refresh schedule, and a reason to exist.
Start with CLAUDE.md.
| Assistant | Rules file |
|---|---|
| Claude | CLAUDE.md |
| Cursor | .cursorrules |
| Windsurf | .windsurfrules |
| OpenCode | AGENTS.md |
| Cline | .clinerules |
| GitHub Copilot | .github/copilot-instructions.md |
.cursorrules.windsurfrulesAGENTS.md- What does the PostHog Next.js Integrator skill do?
- Integrates PostHog analytics into Next.js App Router applications — instrumentation setup, feature flags, event capture, user identification, and error tracking. The copy-ready file above carries the full rule set, the trigger phrases and the checks the assistant runs before it hands work back.
- How do I trigger the PostHog Next.js Integrator skill?
- Ask for the work using one of its trigger phrases — for example “add PostHog”, “PostHog integration”, “analytics setup Next.js”. Once the rules file is in place, assistants that read it also pick the skill up without the phrase.
- Which files should hold the PostHog Next.js Integrator skill?
- CLAUDE.md, .cursorrules, .windsurfrules, AGENTS.md. CLAUDE.md is the one to start with; the rest exist so the same rules load in whichever assistant your team uses.
- Which assistants support the PostHog Next.js Integrator skill?
- Claude, Cursor, Windsurf, OpenCode, Cline, GitHub Copilot. Any assistant that reads a plain-text rules file can use it, so the format matters more than the product.
- Is the PostHog Next.js Integrator skill hard to set up?
- It is rated intermediate. It assumes you already work in this area, so read the rule set once before pasting it in.
- What can I actually use the PostHog Next.js Integrator skill for?
- The documented jobs are set up posthog in next.js, configure feature flags, implement event tracking. Beyond those it still works — the rule set is instructions, and assistants follow it past the examples you give it.
- Does the PostHog Next.js Integrator skill send my code anywhere?
- No. The file is static text in your repository. What happens to your code afterwards depends on the assistant you run it in and that provider's own data policy.
Related Skills
Analytics Tracker
Sets up and audits analytics tracking — event naming conventions, UTM strategy, GA4 implementation, PostHog integration, and data quality checks.
View skillPostHog Event Planner
Designs PostHog event taxonomies, properties, funnels, feature flags, experiments, and session recording rules.
View skillGA4 Audit Specialist
Audits Google Analytics 4 configuration, events, conversions, channel attribution, and reporting accuracy.
View skillUTM Strategy Planner
Creates UTM naming conventions, campaign taxonomy, channel rules, and governance for clean attribution.
View skill