Skip to main content
menu_icon.png

Everything you need to switch from Optimizely Classic to X in one place: See the Optimizely X Web Transition Guide.

x
Optimizely Knowledge Base

Create a metric in Optimizely X

relevant products:
  • Optimizely X Web Experimentation
  • Optimizely X Web Personalization
  • Optimizely X Full Stack
  • Optimizely X Mobile

THIS ARTICLE WILL HELP YOU:
  • Create a new metric for an experiment or campaign
  • Edit an existing metric
  • Add code to track numeric metrics

In Optimizely, a metric is a quantitative measurement of a visitor action. They are what Optimizely uses to measure differences in visitor behavior that occur as a result of changes you make to your site. Metrics measure the success of your experiment by telling you whether an experiment is winning, losing, or inconclusive.

Metrics are created out of events, which directly track actions like clicks, pageviews, form submissions, purchases, and scroll depth. After you create an event and add them to an Optimizely X experiment or Personalization campaign, you'll decide how it's displayed as a metric. A simple example of a metric: an increase in unique conversions per visitor of clicks to an Add-to-Cart button; the event would simply track clicks to the button.

Every Optimizely experiment needs at least one metric. You can add or modify metrics at any time. View the metrics attached to your experiment on the Results page

Confused about metrics, events, and goals in Optimizely? Read our FAQ on these concepts.

Identifying the right metric is a huge factor in determining whether your experiment will have statistically significant results. Read our article on choosing primary vs. secondary metrics.

Build a metric

You define and add metrics to your experiments and campaigns with Optimizely’s natural-language metrics builder. It asks you to define a small set of parameters that tell Optimizely how to measure and report the results of your experiment or campaign. These parameters include the winning direction (increase or decrease), what you want to measure (the numerator), and the rate at which you want to measure it (the denominator).

You can only build metrics in Optimizely if your role is authorized to create and edit campaigns and experiments--that means administrator, editor or project owner. See this article for more details.

To build a metric, follow these steps:

  1. From the Experiments tab, click Create New... and select A/B Test or Personalization Campaign.
    create-exp.png

  2. Locate the Metrics section in the modal window. Choose an event from the list to be your primary metric.
    metrics-metrics.png

  3. Choose a name for your metric and set its winning direction, numerator, and denominator.

    Optimizely offers many pre-built metrics as well as a flexible numerator called total value. If you're not sure which metric to choose, read when to use each type of metric for deeper explanations and use cases.

If you are using total revenue or total value as your numerator, you will need to complete an additional step. The additional step for total revenue is not the same as the additional step for total value. Make sure you are reading the correct section.

If you've done everything correctly, you will start seeing your new metrics in the Results page after starting your experiment.

Total revenue additional step

If you are using total revenue as your numerator, you will have to add a bit of project Javascript to your experiment or campaign. Once you are ready to add code, use the reserved revenue tag.

<script>
   window["optimizely"] = window["optimizely"] || [];

   window["optimizely"].push({
     "type": "event",
     "eventName": "trackRevenue",  //this refers to the API name of the event
     "tags": {
       "revenue": valueInCents
     }
   });
</script>

The 'eventName' parameter is required. You can give it whatever name you want. For example, if you wanted to track the event and name it "purchases", you would simply type 'purchases' in place of 'trackRevenue' in the code block shown above.

The valueInCents variable represents the purchase amount, in cents (purchase amount*100). It is crucial that this value is passed to Optimizely in cents. Otherwise, your revenue totals will be incorrect. If you do not use U.S. currency, simply multiply the purchase amount in your currency by 100. For example, a purchase amount of €54.99 should be passed as 5499.

It is also crucial that this value is passed to Optimizely as an integer. Optimizely ignores the fractional part of the value in the calculations. If your site's revenue calculation code returns a floating point value such as 99.99999999999, you should truncate or round that value to 99.99 or 100. Choose a method that works best for your business needs.

See our Knowledge Base article for more detailed instructions on how to set up revenue tracking in Optimizely X.

Total value additional step

If you are using total value as your numerator, you will have to add project Javascript to your experiment or campaign. Once you are ready to add code, use the reserved value tag.

  • If you are using Optimizely X Web, add a small snippet of code to your site to call Optimizely's event tracking API. Place this code on the pages where the event occurs.

    <script>
       
       window["optimizely"] = window["optimizely"] || [];
       
      
       window["optimizely"].push({
         "type": "event",
         "eventName": "Videos Watched",  //this refers to the API name of the event
         "tags": {
           "value": 4                   
         }
       });
    </script>
    
  • If you are using Optimizely X Full-Stack, Mobile, or OTT, include the value tag when tracking an Optimizely event. Here's an example of what that might look like if you were using our JavaScript SDK.

    var eventKey =  "Videos Watched";     
    var userId =    "auser@adomain.com";
    
    var attributes = {
      DEVICE:       "iPhone"
    };
    
    var eventTags = {
      category:     "videos",
      value:        4                     
    };
    
    // Include revenue among other event tags when submitting Events
    optimizely.track(eventKey, userId, attributes, eventTags);
    

Edit a metric

You can edit your metrics by going to the experiment's Results and clicking any metric's Edit button.

edit-metrics.png

From here, you can change the metric's name, winning direction, and numerator. Click Save to save your updated metric definition.

edit-2-metrics.png

Be careful when editing a metric on a running experiment or campaign. Doing so can change the statistical significance on other metrics in the same experiment or campaign. This is because Optimizely’s Stats Engine simultaneously limits the proportion of false detection across all metrics in an experiment or campaign through false discovery rate control.

Optimizely balances confidence and speed of results by controlling false discoveries only for metrics currently included on the experiment or campaign Results page, adapting as the metrics themselves change.

