Experiment Results
1 个变体An A/B test results card with confidence intervals, a probability-to-beat-control meter, and a ship-the-winner flow.
A/B test
A/B test results with confidence intervals on a zero-lift axis, a probability-to-beat-control meter, and metric tabs that roll every number. Shipping the winner confirms in a dialog, then the status rolls to Shipped and the losing variants fade.
One-page checkout
SignificantDay 14 of 21 · 48,210 users · Primary: Conversion
- Control3.12%Baseline
- One-page3.41%+9.3%One-page: +9.3%, interval +3.1% to +15.6%
- Saved cards first3.05%−2.2%Saved cards first: −2.2%, interval −8.4% to +4.1%
"use client";
import { ExperimentResults } from "@/components/premium/experiment-results";
export function ExperimentResultsAbTestPreview() {
return (
<div className="w-full px-4 py-10">
<ExperimentResults />
</div>
);
}
安装
API 参考
除标注为必填的属性外,其余均为可选。数据、文案和颜色默认使用示例内容。
ExperimentResults9 个属性
experimentExperiment to show. Defaults to the sample checkout test.
ExperimentlabelsText overrides merged over the default labels.
Partial<{ running: string; significant: string; shipped: string; users: string; primary: string; metricsAriaLabel: string; beatControl: string; target: string; control: string; baseline: string; winner: string; ... 15 more ...; confidence: string; }>formattersFormatter overrides for values, lifts, and user counts.
Partial<ExperimentFormatters>targetChance to beat control that counts as a win, 0 to 100. Defaults to 95.
number默认值
95defaultMetricIdMetric tab selected on mount. Defaults to the primary metric.
stringdefaultTrendOpenOpens the cumulative lift chart on mount.
boolean默认值
falseonShipRuns the ship after it is confirmed; a rejected promise shows an error.
((winnerId: string) => void | Promise<void>)onMetricChangeCalled with the metric id when the tab changes.
((metricId: string) => void)classNameClasses merged onto the root element.
string
BeatControlMeter5 个属性
variant必填Leading variant for the selected metric.
ExperimentVariantprobability必填Its chance to beat control, 0 to 100.
numbertarget必填Decision threshold drawn as a target line, 0 to 100.
numberactive必填Fills the track once the card is in view.
booleanlabels必填Text for the caption and target.
Pick<{ running: string; significant: string; shipped: string; users: string; primary: string; metricsAriaLabel: string; beatControl: string; target: string; control: string; baseline: string; winner: string; ... 15 more ...; confidence: string; }, "target" | "beatControl">
ExperimentStatusPill3 个属性
status必填Status that sets the label and tint.
"running" | "significant" | "shipped"labels必填Status names.
Pick<{ running: string; significant: string; shipped: string; users: string; primary: string; metricsAriaLabel: string; beatControl: string; target: string; control: string; baseline: string; winner: string; ... 15 more ...; confidence: string; }, ExperimentStatus>classNameClasses merged onto the root element.
string
IntervalBar9 个属性
low必填Lower bound of the lift interval in percent.
numberhigh必填Upper bound of the lift interval in percent.
numberestimate必填Point estimate of the lift in percent.
numberrange必填Axis half-range in percent; the axis runs from -range to +range.
numberactive必填Collapsed at zero until true, then the interval grows out from zero.
booleandelaySeconds before the first grow-in.
number默认值
0baselineDraws only the zero line and a muted dot, for the control row.
boolean默认值
falselabelAccessible summary, such as "+9.3%, 95% interval +3.1% to +15.6%".
stringclassNameClasses merged onto the root element.
string
LiftTrend6 个属性
points必填Daily cumulative lift, oldest first.
readonly LiftPoint[]viewKey必填Key that replays the draw when the metric changes.
stringopen必填Whether the chart is shown.
booleanonOpenChange必填Called when the disclosure is toggled.
(open: boolean) => voidlabels必填Text for the toggle and caption.
Pick<{ running: string; significant: string; shipped: string; users: string; primary: string; metricsAriaLabel: string; beatControl: string; target: string; control: string; baseline: string; winner: string; ... 15 more ...; confidence: string; }, "trend" | "trendCaption">formatLift必填Formats the latest lift beside the toggle.
(lift: number) => string
ShipDialog5 个属性
winner必填Variant that will get all traffic.
ExperimentVariantvariants必填Every variant, for the traffic split.
readonly ExperimentVariant[]onConfirm必填Called when the ship is confirmed.
() => voidonCancel必填Called when the dialog is dismissed.
() => voidlabels必填Dialog text.
Pick<{ running: string; significant: string; shipped: string; users: string; primary: string; metricsAriaLabel: string; beatControl: string; target: string; control: string; baseline: string; winner: string; ... 15 more ...; confidence: string; }, "shipTitle" | ... 3 more ... | "confirm">
VariantRow10 个属性
variant必填Variant shown in this row.
ExperimentVariantresult必填Result for the selected metric.
VariantResultmetric必填Selected metric, passed to the value formatter.
ExperimentMetricrange必填Axis half-range in percent shared by every row.
numberactive必填Grows the interval in once the card is in view.
booleandelay必填Seconds before this row's interval grows in.
numberdimmed必填Fades the row back after another variant ships.
booleanwinner必填Shows the winner tag after shipping.
booleanlabels必填Text for the baseline and winner tags.
Pick<{ running: string; significant: string; shipped: string; users: string; primary: string; metricsAriaLabel: string; beatControl: string; target: string; control: string; baseline: string; winner: string; ... 15 more ...; confidence: string; }, "users" | ... 1 more ... | "winner">format必填Value, lift, and user formatters.
ExperimentFormatters
类型7 个类型
这些属性使用的对象类型及其字段。
Experiment7 个字段
name必填Experiment name shown in the header.
stringstatus必填Status when the card mounts. Shipping moves it to "shipped".
ExperimentStatusruntime必填Runtime caption, such as "Day 14 of 21".
stringprimaryMetricId必填Id of the metric that decides the winner.
stringvariants必填Variants, control first.
ExperimentVariant[]metrics必填Metrics, one tab each.
ExperimentMetric[]guardrails必填Guardrail metrics summarized in the footer.
Guardrail[]
ExperimentFormatters3 个字段
value必填Formats a metric value, such as "3.41%" or "$5.12".
(value: number, metric: ExperimentMetric) => stringlift必填Formats a relative lift in percent, such as "+9.3%".
(lift: number) => stringusers必填Formats a user count, such as "48,210".
(users: number) => string
ExperimentVariant5 个字段
id必填Unique id, used as the key in each metric's results.
stringname必填Variant name shown in the row and the ship dialog.
stringtraffic必填Share of traffic in percent, such as 34.
numberisControlMarks the baseline every other variant is compared against.
booleandotClassName必填Dot class that identifies the variant, such as `bg-blue-500`.
string
ExperimentMetric6 个字段
id必填Unique id, used as the tab value.
stringlabel必填Tab and header label, such as "Conversion".
stringkind必填How values read: a percentage or a currency amount.
"percent" | "currency"decimals必填Fraction digits shown for values.
numberresults必填Results keyed by variant id.
Record<string, VariantResult>trend必填Daily cumulative lift of the leading variant, oldest first.
LiftPoint[]
Guardrail2 个字段
name必填Guardrail metric name, such as "Payment errors".
stringstatus必填Ok, watch (drifting), or breach (over its limit).
GuardrailStatus
VariantResult6 个字段
users必填Users counted for this metric.
numbervalue必填Metric value, such as 3.41 for 3.41% or 5.12 for $5.12.
numberlift必填Relative lift vs control in percent. Control uses 0.
numberlow必填Lower bound of the lift's confidence interval in percent.
numberhigh必填Upper bound of the lift's confidence interval in percent.
numberprobability必填Chance to beat control, 0 to 100. Ignored for the control.
number
LiftPoint3 个字段
lift必填Cumulative relative lift on that day in percent.
numberlow必填Lower bound of the confidence band in percent.
numberhigh必填Upper bound of the confidence band in percent.
number