跳到正文
Skillpedia
分析与电子表格41k · #6875

configuring-experiment-analytics

它能做什么

本技能设置哪些用户被纳入实验分析,以及哪些数字能说明实验是否有效。适合负责 A/B 测试衡量环节的人。

适用场景

  • ✓当你需要决定实验中应统计哪些用户时。
  • ✓当你想为测试选择主要指标和次要指标的时候。
  • ✓当你需要处理在实验中看到多个变体的用户时。

技能链接

https://github.com/PostHog/posthog/blob/master/products/experiments/skills/configuring-experiment-analytics/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/PostHog/posthog/blob/master/products/experiments/skills/configuring-experiment-analytics/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请设置我的结账实验,只统计到达支付页面的用户,并以转化率作为主要指标。”

每周 5 个新技能,1 分钟读完。

工作原理

它会设置决定哪些用户进入分析的曝光规则,然后添加用于衡量效果的指标。它还会说明如何处理同时看到多个变体的用户。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Configuring experiment analytics

This skill answers: Who is included in the analysis? and How to measure impact?

Exposure criteria

Exposure criteria determine which users are counted in the experiment analysis.

Exposure event

Two options:

  1. Default exposure event — users are included when the experiment's default exposure event fires for the experiment's flag: $feature_flag_called, or $experiment_exposure for newer experiments. Which one applies is resolved server-side — read resolved_exposure_event from experiment-get rather than assuming either name (both events carry the same properties). When it is $feature_flag_called, also read $experiment_exposure (event IN ('$feature_flag_called', '$experiment_exposure')), and count persons, not rows. This is the standard approach — it means a user is included only when they actually encounter the feature flag in your code.
  2. Custom exposure event — users are included when a specific custom event fires. Use this when you want tighter control over who enters the analysis (e.g., only users who actually visit the page where the experiment runs).

Filters on the exposure event remove individual events, not users. A user still counts as long as one of their exposure events passes the filters. To keep users out of the experiment, exclude them in the flag's release conditions before launch (see configuring-experiment-rollout).

Multiple variant handling

When a user is exposed to multiple variants (e.g., due to flag changes or race conditions):

  • Exclude from analysis — removes these users from the analysis entirely. Cleaner data, smaller sample.
  • Use first seen variant — assigns users to the first variant they were exposed to. Keeps all users in the analysis. Note that "first seen" can introduce other biases as behavior cannot be clearly attributed to a single variant and is not recommended unless necessary.

Bias risk on uneven splits. "Exclude from analysis" 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:

  • Not yet launched, or only exposed to a few users so far — switch to an even variant split and use the overall rollout percentage to limit test-variant exposure. This removes the bias and preserves statistical power. See configuring-experiment-rollout.
  • Live experiment with significant exposures — changing the split mid-run reassigns users across variants, which is bad for user experience and data quality. Switch this setting to "Use first seen variant" instead — it keeps already-assigned users in their original variant (no reassignment) and removes the asymmetric exclusion.

Filter test accounts

exposure_criteria.filterTestAccounts (default: true) — excludes internal/test users from the analysis.

Resolving experiments

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.

Metrics

A metric reaches an experiment one of two ways, both via experiment-update:

  • Inline metric — defined directly on the experiment. Sent in the metrics array, which replaces the entire inline list, so always get the current experiment first via experiment-get to preserve existing metrics.
  • Shared (saved) metric — a reusable metric object that can be attached to many experiments. Attached by ID via 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.

Step 1: Check for an existing shared metric (REQUIRED — match by definition, not name)

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.

常见问题

什么是曝光事件?

它是表明用户已看到功能开关的事件,因此该用户会被纳入分析。

筛选曝光事件会移除用户吗?

不会。它移除的是单个事件。只要用户的某个曝光事件通过了筛选,该用户仍会被计入。

支持哪些指标类型?

支持计数、求和、比率和留存指标。

详情

作者的原始描述

Configures the analytics side of a PostHog experiment — exposure criteria (server-resolved default exposure event 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 from analysis" vs "Use 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 met

repo: PostHog/posthog

热度

GitHub 星标
41k
排名
#6875
许可证
—
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能