- Optimizely Web Experimentation
- Optimizely Feature Experimentation
This topic describes how to:
- Add the required code to your site to allow total value metrics to work
- Understand the difference between value metrics and revenue metrics
Optimizely Web Experimentation and Optimizely Feature Experimentation's total value metric is a very flexible numeric metric, letting you track actions that go beyond conversions and revenue. As long as it is quantifiable, you can use total value to track it.
Add the tracking call
When using total value as your numerator, you will have to add some JavaScript to your experiment or campaign. When you are ready to add code, use the reserved value
tag.
-
If you are using Optimizely Web Experimentation, add a small snippet of code to your site to call the 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 Feature Experimentation, include the value tag when tracking an event. The following code shows 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
You should not use 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.