Skip to main content
menu-icon.png

 

x
Optimizely Knowledge Base

Set up multiple revenue tracking events

relevant products:
  • Optimizely X Web Experimentation
  • Optimizely X Web Recommendations
  • Optimizely X Web Personalization
  • Optimizely X Multivariate Experimentation 

THIS ARTICLE WILL HELP YOU:
  • Add multiple revenue events to your experiment tracks
  • Implement the code snippet that calls Optimizely's revenue-tracking API
  • 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 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 X  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 is going to 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 through this article fully before adding additional revenue tracking events, as it can skew the Overall Revenue metric if done incorrectly. 

Overall Revenue vs. Custom Revenue Tracking Events

Out of the box Optimizely gives all projects 'Overall Revenue' as a metric that can be added to any experiment.  It is important to note that overall revenue is not an event, there is not a conversion in the raw data that has a name overall revenue,  there is no event API name or ID either.  Rather Overall Revenue is a special calculation Optimizely does on the results page based on events generated by visitors bucketed in the experiment. 

To generate Overall Revenue Optimizely 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 a conversion towards the Overall Revenue metric, regardless of event name if an event meets the above criteria.  

Custom revenue tracking events on the other hand are actual events that are sent to Optimizely using the events API.  These events are recorded by Optimizely as conversions, which are calculated on the results page as a stand alone metric.  The number of conversions for a custom revenue tracking event are specific to that custom metric, the value of revenue calculated is the sum of the revenue tag values associated to 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 a custom events to track all revenue to take the place of 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 set up. 

Keep using 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. 

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 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.  The revenue should then be converted to cents and stored as a unique variable.  Create a custom event that is designated to tracking just that product, and pass the custom variable as the value to the 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, 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 tracked individually.   Lets break down an example using a 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 the this eCommerce site, by tracking the revenue for both these products, all revenue through the funnel is covered and therefore Optimizely's Overall Revenue metric can be used.

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

Create custom event for each revenue stream

  1. Open your project, to the implementation page
  2. Click on Events
  3. Select create new event
    newCustomEvent.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 and place the code onto the confirmation page of the checkout funnel.  This ensures the transaction was successful, before sending the event.
  7. Repeat steps 1-6 for each type of revenue event you wish to track.

If you are working with the scenario outlined above,  2 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 create custom logic that will pass the value for each revenue stream into a variable that can be passed to Optimizely using the custom event API.  Each revenue stream will need its own independent variable, that is associated to 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 evaluate independently for each event.  

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

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

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

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


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

 

If you have decided not to use the Optimizely 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 purhase amount to a variable
var value = ‘youDefineThisTotalValue’;

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

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

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


<script>
   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
     }
   });
</script>

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's metric builder, you can decide the best way break down data on the results page using different combinations of the revenue events you have created.   To best demonstrate the options, lets look at the Widgets and Wingdings example from above. 

Revenue metrics by total visitors

If you are running a 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 visitor is a good approach.  Here is how to set this up:

  1. Open the experiment
  2. Navigate to the Metrics tab
  3. Select trackWingdingRevenue from the list of metrics
  4. Select increase from the first drop down menu because increasing revenue is considered a win
  5. Select total revenue from the second drop down menu, this will change how Optimizely 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, and takes a sum of those values and displays the result in the form of currency. 
  6. Select visitors from the third drop down menu, this will become the denominator for the metric
    conversionByVisitor.png
  7. Run the experiment, and we see revenue come in per visitor. 

wingdingByVisitor.png

Revenue metrics by total conversions

Lets 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. Open the experiment
  2. Navigate to the Metrics tab
  3. Select trackWingdingRevenue from the list of metrics
  4. Select increase from the first drop down menu because increasing revenue is considered a win
  5. Select total revenue from the second drop down menu, this will change how Optimizely 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, and takes a sum of those values and displays the result in the form of currency. 
  6. Select conversions from the third drop down menu, this will become the denominator for the metric
  7. 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 on the event, our population drops considerably.  Notice that there is a much smaller improvement rate even though the revenue per conversions 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 purchase.  As a result statistical significance will take more time and more visitors when looking at metric by conversion instead of by visitor. 

 

Revenue metrics as a custom event

Lets say you don't 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