On this page

Track revenue

When you begin sending revenue events to Amplitude, you can choose from several configuration options.

Revenue events that include revenue properties appear in the Revenue LTV chart. The chart includes verified and unverified events. For more information about sending revenue events, refer to the following documentation:

Amplitude counts only events that you send through the Amplitude ingestion system. Amplitude doesn't count computed events separately. Additional events attached to revenue events, such as Revenue (Verified) or Revenue (Unverified), don't count toward your limit.

Revenue properties

Amplitude needs revenue properties to track revenue:

  • Send $revenue directly, or send $price. In most cases, include $quantity.
  • Amplitude calculates revenue with the formula $price * $quantity. If $quantity isn't present, Amplitude uses 1.
NameTypeDescriptionDefault
$revenueDoubleThe total revenue from the user's purchase. Negative values are valid. You must send $revenue if you want the revenue event to appear in a Revenue LTV chart.null
$priceDoubleThe price of the products purchased. Negative values are valid.null
$productIdStringAn identifier for the product.null
$quantityIntegerThe quantity of products purchased. Defaults to one if not specified.1
$revenueTypeStringThe type of revenue, for example, tax, refund, or income.null
$currencyStringThe currency for the purchased item. Use a three-character uppercase ISO 4217 code, for example, USD or EUR.null
eventPropertiesObjectAn object of event properties to include in the revenue event. You can only segment on the included event properties in the Event Segmentation chart.null

You must explicitly send revenue properties using Amplitude's SDKs or server-side when you log revenue events.

Track non-in-app purchases

For purchases that aren't in-app purchases, there are three ways to send revenue data to Amplitude:

  • Use Amplitude's SDKs to call the logRevenueV2 function. The logRevenueV2 function generates Revenue events.
  • Use Amplitude's SDKs to call the logEvent function if you include the $revenue property.
  • Use Amplitude's HTTP API by setting the price, quantity, or revenue fields. Add your own event name, for example, Purchase completed.

Amplitude performs verified revenue checks only for in-app purchases.

Track in-app purchases (IAPs)

To track IAPs, send revenue events the same way you send regular revenue events, using logRevenueV2 or logEvent (with the $revenue property) in Amplitude's SDKs. For IAPs, you can validate purchases by passing receipt data with the revenue event.

Enable revenue verification

To enable revenue verification, copy your iTunes Connect In App Purchase Shared Secret or your Google Play License Public Key into the Sources section of your project in Amplitude Data. You must include a key for each Amplitude project where you want revenue verification. You also need to pass in receipt data for Amplitude to verify the revenue event.

Amplitude can create three revenue event types from the SDK logRevenue call. The SDK revenue event types are separate from revenue events sent server-side through the HTTP API:

Event typeDescription
RevenueAmplitude logs Revenue for revenue events, whether revenue verification is on or off. The Revenue event doesn't populate the $revenue property. Revenue (Verified) and Revenue (Unverified) events populate $revenue. To include SDK revenue events in a Revenue LTV chart, turn revenue verification on. If revenue verification is on and the user activity stream shows only Revenue, the revenue failed verification.
Revenue (Verified)Amplitude logs Revenue (Verified) for legitimate transactions. The count difference between Revenue and Revenue (Verified) is the number of illegitimate app purchases. By default, revenue events recorded on SDKs appear in Amplitude dashboards as unverified revenue events. To generate Revenue (Verified) events, enable revenue verification.
Revenue (Unverified)An unverified revenue event didn't necessarily fail verification. An unverified event means Amplitude didn't attempt verification because the event came through the HTTP API or JavaScript SDK, or because your project didn't include revenue verification keys. If revenue verification is off, Amplitude logs Revenue (Unverified) for all revenue events.

You can switch verification on or off only for mobile. Web always tracks Revenue and Revenue (Unverified).

Amplitude displays revenue that doesn't fail verification. You may see both Revenue (Verified) and Revenue (Unverified) if, for example, you send both mobile and web revenue events through Amplitude SDKs.

Receipt validation

Amplitude validates in-app purchases based on the receipt from Apple or Google.

Discrepancies

Discrepancies between app store reports and Amplitude can come from time zone differences, event generation bugs, or piracy.

If the discrepancy is minor and consistent day to day, the most likely cause is a time zone difference between the app store and Amplitude. Amplitude uses UTC. If the app store uses a different time zone, the app store may report a purchase event on a different day than Amplitude. No data is lost.

Major discrepancies can come from client-side errors, such as the store purchase callback running multiple times for a single purchase. Call revenue events only after a successful store purchase. The following calls track the event property and revenue amount:

plaintext
AmplitudeClient.getInstance().logEvent('IAP', {type='Sale Special'})

plaintext
AmplitudeClient.getInstance().logRevenueV2("com.company.productid", 1, 2.99)

Piracy can also cause major discrepancies. Users can circumvent the app store and make purchases that don't appear in app store reports. To exclude pirated revenue events from your data, use Amplitude's revenue verification method. If you suspect piracy heavily skews your data, contact Amplitude Support.

Considerations for developers

Review the following points when you track revenue events:

  • Backward compatibility: The existing logRevenue methods still work but are deprecated. Events logged with the old methods miss fields such as revenueType, so the Amplitude platform limits segmentation on those revenue events.
  • Opting users out of logging: You can turn off logging for a given user by calling setOptOut:
plaintext
amplitude.getInstance().setOptOut(true);

Amplitude doesn't save or send events to the server while opt out is enabled. The opt out setting persists across page loads. You can reenable logging by calling:

plaintext
amplitude.getInstance().setOptOut(false);

Was this helpful?