Tracking revenue
Revenue is an event that carries an amount. The script you already installed sends it; nothing else needs connecting.
-
Make sure the script is on the page where money changes hands
Section titled “Make sure the script is on the page where money changes hands”The tracker has to be running on the page that completes the purchase: a thank-you page, an order-confirmation step, the moment a plan upgrade succeeds. If that page lives on another domain, install the same tag there with the same site key.
-
Send the amount
Section titled “Send the amount”Either form works. Pick the one that reads best in your code.
tracing("purchase", { revenue: 49, currency: "USD", plan: "pro" });Any custom event whose properties include a numeric
revenuebecomes a revenue event. The event keeps its name, so it shows up aspurchaseeverywhere.currencydefaults toUSDwhen omitted. Every other property is stored as a normal event property.tracing.revenue(49, "USD", { plan: "pro" });The dedicated call. The event is named
revenueunless you pass anameproperty. -
Check that it arrived
Section titled “Check that it arrived”Open Realtime and make a test purchase. The event appears in the live feed with its name within a second. The Revenue screen switches from its setup card to the real report on the first revenue event, and the revenue tile on Overview, the value column on Goals and the revenue line in a visit’s timeline appear at the same moment.
Amounts
Section titled “Amounts”Write amounts the way a person would: 49 is forty-nine dollars, 49.99 is
forty-nine dollars and ninety-nine cents. The tracker converts to the
currency’s minor unit before sending, and that unit is not always one
hundredth:
| Currency group | Factor | Example |
|---|---|---|
Zero-decimal: BIF DJF GNF JPY KMF KRW MGA PYG RWF UGX VND VUV XAF XOF XPF CLP |
×1 | revenue: 1200, currency: "JPY" → 1200 |
Three-decimal: BHD IQD JOD KWD LYD OMR TND |
×1000 | revenue: 1.5, currency: "KWD" → 1500 |
| Everything else | ×100 | revenue: 49, currency: "USD" → 4900 |
The result is rounded to the nearest integer. The API and the CSV export report minor units; the dashboard formats them for the currency.
Currencies
Section titled “Currencies”Currency codes are ISO 4217, case-insensitive, uppercased before sending. Send whatever currency the customer actually paid in.
Currencies are never added together. Adding a yen to a dollar produces a number that is true in no currency, so the Revenue screen reports one at a time and shows a switcher when more than one took money in the range. The site currency in Settings is the one the screen opens on.
A visit’s own revenue figure, the one on the Sessions list, adds up the amounts its events reported in the site currency.
What a revenue event is
Section titled “What a revenue event is”One event row, of type revenue, with an amount and a currency. It:
- counts towards your monthly event allowance like any other event;
- belongs to the visit it fired in, and inherits everything the visit knows: referrer, campaign, landing page, country, device. See How attribution works;
- counts as a conversion for any goal that matches its name, and the goal reports the amount as its value;
- appears in the visit’s timeline on Sessions and in the Events explorer with its amount.
Before the script has loaded
Section titled “Before the script has loaded”If the purchase completes before the tracker has booted, queue the call on the stub described in Custom events. Queued calls are replayed once the script is ready and the visitor is known, so the event is filed under the same visit as the landing pageview.
Related
Section titled “Related”- Revenue screen
- How attribution works
- Troubleshooting revenue
- Revenue events in the tracker reference