Set up multiple revenue tracking events

  • Updated
Relevant products:
  • Optimizely Web Experimentation
  • Optimizely Web Recommendations
  • Optimizely Web Personalization

This topic describes how to:
  • Add multiple revenue events to your experiment tracks
  • Implement the code snippet that calls Optimizely Experimentation's revenue-tracking API in Optimizely Web Experimentation
  • Get more insight using Metrics Builder
  • Understand the difference between single product revenue and total revenue 
  • Understand the Overall Revenue metric

If you have multiple products or checkout funnels you wish to track independently, Optimizely Web Experimentation has that flexibility by adding the revenue tag to any custom event. This article builds on the instructions to implement the revenue tracking event outlined in the Set up revenue tracking in Optimizely Web Experimentation and assumes you have read the article.   

Depending on the funnels of your site, and the revenue values you wish to track independently, extra care needs to be taken in deciding if Overall Revenue will work for you.

Before you set up multiple revenue-tracking events, read through this entire article, especially if you have already set up revenue tracking on your site. Multiple revenue tracking events can skew the Overall Revenue metric if set up incorrectly. 

If you have already set up revenue tracking on your site, read this article before adding additional revenue tracking events, as it can skew the Overall Revenue metric if done incorrectly. 

Overall Revenue versus Custom Revenue Tracking Events

Out of the box, Optimizely Web Experimentation gives all projects 'Overall Revenue' as a metric that can be added to any experiment. Overall revenue is not an event. There is not a conversion in the Enriched Events Export data that has the name Overall Revenue. There is no event API name or ID either. Instead, Overall Revenue is a special calculation Optimizely Experimentation does on the results page based on events generated by visitors bucketed in the experiment. 

To generate Overall Revenue, Optimizely Experimentation looks for events that meet the following two conditions:

  1. events that have a revenue tag
  2. a revenue tag with a value greater than $0 

Overall Revenue will count as a conversion towards the Overall Revenue metric, regardless of the event name, if an event meets the above criteria.  

On the other hand, custom revenue tracking events are actual events sent to Optimizely Experimentation using the Events API. Optimizely Web Experimentation records these events as conversions, calculated on the results page as a stand-alone metric. The number of conversions for a custom revenue tracking event is specific to that custom metric. The value of revenue calculated is the sum of the revenue tag values associated with the custom event with that name only.

Note: Overall Revenue does not count $0 or negative values. If you wish to track discount values, returns, credits, or any other revenue that is negative or $0, you must use a custom revenue event to track conversions. 

Use Overall Revenue or not?

Depending on the funnels of your site, and the revenue values you wish to track independently, extra care needs to be taken in deciding if Overall Revenue is going to work for you.  If you choose to track multiple revenue streams on your site, you must either create a custom event that tracks every revenue stream on your site independently or create custom events to track all revenue to take the place of the Overall Revenue metric.

Since Overall Revenue is a sum of all events with a revenue tag, it is important to ensure that the values that CAN be consumed by Overall Revenue are accurate. If you have set up a revenue tracking event as outlined in this article: Set up Revenue Tracking then there is an event called 'totalRevenue' placed on your confirmation page that is capturing all revenue. Overall Revenue is in turn calculating all revenue on your site by reading the 'totalRevenue' event's revenue tag. Adding additional revenue events that track one product line within the funnel can cause Overall Revenue to become inflated if those products are already tracked in the 'totalRevenue' event. Thus an adjustment must be made to your setup. 

Keep using the Overall Revenue metric

To keep the Overall Revenue metric, remove any revenue events that capture all revenue transactions.  Then create a new event for each product line or revenue stream that comes through your checkout. When a visitor checks out all products in the cart should be captured by only one revenue event.  Ensure that no product or dollar amount is unaccounted for, as this will cause revenue to be missed.

Overall Revenue can not be removed from the project, so it may be helpful to continue using this metric to prevent confusion. 

Replace Overall Revenue with totalRevenue

If there are too many products to create custom events for, or the complexity of capturing each item in the funnel can not be accomplished, then a custom event that collects all revenue can be used in place of the Overall Revenue metric in Optimizely Web Experimentation. 

For this approach there are two parts, first is to set up an event that tracks all revenue, regardless of the product purchased. If you set up 'totalRevenue' as outlined in the Set up Revenue Tracking article, then you can use this metric, just ensure that you add the custom event to your project.  

