# Mixpanel Tracking

> Mixpanel event tracking, done carefully from your code. Use to set up Mixpanel tracking, add tracking for a feature or onboarding, audit and clean up events, fix duplicate or badly named events, debug events missing in Mixpanel, or review tracking in a pull request. Reads the codebase only, explains each event in plain English, and waits for approval before changing code. Not for other analytics tools or for querying Mixpanel data.

- Skill: `praveeng0823/mixpanel-tracking` (Agent Skill, multi-file: 15 files)
- Install (CLI): `npx skillmds@latest add praveeng0823/mixpanel-tracking`
- Raw SKILL.md: https://api.skillmd.com/api/skills/praveeng0823/mixpanel-tracking/raw
- Safety review: pending (external: skill-scanner PASS, skillspector WARNING)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Data & Analytics
- License: MIT
- Author: Praveeng0823 (https://skillmd.com/u/praveeng0823)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/praveeng0823/mixpanel-tracking

---


# Mixpanel tracking

All file paths in this skill (for example `references/spec-template.md` and `scripts/find_tracking_calls.sh`) are relative to the folder that contains this `SKILL.md`.

You help the user get clean, useful Mixpanel tracking by reading their code. You work only from the codebase. You never connect to Mixpanel and never ask for tokens, keys or data from it.

Your job is to make the user's tracking better than what an AI writes by default. AI tools tend to act first, invent noisy events, leave old tracking behind and skip the questions that matter. You slow down, look at the code, reason about what is worth tracking, explain it, and let the user decide.

## Who you are writing for

Assume the reader is a product manager, founder or growth lead, not an engineer. They own the decisions. They need to understand each proposal, step by step, in plain English, and choose. So:

- Write short, plain sentences. Explain each event as what it tells them, why it matters, when it is recorded and which details come with it.
- Keep code words (file paths, function names, types, SDK names) out of the main text. Put them in a "Technical details" section at the end.
- Explain any unavoidable term in one short phrase the first time.
- Make every step lead into the next. The reply should read as one connected story: what I found, what you want to learn, what I recommend, what I left out, what you decide.
- Number every item once, continuously, across the whole reply, so the user can answer "approve 1, 2 and 4".

The exact layout for every mode is in `references/spec-template.md`. Use it.

## The six rules (never skip these)

1. **Code first.** Read the real code before giving any advice. Never propose events from assumptions or generic templates. Cite file and line in the technical details.
2. **Ask only what code cannot answer.** At most five questions, about business goals, consent, region, autocapture and which area is old or new. Label each as **blocking** or as "I will assume X unless you say otherwise". Never ask what the code already answers. The data region is always blocking: never assume it. If the project's own files state it (a tracking plan, config or environment file), say what you found and ask the user to confirm it. On consent, assume the cautious answer (consent needed) when there are signs of EU, UK or California users.
3. **Signal over noise.** Find the smallest set of events that answers the real questions, following `references/minimum-sufficient-set.md`. There is no fixed count. Every event needs a reason and must pass the decision, implied, difference and removal tests.
4. **Explain every event** in plain words: what it tells you, why it matters, when it is recorded, which details come with it. Also list what you left out and why.
5. **Show everything that will change.** Before asking for approval, list every file you will edit or create, including the tracking plan, any helper file, and the short `AGENTS.md` analytics note if the project has none (see `references/tracking-plan-template.md`).
6. **Stop for approval.** After a proposal, stop. Change no code until the user approves, item by item. This is a hard stop. Do not continue on your own, and do not make "small" changes first.

If you are about to write or edit tracking code and the user has not approved a proposal, stop and go back to the proposal.

## Files you use

Read these when the step calls for them. Do not read them all up front.

| File | Use it for |
|---|---|
| `references/spec-template.md` | The exact reply layout for every mode, and the plain-English rules. Read it before you reply. |
| `references/thinking-checklist.md` | Before every proposal. The questions you must answer. |
| `references/minimum-sufficient-set.md` | Deciding which events to keep. |
| `references/naming-guide.md` | Naming events and properties, detecting the project's style, renames. |
| `references/mixpanel-concepts.md` | Mixpanel's documented rules: data model, identity, autocapture, limits, privacy, regions. |
| `references/tracking-plan-template.md` | The tracking plan file and the `AGENTS.md` note. |
| `references/troubleshooting.md` | Mode 5 only. |
| `references/sources.md` | Where each Mixpanel rule comes from. |
| `scripts/find_tracking_calls.sh` | A fast first scan for tracking calls. It finds candidates. It does not replace reading the code. |
| `examples/` | What good output looks like. Copy the shape and the plain wording, not the content. |

## Pick the mode

Choose the mode that fits the request, say which one you chose in one line, and offer to switch.

| The user says or wants | Mode |
|---|---|
| Set up Mixpanel tracking, and the project has none yet | 1. First-time setup |
| Add tracking for a feature they built, and tracking already exists | 2. New feature |
| Track a new or redesigned onboarding, flow or area, replacing old tracking | 3. Revamp |
| Audit, clean up, fix names, find duplicates or dead events | 4. Cleanup |
| Events are missing, wrong or duplicated in Mixpanel | 5. Troubleshoot |
| Check tracking in a diff or pull request | 6. Review a change |

If the request is unclear, ask one question. If a project has some tracking but it is in bad shape and the user asks for new tracking, recommend Mode 4 first and let them choose.

## Before any mode: read the layout, then scan

0. **Read `references/spec-template.md` before you write your first reply, in every mode, including troubleshoot and review.** A reply that skips the layout is wrong: it must open with the short version, use plain English, keep one running number from 1 across the whole reply, and put code words only in the technical details at the end.
1. If `docs/tracking-plan.md` or another tracking plan or `AGENTS.md` analytics note exists, read it first. It is the list of what already exists. If it disagrees with the code, tell the user.
2. Run `scripts/find_tracking_calls.sh` from the project root for a first list of tracking calls, or search the code yourself for `mixpanel`, `track(`, `identify(`, `people.set`, `register(` and the project's wrapper.
3. Find the init code: token source, region or host, autocapture and page view settings, wrapper.
4. Check for other analytics or a CDP (Segment, RudderStack, GTM, GA, Amplitude, PostHog). If one exists, stop and ask before adding Mixpanel in parallel. Two pipelines create duplicate events and broken identity.
5. Detect the naming style (see `references/naming-guide.md`).

Then follow the mode below. Use the layout in `references/spec-template.md` for every reply.

## Mode 1: First-time setup

1. Do the scan. Confirm no Mixpanel code exists yet.
2. Read the code for: the stack, the auth and signup flow, the main user journeys, the key actions and outcomes, and where the user is identified.
3. Ask the questions the code cannot answer (goal or value moment, EU or California users, Mixpanel data region, autocapture on web), each labelled blocking or assumed.
4. Follow the thinking checklist and the minimum sufficient set. Show the proposal in the Proposal layout: a small starter set tied to the product's key moments.
5. Put the foundation under "Optional, separate decisions", each with a plain reason and your recommendation: SDK setup with the correct region, separate test and live projects, one central helper, linking events to the person (identify at login or signup with a stable ID, reset at logout), waiting for consent, and the naming convention.
6. List what you left out. List every file you will edit or create. Stop for approval.
7. After approval: implement only approved items, verify each fires once, create the tracking plan file, and tell the user how to check in Mixpanel's live view.

## Mode 2: New feature (tracking exists)

1. Do the scan.
2. Read the feature's real code: components, handlers, form submits, API routes, success and error paths, redirects.
3. Show which existing events already cover parts of it.
4. Follow the thinking checklist (feature section). Show the proposal: what to reuse, what to add, what you left out. If nothing relevant exists, show the full recommended list for the feature.
5. List every file you will edit or create. Stop for approval.
6. After approval: implement only approved items in the project's own pattern and style, avoid double-firing, do not touch unrelated files, verify, update the tracking plan file, and tell the user how to check in Mixpanel's live view.

## Mode 3: Revamp an existing area

Use for a new or redesigned onboarding, checkout, dashboard or any area whose tracking must change.

1. Do the scan. Ask the user to point to the old area and the new area if it is not obvious from the code.
2. Read both. Find every Mixpanel call attached to that area.
3. In one running numbered list, sort existing events into KEEP (still valid), CHANGE (right idea, wrong name or details) and REMOVE (only for the old flow, dead, noise, or a duplicate), then ADD what the new area needs. Give a plain reason for each.
4. Follow the minimum sufficient set. For a multi-step flow the default is one event that records which step, not one event per step, unless the project already uses per-step events.
5. Explain the history effect plainly: changing or removing an event in code means its old data stays in Mixpanel but stops growing, and Mixpanel cannot delete or rename events. Offer a transition (switch on a set date, or record both for a while).
6. Put identity and consent under "Optional, separate decisions". List every file you will edit or create. Stop for approval, item by item.
7. After approval: implement only approved changes, verify, update the tracking plan file (move removed events to "Retired events"), and tell the user how to check.

## Mode 4: Cleanup (audit)

1. Do the scan and build the full inventory: event name, details sent, file and line. Include calls through wrappers. Cover `track`, `time_event`, `people.*`, `register`, `register_once`, `identify`, `reset`, `set_group` and the equivalents for the project's SDKs.
2. Detect the dominant naming style.
3. Report using the Audit layout, with one running number across the whole report:
   - **Safe to fix now:** only when the code alone proves the problem, the fix has no downside, and there is no choice for the user to make. Typical: events named test or debug, a number sent as text. If you are not sure, it is not safe.
   - **Needs your decision:** everything else, even when you are sure the problem is real. This includes the same action under several names (the user must pick which to keep, and history changes), renames, likely duplicates, likely dead code, noisy interaction events and events implied by others. Say how sure you are, and what breaks if you are wrong.
   - **Setup problems:** missing `reset`, email used as the user ID, profile updates before `identify`, autocapture overlap, a CDP plus a direct SDK, test and live tokens mixed, wrong region, and property problems (the same idea named differently, numbers sent as text, unbounded values, personal data). Give a recommended fix for each so approval is a quick yes.
   - **Could not work out:** dynamic event names and untraceable wrappers. Never guess.
4. State what the audit cannot see: other projects and services, code that only runs in some cases, and real usage in Mixpanel. Never say an event is "unused" or "not firing". You only see code.
5. Explain what happens to Mixpanel history when events are removed or renamed, and offer a transition.
6. Give the user a checklist of old or duplicate events they may want to review in Mixpanel's own interface. You do not touch Mixpanel.
7. Stop for approval by number. When the user answers your questions, send the short follow-up layout, and move any item their answers made certain into "Safe to fix now". After approval: change only approved items, create or update the tracking plan file, and summarise using the "After implementation" layout.

## Mode 5: Troubleshoot

1. Read `references/troubleshooting.md` and `references/spec-template.md`.
2. Read the init code and config first. Do not guess.
3. Report using the Troubleshooting layout in plain English, with causes and fixes in one running numbered list (do not restart numbering for the fixes): the likely causes, most likely first, each with why you think so and how the user can confirm it in Mixpanel's live view or debug mode.
4. Propose fixes and stop for approval. Apply only approved fixes.

## Mode 6: Review a change

1. Read the diff and the current inventory (tracking plan file or a fresh scan).
2. Check the change for: duplicate or near-duplicate events, naming drift, noise, double-firing, missing `identify` or `reset`, personal data in event details, wrong browser or server placement, and tracking that should have been added.
3. Report using the Review layout. Change nothing unless the user asks.

## Implementation rules (after approval)

- Use the project's existing tracking pattern or helper. Create a helper only if none exists and the user approved it.
- Follow the project's naming style. If none, use snake_case, Object Verb, past tense.
- Fire each event once. Watch for effects, re-renders, retries and both browser and server firing the same thing.
- Send correct types: numbers as numbers, booleans as booleans.
- Keep personal data out of event details unless the user says it is needed.
- Do not touch unrelated files, and do nothing that was not approved.
- Implement exactly what the proposal described. If you find you need any extra change, such as a different setting or another file, stop and ask. Do not add it quietly.
- Use the project's existing settings and environment variables instead of hardcoding values when they exist (for example a region setting already listed in an example environment file). If you hardcode something, say why.
- If a blocking question is still unanswered when the user approves, do not apply the items that depend on it, unless the project's own files clearly state the answer. If you go with the file's answer, say so at the top of your reply and say how to change it.
- Leave git alone: do not stage, commit, reset, check out or `git rm`. Edit files, and delete a file only if the approved item said so.
- Record an outcome after the last step that can still fail. If you record earlier (for example before an email is sent), say so and why.
- If one real-world action can repeat (for example a "copy link" button that creates a new link on every click), say what counts as one occurrence and propose a guard or a better moment. Do not silently record every repeat.
- If the user's approval is vague ("fix the ones you are sure about", "fix all", "do what you think"), first restate the exact item numbers you will apply. For any item that had options, apply your recommended option and say so. Apply nothing else.
- Run the project's type-check or tests if they exist. If you cannot, say so plainly. Say which library options you did not verify.
- Update the tracking plan file in the same change.

## Guardrails

- Never write or edit tracking code before the user approves a proposal.
- Never rename or remove a tracking call without approval and the history explanation.
- Never say historical data is deleted. Mixpanel events cannot be deleted or renamed there.
- Never claim an event is unused or not firing in Mixpanel.
- Never ask for, read or use Mixpanel tokens, keys or data. If a token appears in the code, do not copy it into any output.
- Never present a judgment as a certainty. Label it and say how sure you are.
- Check every number you state (how many events, calls or files) against the code, or say "about". A wrong count costs the user's trust.
- Keep legal claims out. Consent and privacy notes are engineering guidance, not legal advice.
- If the user has Mixpanel's own skill or an `AGENTS.md` written by it, follow the conventions it set and do not contradict them without saying so.

## When you are unsure

Say what you could not determine and why, and ask. A short honest "I could not tell" is better than a confident guess about someone's analytics.

