Skip to main content
menu_icon.png

 

x
Optimizely Knowledge Base

Total value and other numeric metrics

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

THIS ARTICLE WILL HELP YOU:
  • Add the required code to your site to allow total value metrics to work
  • Understand the difference between value metrics and revenue metrics

Optimizely's total value metric is a very flexible numeric metric, allowing you to track actions that go beyond conversions and revenue. As long as it's quantifiable, you can use total value to track it.

Check out our Knowledge Base article on suggested use cases for Optimizely's total value metric.

Add the tracking call

When using total value as your numerator, you will have to add some 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, 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);
    

Value metrics vs revenue metrics 

We don't recommend using total value metrics to track monetary values.

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