Amplitude

Integrate in-app subscription events from RevenueCat with Amplitude

👍

The Amplitude integration is available on the Pro plan.

RevenueCat can automatically send subscription events into Amplitude. This is useful for seeing all events and revenue that occur for your app even if it's not active for a period of time.

Events

The Amplitude integration tracks the following events:

EventDescription
Initial PurchaseThe first purchase of an auto-renewing subscription product that does not contain a free trial.
Trial StartedThe start of an auto-renewing subscription product free trial.
Trial ConvertedWhen an auto-renewing subscription product converts from a free trial to normal paid period.
Trial CancelledWhen a user turns off renewals for an auto-renewing subscription product during a free trial period.
RenewalWhen an auto-renewing subscription product renews OR a user repurchases the auto-renewing subscription product after a lapse in their subscription.
CancellationWhen a user turns off renewals for an auto-renewing subscription product during the normal paid period.
UncancellationWhen a user re-enables the auto-renew status for a subscription.
Non Subscription PurchaseThe purchase of any product that's not an auto-renewing subscription.
Subscription pausedA subscription has been paused.
ExpirationA subscription has expired and access should be removed.
Billing IssuesThere has been a problem trying to charge the subscriber.

This does not mean the subscription has expired (in the case of a grace period enabled).

For events that have revenue, such as trial conversions and renewals, RevenueCat will automatically record this amount along with the event in Amplitude.

Setup

1. Set Amplitude User Identity

If you're using the Amplitude SDK, you can set the User Id to match the RevenueCat App User Id. This way, events sent from the Amplitude SDK and events sent from RevenueCat can be synced to the same user.

Configure the Amplitude SDK with the same App User Id as RevenueCat or use the .setUserId() method on the Amplitude SDK.

// Configure Purchases SDK
Purchases.configure(withAPIKey: "public_sdk_key", appUserID: "my_app_user_id")

// Configure Amplitude SDK
Amplitude.instance()?.initializeApiKey("amplitude_api_key", userId: "my_app_user_id")

// Optional User Alias Object attributes
Purchases.shared.setAttributes(["$amplitudeDeviceId" : <AMPLITUDE_DEVICE_ID>])
// Configure Purchases SDK
[RCPurchases configureWithAPIKey:@"public_sdk_key" appUserID:@"my_app_user_id"];

// Configure Amplitude SDK
[[Amplitude] instance] initializeApiKey:@"amplitude_api_key" userId:@"my_app_user_id"];
// Configure Purchases SDK
Purchases.configure(this, "public_sdk_key", "my_app_user_id");

// Configure Amplitude SDK
Amplitude.getInstance().initialize(this, "amplitude_api_key", "my_app_user_id");

(Optional) Send Amplitude device_id to RevenueCat

If your App User ID in RevenueCat is different than the User ID in Amplitude, you can use the Amplitude Device ID to identify events by adding a key in Subscriber Attributes.

KeyDescription
$amplitudeDeviceIdThe Amplitude Device ID

When this key is present, RevenueCat will always use Device ID to identify events into Amplitude, as opposed to the RevenueCat App User ID. The property can be set and removed manually, like any other Subscriber Attribute.

2. Send RevenueCat Events to Amplitude

After you've set up the Purchases SDK and Amplitude SDK to have the same user identity, you can "turn on" the integration and configure the event names from the RevenueCat dashboard.

  1. Navigate to your project in the RevenueCat dashboard and find the Integrations card in the left menu. Select + New
332332
  1. Choose Amplitude from the Integrations menu
  2. Add your Amplitude API key
  3. Enter the event names that RevenueCat will send or choose the default event names
  4. Select whether you want RevenueCat to report proceeds (after app store cut) or revenue (gross sales)
576576

Amplitude configuration page

Sample Event

Below is sample JSON that is delivered to Amplitude for a trial conversion event.

{
    user_id: "yourCustomUserId", 
    event_type: "Trial Conversion Event", 
    time: 1580602110000, 
    platform: "iOS", 
    revenue: 9.99, 
    productId: "your_product_id"
}