## Growth Hack #4 · Install a full funnel in your app in ten minutes

**What it's for:** Claude Code or Codex reviews your app, adds the five pirate-funnel events (sign-up, activation, return, invite and payment) with PostHog, builds your funnel, your retention chart and a dashboard, finds where people drop off and proposes three experiments. If you're in the course, it uses the activation event you already defined and saves the plan to your campus.

**Requirements**
- A web app with its code in your repository (examples are for JavaScript or TypeScript; if you use another PostHog library, the agent adapts them).
- A PostHog account (the free plan includes one million events a month, no card required) and your project token.
- PostHog's MCP server, which is remote and authenticates in your browser:
  - Claude Code: `claude mcp add --transport http posthog https://mcp.posthog.com/mcp -s user` (or `claude plugin install posthog`). Then run `/mcp` and log in.
  - Codex: `codex mcp add posthog --url https://mcp.posthog.com/mcp`. Log in when prompted.
  - Or the wizard: `npx @posthog/wizard mcp add`.
- Optional, for students: the Rizoma Academy connector (`rizoma-academy`), installed from rizoma.boutique/campus/conectar.

```
Let's install a full funnel in my app with PostHog and find where people drop off. Work step by step: when you finish each step, show me the result and wait for my approval before moving on. Don't commit, don't deploy and don't launch anything: I decide.

STEP 0 · WHAT I ALREADY DEFINED IN RIZOMA
If you have the rizoma-academy connector:
- Call rizoma_estado.
- Read my notes with rizoma_notas (sesion: "La etapa donde casi todos fallan: ¡haz que tu app haga clic!") and my documents with rizoma_documentos: metricas.md, activacion-retencion.md, medicion.md and brief-mvp.md, if they exist.
- Tell me in one sentence what my activation event is, with its threshold and window (for example, "completes their first workout within their first 3 days"). Use that one; don't invent another.
If I don't have the connector or you can't find the definition, ask me: what is the action that delivers my app's promise? Creating an account is not activation.

STEP 1 · REVIEW MY CODE
Read the repository and tell me:
- The framework, and where sign-up, login, the activation action, invite or share, and payment live (if they exist).
- Whether PostHog is already installed and which events are already captured (if the PostHog MCP is connected, use read-data-schema to see the events already arriving).
Stop.

STEP 2 · PROPOSE THE EVENTS (AARRR)
Propose a table with: stage, event name, file and function where it fires, properties, and why.
- Sign-up: account_created.
- Activation: my activation event (for example, workout_completed with is_first: true).
- Return: the same value event in a later period (retention computes it; don't invent a "returned" event).
- Invite or share: invite_sent or content_shared.
- Payment: subscription_started (preferably server-side, in the payment webhook).
Naming rules: object_action, lowercase, snake_case, past tense. One event per moment; variants go in properties.
Privacy rules: identify with my database id (posthog.identify(user.id) after login and posthog.reset() on logout). Never put emails, names, phone numbers, addresses, tokens or free-form user text in events or properties. If my app has a privacy notice or cookie consent, respect it.
Stop. Wait for me to approve the table.

STEP 3 · ADD THE EVENTS
- Install posthog-js (and posthog-node only if server-side events need it).
- Initialize with the token from environment variables (for example, NEXT_PUBLIC_POSTHOG_KEY and NEXT_PUBLIC_POSTHOG_HOST in .env.local) and add the empty keys to .env.example. Never write the token in code or ask me for it in the chat.
- Show me the full diff, file by file, and wait for my approval before writing.
- Tell me how to test it: what to do in my app and where to see each event arrive (with the MCP, confirm it with read-data-schema or execute-sql).
Stop.

STEP 4 · FUNNEL, RETENTION AND DASHBOARD (with the PostHog MCP)
- Use insight-create to build a funnel: account_created → activation → invite_sent → subscription_started, with a 14-day conversion window (adjust it if my cycle is different).
- Use insight-create to build a weekly retention chart: start event = my activation (first time), return event = the same value event, last 8 weeks.
- Use dashboard-create to build the "AARRR Funnel" dashboard and add both charts.
- Give me the links. If there isn't enough data yet, say so and don't make up numbers.

STEP 5 · WHERE AM I LOSING PEOPLE?
- With query-funnel, query-retention or execute-sql, tell me each step's conversion, each group's size and the biggest drop-off, with dates.
- If fewer than 100 people are in the first step, say so: these are signals, not conclusions.
- Propose three experiments for the biggest drop-off, ranked by impact and effort (ICE from 1 to 10). For each: hypothesis ("if I change X, conversion from A to B goes up because…"), the exact change in my code, the primary metric, the guardrail metric that must not get worse, the minimum sample size or duration, and when we call it a win or a loss.
- If I want, leave the first one as a draft with its feature flag (experiment-create). Don't use experiment-launch or enable flags without my explicit permission.
Stop.

STEP 6 · SAVE IT IN RIZOMA
If you have the rizoma-academy connector:
- Write docs/rizoma/funnel-posthog.md with: the activation event, the events table, the links to the funnel, retention and dashboard, the observed numbers with dates (or "no data yet") and the three experiments.
- Save it with rizoma_guardar_documento (documento: "funnel-posthog.md", sesion: "Hack #4: instala tu funnel completo en diez minutos", revisar_el: 7 days from today, in YYYY-MM-DD format).
- Add a three-line summary with rizoma_guardar_nota in that same lesson (sesion: "Hack #4: instala tu funnel completo en diez minutos").
- If the data is useful for my module deliverable, propose the text for activacion-retencion.md, but don't overwrite it without my approval.
If I don't have the connector, give me the full Markdown and don't claim you saved it.

RULES THAT DON'T BREAK
1. Keys live in .env (and .env is in .gitignore). Never ask me for them in the chat or write them in code.
2. No personal data in analytics.
3. Show me every diff and wait for my approval change by change; no commits, deploys, experiment launches or flags enabled on your own.
4. Never make up numbers: if there's no data, say so.
```

**Safety note:** your PostHog keys and token go in `.env` (or `.env.local`), never in the chat or in code. PostHog and Rizoma Academy connect through a browser login, so you don't have to paste any key. Review and approve every change before the agent writes it, and don't let it launch experiments or enable flags without your permission. Some PostHog MCP tools use models internally and count toward PostHog AI spend; they only work if AI data processing is enabled in your organization.