The second step is to set up logic that evaluates the revenue for just the product(s) you wish to track independently with Optimizely Web Experimentation. The revenue should then be converted to cents and stored as a unique variable. Create a custom event that is designated to track just that product, and pass the custom variable as the value to the revenue tag. 

This event can be added to the same page as the 'totalRevenue' event. When a visitor checks out and has purchased the special item along with other items, then both events will be fired off at the same time.  

Track Multiple Streams of Revenue Example

If you wish to track multiple types of revenue on your site, you can do so by creating custom events that include the revenue tag.  Adding the revenue tag does two things; first, it allows a value to be passed to Optimizely Experimentation, and second, it marks the event to be tracked by Overall revenue.  

An example of this use case would be if your site has multiple revenue funnels or multiple products you wished to track individually.  Let us break down an example using an eCommerce site that sells two types of products Widgets and Wingdings.  This store wants to track all the revenue on the site but also wants to track the revenue for each product separately as well.  To do this create a custom revenue event for Widgets and a second custom event for Wingdings.  Since these are the only two products on this eCommerce site, by tracking the revenue for both these products, all revenue through the funnel is covered, and therefore Optimizely Web Experimentation's Overall Revenue metric can be used.

This guide starts with creating a custom event for product one 'Widgets':

Create a custom event for each revenue stream

  1. Open your web project and navigate to the Implementation page
  2. Click on the Events tab
  3. Select Create New Event 
    create-new-web-event.png
  4. Select Custom event from the new window 
  5. Create a Name and API name that is distinct for the type of revenue event to be tracked. 
    customRevenueName.png
  6. Copy the generated code from Optimizely Web Experimentation and place the code onto the confirmation page of the checkout funnel.  This ensures the transaction was successful before sending the event.
  7. Click Create Event to save your new event.
  8. Repeat steps 1-6 for each type of revenue event you wish to track.

If you are working with the scenario outlined above, two custom events should be created, one custom event to track each of the two products: Widgets and Wingdings.  

Screen Shot 2018-07-09 at 1.59.35 PM.png

 

If you have more products that are not covered by the metrics tracked independently, use the steps above to create an All Revenue event. If you choose to track all revenue through a custom event, do not use overall revenue. Overall revenue will count the individual product events, as well as the all revenue event, which will cause overall revenue to appear inflated.

3RevenueEvents.png

Create custom logic to isolate the revenue streams

Next, create custom logic that will pass the value for each revenue stream into a variable that can be passed to Optimizely Experimentation using the custom event API. Each revenue stream will need its own independent variable that is associated with a specific revenue custom event. Ensure that the value passed is converted into a single currency denomination and converted to cents before the value is passed to the revenue tag of the custom event.

We recommend that revenue tracking events be placed on the confirmation page after a successful transaction has occurred. Multiple revenue events can be added to the same page as long as the variable used to pass the transaction amount to the revenue tag is evaluated independently for each event.  

For our example of 2 revenue events, the confirmation page logic may look something like this:

//pass the total purchase amount of just Widgets
var valueOfWidgets = ‘youDefineThisWidgetsValue’;

//pass the total purchase amount of just Wingdings
var valueOfWingdings = ‘youDefineThisWingdingsValue’;

// Convert all Revenue into cents
var widgetsInCents = valueOfWidgets * 100;
var wingdingsInCents = valueOfWingdings *100;

   window["optimizely"] = window["optimizely"] || [];
     window["optimizely"].push({
     "type": "event",
     "eventName": "trackWidgetRevenue",
     "tags": {
       "revenue": widgetsInCents
     }
    });
    
    window["optimizely"].push({
     "type": "event",
     "eventName": "trackWingdingRevenue",
     "tags": {
       "revenue": wingdingsInCents
     }
   });

 

If you have decided not to use the Optimizely Web Experimentation overall revenue metric and instead want to set up your own custom event. Then create an additional goal that captures all revenue in addition to each revenue stream. The code on the confirmation page will look something like the following:

  //pass the total purchase amount to a variable
var value = ‘youDefineThisTotalValue’;

//pass the total purchase amount of just Widgets
var valueOfWidgets = ‘youDefineThisWidgetsValue’;

