Skip to content

Custom metrics

A custom metric is a saved lens over the events you already track. It does not add new tracking. It tells Versuch how to roll a tracked event up into a number: which event to read, how to aggregate it, which direction is good, and how to format it.

Because metrics are computed at analysis time, defining one is retroactive: it applies to events already in the store, not just events sent after you create it.

Metric definition
{
"name": "Checkout revenue",
"key": "checkout_revenue",
"description": "Revenue per exposed visitor from checkout events",
"event": "checkout",
"aggregation": "sum",
"direction": "higher",
"format": "usd"
}
FieldWhat it does
nameHuman label shown in the dashboard and results. Required.
keyStable id used by the API. Auto-generated from name if omitted.
descriptionOptional note describing what the metric measures.
eventThe tracked event name this metric aggregates (for example checkout, signup). Required.
aggregationsum, mean, count, or conversion.
directionhigher or lower: which way is a win.
formatusd, percent, seconds, or number: how the value renders.
  • conversion: the share of exposed visitors who fired the event at least once. Use for signup rate, purchase rate, activation.
  • count: how many times the event fired per visitor. Use for events per session, actions taken.
  • sum: the total of the event’s value across a visitor. Use for revenue, total items.
  • mean: the average value per event. Use for average order value, average time.

sum and mean read the event’s value field, so make sure you send a value when you track those events. Values are in minor units (cents), and usd formatting divides accordingly.

direction tells the stats engine which way counts as an improvement. For revenue and signups that is higher. For refunds, latency, or churn that is lower. Results read the significance against control in the correct direction, so a metric where lower is better does not get flagged as a loss for going down.

POST https://versuch.ai/api/v1/metrics with a secret key.

Define a custom metric
curl -X POST https://versuch.ai/api/v1/metrics \
-H "Authorization: Bearer vsk_live_…" \
-H "Content-Type: application/json" \
-d '{
"name": "Checkout revenue",
"description": "Revenue per exposed visitor from checkout events",
"event": "checkout",
"aggregation": "sum",
"direction": "higher",
"format": "usd"
}'

List and delete:

List and delete
# List all metric definitions
curl https://versuch.ai/api/v1/metrics \
-H "Authorization: Bearer vsk_live_…"
# Delete a metric (also detaches it from any experiments)
curl -X DELETE https://versuch.ai/api/v1/metrics/checkout_revenue \
-H "Authorization: Bearer vsk_live_…"

Deleting a metric detaches it from every experiment it was attached to. The underlying events are untouched.

A metric only affects results once it is attached to an experiment. Attach a primary metric and optional guardrails:

Attach metrics to an experiment
curl -X PUT https://versuch.ai/api/v1/experiments/exp_123/metrics \
-H "Authorization: Bearer vsk_live_…" \
-H "Content-Type: application/json" \
-d '{
"primary": "checkout_revenue",
"guardrails": ["signup_rate", "refund_rate"]
}'
  • primary: the metric the experiment is decided on.
  • guardrails: metrics you want to watch for regressions while the primary moves. A guardrail with direction: "lower" (like refund_rate) flags if it goes up.

Once attached, results show direction-aware significance per metric: the primary drives the call, and each guardrail is reported alongside so you can see the trade-offs.