/Docs

Revenue Tracking

When you pass a revenue amount with a custom event, A vs B can calculate the estimated revenue impact of your experiment — not just whether one variation converted more, but how much more money it generated. This is the most direct way to connect your A/B tests to business outcomes.

How revenue tracking works

Revenue tracking is an optional extension of custom events. When you call avsb.track.event(), you can pass a second argument containing a revenue property. The value should be a plain number representing the transaction amount in your primary currency.

javascript
1avsb.track.event(12345, { revenue: 49.99 });

A vs B stores this value alongside the conversion record. When you view your experiment results, the Results page uses the stored revenue figures to calculate:

  • Revenue per visitor — total revenue divided by total visitors for each variation.
  • Revenue Impact — the estimated additional revenue generated by the winning variation compared to the control, projected over the full experiment traffic.
  • Average Order Value (AOV) — total revenue divided by the number of converting visitors for each variation.

Code examples

E-commerce purchase

Track the revenue from a completed purchase. Typically you would fire this after the server confirms the order — either by reading the total from your order confirmation page or from the API response.

Reading revenue from the page
javascript
1// Read the order total from a data attribute or hidden field
2var orderTotal = parseFloat(document.getElementById('order-total').dataset.value);
3
4avsb.track.event(12345, { revenue: orderTotal });
Reading revenue from an API response
javascript
1fetch('/api/checkout', { method: 'POST', body: cartData })
2 .then(function(response) { return response.json(); })
3 .then(function(data) {
4 if (data.success) {
5 avsb.track.event(12345, { revenue: data.order.total });
6 }
7 });

SaaS trial conversion

Track when a free trial converts to a paid subscription. Pass the monthly or annual plan value as revenue.

javascript
1// When the user upgrades to a paid plan
2var planValue = 29.00; // monthly plan price
3
4avsb.track.event(12345, { revenue: planValue });

Dynamic revenue from a data layer

javascript
1// Reading from a GTM-style dataLayer push
2window.dataLayer = window.dataLayer || [];
3window.dataLayer.push({
4 event: 'purchase',
5 transactionTotal: 79.99
6});
7
8// In your A vs B tracking code, read from the dataLayer
9var lastPurchase = window.dataLayer
10 .filter(function(e) { return e.event === 'purchase'; })
11 .pop();
12
13if (lastPurchase) {
14 avsb.track.event(12345, { revenue: lastPurchase.transactionTotal });
15}

Average Order Value calculation

Average Order Value (AOV) is calculated per variation as:

AOV = Total Revenue / Number of Converting Visitors

A high AOV in one variation does not necessarily mean that variation is better overall — it means the visitors who converted spent more on average. A variation could have a lower conversion rate but a higher AOV, meaning fewer visitors bought but each one spent more. The Revenue Impact card on the results page accounts for both the conversion rate and the AOV together.

When to use revenue tracking

Revenue tracking is most useful when:

  • You are running an e-commerce site and want to understand whether a design change drives more purchases and more revenue — not just more clicks.
  • You are testing pricing or plan presentation on a SaaS product and want to compare how different variations affect the revenue value of conversions, not just the conversion rate.
  • You have a high cart abandonment problem and want to know whether a checkout redesign generates more revenue per visitor, even if the raw conversion rate improvement looks small.

Important notes

Revenue is stored on first conversion only
Because A vs B records at most one conversion per visitor per metric, only the revenue value from the first avsb.track.event()call is stored. If a visitor makes multiple purchases during the experiment, only the first one is counted.
Pass a plain number
The revenue value must be a plain JavaScript number — for example 49.99. Do not pass a formatted string like '$49.99' or '49,99'. These will not be parsed correctly and the revenue data will be lost.