skills/configuring-experiment-analytics/SKILL.md
Configures the analytics side of a PostHog experiment — exposure criteria (default `$feature_flag_called` vs custom exposure events), primary and secondary metrics, the supported metric types (count, sum, ratio with `math` and `math_property`, retention with `retention_window_start` and `start_handling`), multivariate user handling ("Exclude" vs "First seen variant"), and how to read results once the experiment is live. Use when the user adds or edits a primary or secondary metric (e.g. "add a secondary metric tracking 'downloaded_file' per user"), sets up a ratio metric (e.g. "revenue from purchase_completed / pageviews"), sets up a retention metric (e.g. "$pageview → uploaded_file, 7-day window"), configures custom exposure (e.g. "only count users who hit /checkout"), changes multivariate handling, or asks "who is in the analysis?", "how do I measure impact?", "is this winning?", "what's the confidence level?", or "should I ship?".
npx skillsauth add posthog/ai-plugin configuring-experiment-analyticsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill answers: Who is included in the analysis? and How to measure impact?
Exposure criteria determine which users are counted in the experiment analysis.
Two options:
$feature_flag_called event fires for the experiment's flag. This is the standard approach — it means a user is included only when they actually encounter the feature flag in your code.When a user is exposed to multiple variants (e.g., due to flag changes or race conditions):
Bias risk on uneven splits. "Exclude multivariate users" combined with an uneven variant split can introduce bias — multi-variant users are dropped asymmetrically and the smaller variant loses a larger fraction of its assignments. If those users behave differently from the rest, the smaller variant's metrics will be skewed.
The right mitigation depends on experiment state:
configuring-experiment-rollout.exposure_criteria.filterTestAccounts (default: true) — excludes internal/test users from the analysis.
Metric changes require an experiment ID. If the user refers to an experiment by name
or description (e.g. "add metrics to the checkout test"), load the finding-experiments
skill to resolve it to a concrete ID before proceeding.
A metric reaches an experiment one of two ways, both via experiment-update:
metrics array, which
replaces the entire inline list, so always get the current experiment first via experiment-get
to preserve existing metrics.saved_metrics_ids (this list also replaces the experiment's existing
saved-metric links, so resend the full set — see Step 1).Prefer reusing a shared metric over duplicating it inline. Build a new inline metric only when no suitable shared metric already exists.
Before building any new inline metric, you MUST check whether the project already has a shared (saved) metric that measures the same thing, and reuse it. Duplicating a metric that already exists as a shared metric fragments measurement and is exactly what we want to avoid.
Reuse is decided by the metric definition — the event or action plus the metric type — not the
name. Saved metrics are named by each team's own conventions, which you cannot guess, so you must
compare on what each metric measures (its query), never on its title.
Workflow:
read-data-schema. You can only recognize a duplicate once you know the concrete event/action,
so this check runs after you've pinned down the event, not before.query. Call experiment-saved-metrics-list
with ?event=<the event you're measuring> to find metrics that reference it — matched directly (an
EventsNode) or via the step events of any action a metric references, so action-based metrics are
found by the event their action fires on. Then for each returned row, inspect its query (not the
name/description): a saved metric is a reuse match when its query measures the same event or
action with the same metric_type (and compatible math) as the metric you'd otherwise build, even
if its name is different.
search for this. search matches only the metric's own name / description / tags —
never the underlying event or action — so it cannot find a definition match. Use search only when the
user names a specific saved metric to attach (name resolution, not a definition match).experiment-get to read the experiment's current saved_metrics.experiment-update with saved_metrics_ids set to the full desired set — it replaces
existing links, so include the already-attached ones plus the new entry. Each entry has shape
{ "id": <saved-metric id>, "metadata": { "type": "primary" } } — set type to "primary" or
"secondary". metadata is optional and defaults to primary.saved_metrics you just read has a
top-level id (the link id) AND a saved_metric field (the metric id). saved_metrics_ids
wants the saved_metric value, not the link id — sending the link id attaches the wrong
metric or fails validation.experiment-saved-metrics-create, then attach it as above, so the
next experiment can reuse it.Before suggesting or building any new inline metric, you MUST call read-data-schema to discover
what events actually exist in the project. Do NOT skip this step. Do NOT suggest event names
based on what you think the project might track — only use events you have confirmed exist.
(Attaching an existing shared metric from Step 1 does not need this — it already encodes its events.)
This applies even when:
Workflow:
read-data-schema to get the project's eventsLegitimate exception — allow_unknown_events: true:
Pass this on experiment-create / experiment-update only when the user is intentionally instrumenting an event that hasn't been ingested yet (e.g. setting up the experiment before the code change ships). Confirm this with the user — never use it as a workaround for "the event lookup didn't return what I expected".
Example:
User: "Let's add some metrics for the checkout experiment"
WRONG: "I'd suggest using purchase_completed as the primary metric..."
(hallucinated event name — never seen the project's actual events)
RIGHT: *calls read-data-schema* → "Here are the events in your project
related to checkout: `checkout_step_completed`, `payment_processed`,
`order_confirmed`. Which of these represents a successful checkout?"
There are four metric types. Each has kind: "ExperimentMetric":
| metric_type | When to use | Required fields |
| ------------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| "mean" | Average of a numeric property per user (revenue, session duration, pageviews per user) | source |
| "funnel" | Conversion rate from exposure through one or more ordered actions | series (1 or more steps) |
| "ratio" | Rate of one event relative to another | numerator, denominator — set math: "sum" + math_property on a side to aggregate a property; filters never aggregate |
| "retention" | Do users come back after exposure? | start_event, completion_event, retention_window_start, retention_window_end, retention_window_unit, start_handling |
Funnel metrics and the implicit exposure step
Funnel metrics automatically prepend the experiment's exposure event as step_0.
So a funnel with 1 step in series is a valid 2-step funnel: exposure → action.
This is the correct choice for measuring "what percentage of exposed users did X?"
Examples:
$pageview filtered to /login)checkout_completed)Mean vs funnel for the same event
Both can reference the same event — the difference is whether you care about count/magnitude (mean) or yes/no conversion (funnel).
Retention: same vs different start/completion event
The retention window is measured from the start event, so the events you pick decide what's measured: The start occurrence never counts as its own completion (only a distinct later event does), so both shapes are valid:
From 0 counts a repeat from the same period onward (same-day repeats included); From ≥ 1 requires an occurrence later. Use start_handling: "first_seen". When a user says "retention of <event>" they usually mean repeat retention.See references/metric-configuration.md for the full rendered ExperimentMetric schema (all four metric types, with required fields per type) plus WRONG/RIGHT JSON pairs for the failure modes that come up most often (ratio with is_set filter instead of math: "sum" + math_property; retention without retention_window_start / start_handling). Read it before assembling a ratio or retention payload — the required fields are authoritative.
See references/interpreting-results.md for guidance on reading experiment results, statistical significance, and when to ship vs end.
data-ai
Signals scout for PostHog Tasks, the agent work items a project runs. Two lenses: delivery health (runs failing, clustered by repository and error class, and retry storms) every run, and on a slower rotation demand (recurring asks across human-authored tasks that point at a product gap). Skips the scout fleet's own run rows.
devops
Signals scout for the PostHog Conversations (support inbox) product. Watches the `$conversation_*` ticket-lifecycle events for support-delivery regressions — SLA breach-rate steps, first-response latency blowouts, backlog inflow-vs-resolution imbalance, and channel / assignment concentration — and files each dated regression as a report. Complements the per-ticket product-feedback signals the emission pipeline already fires; does not re-surface individual ticket content.
development
Populates and maintains a project's data catalog (semantic layer): canonical metrics, trust marks (certifications) on warehouse tables/views, and reviewed table relationships. Use when asked to set up / seed / bootstrap the data catalog or semantic layer, to catalog a project's metrics, to certify or deprecate data sources, to propose or review table joins, or to work through the proposal review queue. To *use* an existing catalog to answer a business-number question, see querying-posthog-data instead. Trigger terms: data catalog, semantic layer, canonical metric, certify table, deprecate source, relationship proposal, metric drift, review queue.
tools
Investigate logs in a PostHog project: verify a service or deployment is healthy, explain an error spike, triage an incident, or understand what a log stream is saying. Use when the user asks to "check the logs", asks whether a service, deploy, release, or change is working or broke anything, asks why errors are up or what changed, or wants the root cause of failures visible in logs. Routes the logs MCP tools (services overview, pattern mining, before/after pattern diffing, bucketed counts, facets, raw rows) so investigations start from summaries instead of raw rows or hand-written SQL over the logs table.