This means experiments and campaigns with metrics selected and fixed in advance are less prone to cherry-picked results that may present a misleading picture. Excessive metric changes after an experiment or campaign has started may invalidate Optimizely’s guarantees regarding false detection.

Metrics options

Winning direction

In most experiments and campaigns, you will want to see your metrics increase. However, for some metrics — like bounce rate, Cancel button conversions, or cart abandonment — a lower value (i.e., negative lift) would be more desirable. 

Numerators

  • Unique conversions: the number of visitors with at least one conversion

  • Total conversions: the total number of conversions

  • Bounce Rate: the total number of times where the page being viewed is the first and only page the visitor sees before leaving your site

  • Exit Rate: the total number of times where the page being viewed is the last page the visitor sees before leaving your site

  • Total revenue: total revenue generated (you will have to set up revenue tracking before using the total revenue metric)

  • Total value: the total of any other numerical value

Denominators

Replaced the original paragraph with the below small sentence + table. Here is the original paragraph.

If you are measuring unique conversions or total conversions, the denominator is automatically set to per visitor. If you are measuring total bounces or total exits, the denominator is automatically set to per session. If you are measuring total revenue or total value in a personalization campaign, you can choose between per session and per conversion for your numerator. If you are measuring total revenue or total value in an experiment, you can choose between per visitor and per conversion.

Not every denominator works with every numerator.

Numerators Experiment type Possible denominators
Per visitor Per session Per conversion
Unique conversions and total conversions Personalization campaign    
Unique conversions and total conversions Experiment    
Bounce rates and exits rates Any   *  
Total revenue and total value Personalization campaign  
Total revenue and total value Experiment  

When you run an experiment with many variations and metrics, there’s a greater chance that some of them will give false positive results. The Optimizely X Stats Engine uses false discovery rate control to address this issue and reduce your chance of making an incorrect business decision or implementing a false positive among conclusive results. To learn how Stats Engine prioritizes primary and secondary metrics and monitoring goals, see Stats Engine approach to metrics and goals.

When to use each type of metric

Unique conversions

The unique conversions metric tracks the number of visitors who convert. Each visitor who converts is counted only once, no matter how many times they click.

Use unique conversions when you want to track:
Demo requests
Newsletter subscriptions
White paper downloads
Event registration

Total conversions

The total conversions metric tracks the total number of conversions. While the unique conversions metric only counts the first time a user interacts with your event, total conversions will count every interaction, regardless of whether or not a particular user has already converted on a previous visit.

Use total conversions when you want to track:
Total completed purchases
Total number of upsells
Number of videos viewed

Bounce rate and exit rate

A bounce is when a visitor views only a single page on your site (in other words, if the page is the first and last page a visitor sees). If the visitor continues to browse your site after landing on that first page (in other words, if the page is the first but not the last page a visitor sees), the visitor did not bounce from the page.

If you count all of the times a page was the first page viewed (including the times it was also the only page viewed), and you divide a page's total bounces by that number, you have the bounce rate.

  1. Need use cases
  2. Should I include the platform-specific "additional considerations" from Giannis' document?
  3. Should I include information about scope?

In general, an exit is when a visitor leaves your site. In metrics, a page is an exit when it is the last page a visitor sees. Optimizely calculates a page's exit rate by dividing the total number of times a page was an exit by the number of times the page was viewed.

  1. Need use cases
  2. Is it worth mentioning that all bounces are also exits?

Please read our separate article for detailed information about the bounce rate and exit rate metrics.

Total revenue

As its name suggests, total revenue tracks the total amount of revenue generated from user interactions with your event.

Use total revenue when you want to track:
Revenue per visitor
Average order value
Revenue per visit
Customer lifetime value

You will not be able to use the total revenue metric until you set up revenue tracking.

Total value

Using the total value metric enables you to quantify visitor actions beyond bounces, exits, conversions, and revenue. By selecting the total value numerator and editing a few lines of code, you can track the performance of your different variations on any visitor action that can be described numerically per conversionper session (Personalization), or per visitor (Full Stack, Mobile, and Web Experimentation).

Unlike revenue metrics, which use fixed-point numbers, metrics tracked with total value use floating-point numbers. For example, $72.81 would be submitted as 7281 as a revenue metric, but as 72.81 otherwise. Due to the dynamic precision of floating-point numbers, aggregations for non-monetary metrics are susceptible to rounding. When tracking monetary values, we recommend using the revenue metric to prevent these rounding errors.

Some common uses for the total value metric include:

What you wish to measure How you wish to calculate it

Measure reader engagement and content consumption

  • Ad units per visit

  • Ad viewability rate

  • Video play duration

  • Article scroll depth (25/50/75/100%)

  • Article page load time

  • Number of articles read

  • Number of videos watched

  • Article count per page

Measure high-value behavior beyond conversions and revenue

  • Number of items added to / removed from cart

  • Number of items per order 

  • Number of products viewed

  • Number of filters applied

  • Number of related products viewed

  • Category page scroll depth

  • Page load time

Determine appropriate products for customers based on demographic data

  • Credit score

  • Loan amount applied for

  • Interest rate selected

  • Steps of application funnel completed

Evaluate the effectiveness of website messaging and content on generating qualified leads

  • Average lead score

  • Pieces of content downloaded

  • Number of form fields completed

  • Demo video play duration

Determine booking efficacy and ability to upsell ancillary products

  • Number of items added to / removed from cart

  • Number of ancillary products purchased

  • Steps of booking funnel completed

Measure high-value behavior beyond clicks and conversions

  • Number of form fields completed

  • Video consumed

  • Unique pages per visit

  • Page scroll depth (25/50/75/100%)