Sub topic 14
How revenue metrics are calculated
Assume you understand GA4 properties, events, JavaScript objects, and the basic structure of a shop’s checkout. This chapter focuses on how GA4 turns purchase, item, and refund data into revenue metrics.
The calculation model
A purchase event normally contains:
value: the monetary value assigned to the purchasecurrency: the currency code, such asUSDitems: the products boughttaxandshipping: optional separate amountstransaction_id: the order identifier
GA4 uses these fields to calculate different metrics. The metrics answer different questions, so they will not always have the same value.
| Metric | Typical calculation | What it represents |
|---|---|---|
| Item revenue | Sum of item price × quantity | Revenue from products only |
| Purchase revenue | Sum of `value` on purchase events | Revenue assigned to completed purchases |
| Refund amount | Sum of `value` on refund events | Value returned to customers |
| Total revenue | Purchase revenue + subscription revenue + ad revenue | Revenue across supported revenue sources |
In the standard implementation, value is the sum of item price multiplied by quantity. Tax and shipping are sent separately. Therefore, do not assume that a report includes tax or shipping unless the metric definition and your implementation support that interpretation.
Item revenue
Suppose an order contains two units priced at $24.99:
const items = [
{ price: 24.99, quantity: 2 }
];
const itemRevenue = items.reduce(
(sum, item) => sum + item.price * item.quantity,
0
);
const purchaseValue = itemRevenue;
const refundAmount = 24.99;
const netItemRevenue = itemRevenue - refundAmount;
console.log({ itemRevenue, purchaseValue, refundAmount, netItemRevenue });The item revenue is $49.98. A refund for one unit is $24.99. This example produces net item revenue of $24.99 for the business-defined period.
Use consistent price rules. If price represents the discounted unit price, calculate revenue from that price. If discounts are sent separately, document how your reporting process accounts for them.
Purchase revenue and refunds
Purchase revenue comes from purchase events. A purchase event with the same order sent twice can inflate reporting unless the duplicate is handled correctly. Generate one stable, unique transaction_id for each order and do not create a new ID when a page reloads.
A refund event identifies the original order with its transaction_id. A partial refund should include the refunded item and quantity, or the corresponding refunded value. Reports commonly show purchase revenue and refund amount as separate metrics. If you need net revenue, calculate it as purchase revenue minus refund amount within the same reporting scope.
Currency and reporting scope
The currency parameter tells GA4 how to interpret value. Use an ISO 4217 code such as USD or EUR, and send a numeric value rather than a formatted string. GA4 can convert currencies to the property currency for reporting, but inconsistent or missing currency values make comparisons unreliable.
Revenue belongs to the date and reporting scope of the event. Time zone, filters, attribution settings, refunds, and data-processing delays can make a GA4 total differ from an order system total.
Exercise
An order has two items at $30 each, and one item is refunded for $30. What are the item revenue and net item revenue before considering tax, shipping, subscriptions, or ads?
Show answer
Item revenue is $60. Net item revenue is $30 after subtracting the $30 refund.