Set Up Metrics
Why set up metrics
Section titled “Why set up metrics”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 types
Section titled “Metric types”| Metric type | What it measures | Example |
|---|---|---|
| Conversion | Whether an event occurred (binary) | “Clicked sign-up button” |
| Numeric | A count or sum per visitor | ”Number of pages viewed” |
| Revenue | Monetary value per visitor | ”Total purchase value” |
Each experiment should have one primary metric that drives the decision, plus optional secondary metrics for additional insight.
| Primary | Secondary | |
|---|---|---|
| Purpose | The single metric that decides the winner | Guards against unexpected side effects |
| Count | Exactly one per experiment | Two to four recommended |
| Decision weight | Determines ship/no-ship | Advisory — 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)
Create an event
Section titled “Create an event”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)”- Navigate to Implementation → Events
- Click Create New Event
- Select Click event
- Enter a descriptive name (e.g., “CTA button click”)
- Use the visual selector to click the target element on your page, or enter a CSS selector
- 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.
// 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,
}); # 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,
}) // 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.
Add metrics to an experiment
Section titled “Add metrics to an experiment”- Open your experiment and navigate to the Metrics tab
- Click Add Metric
- Select or search for the event you created
- 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
- Mark one metric as the Primary metric — this is the metric used to determine the winner
- 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.
- Navigate to Implementation → Events
- Click Create New Event
- Select Pageview event
- Enter the URL match — use substring, exact, or regex matching
- Name the event (e.g., “Reached checkout confirmation”)
- Attach it to your experiment as a metric
Set statistical significance
Section titled “Set statistical significance”- In the experiment settings, navigate to Statistical Settings
- Set the significance level — 90% for low-risk tests, 95% for most decisions (default), 99% for high-impact changes
- Set the minimum detectable effect (MDE) — the smallest improvement worth detecting. A 2% MDE needs more traffic than a 10% MDE.
- 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.
Best practices
Section titled “Best practices”- 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
Troubleshooting
Section titled “Troubleshooting”| Issue | Cause | Fix |
|---|---|---|
| Metric shows zero conversions | Event not firing or name mismatch | Check browser dev tools (Web) or SDK logs (Feature) for the event |
| Revenue shows as whole numbers | Revenue not sent in cents | Multiply by 100 before sending |
| Metric not attached to experiment | Event created but not added as metric | Open experiment and add the event in the Metrics tab |
| Results seem delayed | Events batch before sending | Wait 5-10 minutes; SDK batches events for efficiency |