Sub topic 13
Tracking refunds
This chapter covers how to report refunds to GA4, how a refund changes revenue metrics, and which mistakes distort the numbers. It assumes you can already send a purchase event with a unique transaction_id and a correct items array. It also assumes you know basic JSON and JavaScript objects.
What a refund event does
A refund event tells GA4 that money was returned for an earlier order. GA4 does not look up the original purchase. It links the refund to the purchase by matching transaction_id. So the value you send in the refund must be the same ID you sent in the purchase.
Two refund shapes exist:
- Full refund: send
transaction_id,currency, andvalue. You do not need to senditems. - Partial refund: send the same fields plus an
itemsarray that lists only the refunded products and quantities.
The value is the amount returned to the customer. For a full refund, it is normally the order's total. For a partial refund, it is the sum of price times quantity for the refunded items.
Where refunds come from
A refund usually happens after the shopper has left your site. A support agent or a payment system issues it, often days later. That affects how you send it.
| Source | Typical approach | Notes |
|---|---|---|
| Admin page in the browser (agent clicks "refund") | `gtag` or `dataLayer` event | The event is tied to the agent's browser, not the customer's. |
| Payment provider webhook | Measurement Protocol from your server | Best for refunds that happen outside the site. |
| Batch import of returns | Measurement Protocol | Send one request per refund event. |
The browser approach is fragile. The agent's session is not the shopper's session, so the refund can be attributed to the wrong user or traffic source. The Measurement Protocol is usually the better choice for refunds that start on the back end.
Sending a refund with gtag.js
For a full refund, you only need the transaction ID, currency, and value:
gtag('event', 'refund', {
transaction_id: 'T_12345',
currency: 'USD',
value: 49.98
});This reverses the whole order. If the order had tax and shipping and you refund those too, include them in value so it matches what you returned.
For a partial refund, add the items being returned:
gtag('event', 'refund', {
transaction_id: 'T_12345',
currency: 'USD',
value: 24.99,
items: [
{
item_id: 'SKU_1001',
item_name: 'Trail Running Shoe',
price: 24.99,
quantity: 1
}
]
});The original order had two pairs of shoes at 24.99 each. This event returns one pair. The quantity is the number of units refunded, not the original quantity.
Sending a refund with the Measurement Protocol
The Measurement Protocol lets your server send events over HTTP. It suits refunds because your back end knows when the money moved. You send a POST request to this address:
https://www.google-analytics.com/mp/collect?measurement_id=G-XXXXXXX&api_secret=YOUR_SECRET
The measurement_id identifies the web data stream. The api_secret is created in the data stream's settings. Keep it on the server and out of client code.
The request body below is a partial refund of one unit:
{
"client_id": "123456.7654321",
"events": [
{
"name": "refund",
"params": {
"transaction_id": "T_12345",
"currency": "USD",
"value": 24.99,
"items": [
{
"item_id": "SKU_1001",
"item_name": "Trail Running Shoe",
"price": 24.99,
"quantity": 1
}
]
}
}
]
}The client_id is required. To attribute the refund to the original customer, store the GA client_id from the browser when the purchase happens, for example in your order record. Then reuse it here. If you invent a new client_id, GA4 treats the refund as coming from a new user. The revenue effect still ties to the transaction, but user-level reports will not connect the two events.
A successful request to /mp/collect returns a success status even if the payload is wrong. That is why validation matters. The Measurement Protocol also offers a validation endpoint at /debug/mp/collect, which returns messages about malformed events and does not record them.
How refunds flow into metrics
The diagram shows how a purchase and a later refund combine.
GA4 keeps purchase revenue and refund amounts as separate metrics. Reports such as the Monetization overview show a refund amount alongside revenue. Be careful with the metric names. "Purchase revenue" counts only purchases, so a refund does not lower it. The "Total revenue" metric includes the effect of refunds. When you compare GA4 to your finance system, decide first whether you are comparing gross or net figures.
Refunds are recorded on the date the refund event arrives, not the date of the original purchase. A refund sent in December for a November order lowers December's figures. Month-end comparisons can differ from your accounting system for this reason.
Common mistakes
- Mismatched
transaction_id. A typo, a changed format, or a prefix added in one system means GA4 cannot link the refund to the purchase. Use the exact string from the purchase. - Sending the refund twice. A retried webhook can send the same refund repeatedly. GA4 does not de-duplicate refund events the way it can for purchases. Keep a record of refunds you have already sent, and check it before each send.
- Wrong sign. Send
valueas a positive number. GA4 subtracts it. A negative value produces confusing results. - Missing or different
currency. Send the same currency as the original purchase. - Quantity from the original order. In a partial refund,
quantityis the refunded quantity. - Item IDs that do not match the purchase. Item-level refund figures depend on
item_idmatching what you sent earlier. - Relying on the agent's browser. As noted above, this attributes the event to the wrong session.
Checking your work
- Send a test purchase with a known
transaction_id, then send the refund. - For browser events, open DebugView and confirm the
refundevent arrives with the expected parameters. - For server events, first post to
/debug/mp/collectand read the validation messages. Then post to/mp/collect. - After processing, look for refund amounts in the Monetization reports. Standard reports can lag, so do not expect an instant result.
Exercise
A customer bought two pairs of shoes at 24.99 each in order T12345. They return one pair. Your server sends a refund event. Which value, quantity, and `transactionid` do you send, and why is the Measurement Protocol often better than the browser here?
Show answer
Send value: 24.99, quantity: 1 for the item in items, and transaction_id: 'T_12345'. The value and quantity describe only the refunded unit, and the transaction ID must match the purchase exactly so GA4 can link them. The Measurement Protocol is often better because the refund is issued on the back end, usually after the shopper has left. A browser event would come from an agent's session and could be attributed to the wrong user.
Exercise
Your payment webhook retries failed deliveries, and your analytics shows refund totals higher than your finance system. What is the likely cause and the fix?
Show answer
The webhook probably sends the same refund event more than once, and GA4 counts each one. Fix it by storing the refunds already reported, for example by refund ID, and skipping any refund that has been sent before.