//pass the total purchase amount of just Wingdings
var valueOfWingdings = ‘youDefineThisWingdingsValue’;

// Convert all Revenue into cents
var valueInCents = value * 100;
var widgetsInCents = valueOfWidgets * 100;
var wingdingsInCents = valueOfWingdings *100;

   window["optimizely"] = window["optimizely"] || [];

   window["optimizely"].push({
     "type": "event",
     "eventName": "trackRevenue",
     "tags": {
       "revenue": valueInCents
     }
   });
   window["optimizely"].push({
     "type": "event",
     "eventName": "trackWidgetRevenue",
     "tags": {
       "revenue": widgetsInCents
     }
   });
   window["optimizely"].push({
     "type": "event",
     "eventName": "trackWingdingRevenue",
     "tags": {
       "revenue": wingdingsInCents
     }
   });

Finally, add the custom events to your experiment to track conversions for each revenue stream.

Picking the right revenue metric for your experiment 

With Optimizely Web Experimentation's metric builder, you can decide the best way to break down data on the results page using different combinations of the revenue events you have created. To best demonstrate the options, let us look at the Widgets and Wingdings example from above. 

Revenue metrics by total visitors

If you are running an experiment that calls attention to your new Wingding product, where the goal is to increase the number of visitors that purchase a wingding product, then conversions by the visitor is a good approach. Here is how to set this up:

  1. Click on the Experiments page
  2. Click on the name of your experiment: (Widgets and Wingdings)
  3. Navigate to the Metrics from the left-hand navigation panel
  4. Select Wingdings only revenue from the list of metrics
  5. Then, select increase from the first drop-down menu because increasing revenue is considered a win
  6. Select total revenue from the second drop-down menu. This will change how Optimizely Web Experimentation calculates the event.  Instead of by default counting one conversion per instance of the event, by selecting 'total revenue,' Optimizely Web Experimentation looks at the value passed with the revenue tag, takes a sum of those values, and displays the result in the form of currency. 
  7. Select visitor from the third drop-down menu. This will become the denominator for the metric
    revenue-metrics.png
  8. Click Save to Experiment
  9. Click Save
  10. Run the experiment, and we see revenue come in per visitor. 

wingdingByVisitor.png

Revenue metrics by total conversions

Let us say you have an experiment where you want to encourage visitors to buy more than one Widget in a transaction. For this, it is better to look at the number of conversions as a denominator. This approach will say of the visitors that made a purchase, did the amount spent increase? 

The same steps as above only on step 6 select conversions as a denominator:

  1. Click on the Experiments page
  2. Click on the name of your experiment: (Widgets and Wingdings)
  3. Navigate to the Metrics from the left-hand navigation panel
  4. Select Wingdings only revenue from the list of metrics
  5. Then, select increase from the first drop-down menu because increasing revenue is considered a win
  6. Select total revenue from the second drop-down menu. This will change how Optimizely Web Experimentation calculates the event. Instead of by default counting one conversion per instance of the event, by selecting 'total revenue,' optimizely looks at the value passed with the revenue tag, takes a sum of those values, and displays the result in the form of currency. 
  7. Select conversions from the third drop-down menu. This will become the denominator for the metric
  8. Click Save to Experiment
  9. Click Save
  10. Run the experiment, and we see revenue come in per visitor. 

wingdingBuConversion.png

Look at the two graphics for the Wingding revenue above.  Notice that the dollar amount is the same, but the data given is much different. In the revenue per visitor, we see we are closer to statistical significance, and the total improvement is much greater. How can that be when the total revenue is the same?

By changing the denominator from total visitors, to the total population that converted to the event, our population drops considerably.  Notice that there is a much smaller improvement rate even though the revenue per conversion is substantially more. By removing all the visitors that spent $0 dollars, we can evaluate just the difference in the totals of those who made purchases. As a result, the statistical significance will take more time and more visitors when looking at metrics by conversion instead of by visitor. 

 

Revenue metrics as a custom event

Let us say you do not have a static confirmation page, but you still want to evaluate how many times the custom revenue event was triggered. Simply added the wingding metric to the results page, but instead of changing the event type to revenue use total conversions. This will give you a numeric value of how many times the revenue event was triggered.

totalConversions.png