Skip to content

Set Up Metrics

⏱ 20 minutes intermediate

An experiment without metrics is just a coin flip. Metrics define what success looks like — whether that is more clicks, higher revenue, or fewer support tickets. Choosing the right metrics before you start ensures you measure what matters and avoid p-hacking after the fact.

Metric typeWhat it measuresExample
ConversionWhether an event occurred (binary)“Clicked sign-up button”
NumericA count or sum per visitor”Number of pages viewed”
RevenueMonetary value per visitor”Total purchase value”

Each experiment should have one primary metric that drives the decision, plus optional secondary metrics for additional insight.

PrimarySecondary
PurposeThe single metric that decides the winnerGuards against unexpected side effects
CountExactly one per experimentTwo to four recommended
Decision weightDetermines ship/no-shipAdvisory — flags tradeoffs

Example setup for a checkout experiment:

  • Primary: Revenue per visitor (increase)
  • Secondary: Cart abandonment rate (decrease), page load time (decrease), support tickets (decrease)

Events are the raw signals that metrics are built on. You can create events through the UI or by sending them from code.

Create a click event (Web Experimentation)

Section titled “Create a click event (Web Experimentation)”
  1. Navigate to ImplementationEvents
  2. Click Create New Event
  3. Select Click event
  4. Enter a descriptive name (e.g., “CTA button click”)
  5. Use the visual selector to click the target element on your page, or enter a CSS selector
  6. Click Save

Create a custom event (Feature Experimentation)

Section titled “Create a custom event (Feature Experimentation)”

Custom events are sent from your application code when a meaningful action occurs.

Track a custom event
javascript
// After the user completes a purchase
const user = optimizely.createUserContext('user-123', {
  country: 'US',
});

// Simple conversion event
user.trackEvent('purchase_complete');

// Revenue event with tags
user.trackEvent('purchase_complete', {
  revenue: 4999,  // Value in cents
  quantity: 2,
});
python
# After the user completes a purchase
user = client.create_user_context('user-123', {
    'country': 'US',
})

# Simple conversion event
user.track_event('purchase_complete')

# Revenue event with tags
user.track_event('purchase_complete', {
    'revenue': 4999,  # Value in cents
    'quantity': 2,
})
csharp
// After the user completes a purchase
var user = optimizely.CreateUserContext("user-123", new UserAttributes
{
    { "country", "US" },
});

// Simple conversion event
user.TrackEvent("purchase_complete");

// Revenue event with tags
var tags = new EventTags
{
    { "revenue", 4999 },   // Value in cents
    { "quantity", 2 },
};
user.TrackEvent("purchase_complete", tags);

Important: The revenue tag must be an integer in cents (or the smallest currency unit). A $49.99 purchase is 4999.

  1. Open your experiment and navigate to the Metrics tab
  2. Click Add Metric
  3. Select or search for the event you created
  4. Configure the metric:
    • Metric name — A clear label (e.g., “Purchase conversion rate”)
    • Aggregation — Unique conversions (binary), total conversions (count), or revenue (sum)
    • Winning direction — “Increase” for positive metrics, “Decrease” for metrics like bounce rate
  5. Mark one metric as the Primary metric — this is the metric used to determine the winner
  6. Add additional secondary metrics as needed

Configure pageview events (Web Experimentation)

Section titled “Configure pageview events (Web Experimentation)”

Pageview events track when a visitor reaches a specific page. These are useful for funnel-based metrics.

  1. Navigate to ImplementationEvents
  2. Click Create New Event
  3. Select Pageview event
  4. Enter the URL match — use substring, exact, or regex matching
  5. Name the event (e.g., “Reached checkout confirmation”)
  6. Attach it to your experiment as a metric
  1. In the experiment settings, navigate to Statistical Settings
  2. Set the significance level — 90% for low-risk tests, 95% for most decisions (default), 99% for high-impact changes
  3. Set the minimum detectable effect (MDE) — the smallest improvement worth detecting. A 2% MDE needs more traffic than a 10% MDE.
  4. Enable multiple comparisons correction when testing three or more variations to reduce false positive risk

Lower MDE values require more traffic. Balance sensitivity with how long you can run the experiment.

  • Decide metrics before starting — Adding metrics mid-experiment introduces bias
  • Limit secondary metrics — 3 to 5 additional metrics is usually sufficient
  • Use revenue metrics for e-commerce — They capture magnitude, not just frequency
  • Name events descriptively — “purchase_complete” is better than “event_7”
  • Track events close to the decision point — If you are testing the checkout button, track the purchase, not just the button click
IssueCauseFix
Metric shows zero conversionsEvent not firing or name mismatchCheck browser dev tools (Web) or SDK logs (Feature) for the event
Revenue shows as whole numbersRevenue not sent in centsMultiply by 100 before sending
Metric not attached to experimentEvent created but not added as metricOpen experiment and add the event in the Metrics tab
Results seem delayedEvents batch before sendingWait 5-10 minutes; SDK batches events for efficiency