Amplitude

Integrate in-app subscription events from RevenueCat with Amplitude

πŸ‘

The Amplitude integration is available on the Pro plan.

Amplitude can be a useful integration tool for seeing all events and revenue that occur for your app even if it’s not active for a period of time. You can use Amplitude’s product analytics to find patterns in customer behavior and inform marketing strategies.

With our Amplitude integration, you can:

  • Create a behavioral cohort of customers based on specific actions, such as watching a specific episode of a show after subscribing. Follow a cohort throughout their lifecycle to realize overarching trends.
  • Measure the path of a user from marketing material to the purchase of a subscription.

With accurate and up-to-date subscription data in Amplitude, you'll be set to turbocharge your product analytics ⚑️

Events

The Amplitude integration tracks the following events:

Event

Description

Initial Purchase

The first purchase of an auto-renewing subscription product that does not contain a free trial.

Trial Started

The start of an auto-renewing subscription product free trial.

Trial Converted

When an auto-renewing subscription product converts from a free trial to normal paid period.

Trial Cancelled

When a user turns off renewals for an auto-renewing subscription product during a free trial period.

Renewal

When an auto-renewing subscription product renews OR a user repurchases the auto-renewing subscription product after a lapse in their subscription.

Cancellation

When a user turns off renewals for an auto-renewing subscription product during the normal paid period.

Uncancellation

When a user re-enables the auto-renew status for a subscription.

Non Subscription Purchase

The purchase of any product that's not an auto-renewing subscription.

Subscription paused

A subscription has been paused.

Expiration

A subscription has expired and access should be removed.

Billing Issues

There 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).

Product Change

When user has changed the product of their subscription.

This does not mean the new subscription is in effect immediately. See Managing Subscriptions for more details on updates, downgrades, and crossgrades.

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.attribution.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 User Identifiers to RevenueCat

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

Key

Description

$amplitudeDeviceId

The Amplitude Device ID

$amplitudeUserId

The Amplitude User ID

If both keys are present, RevenueCat will send both the User ID and Device ID to identify events into Amplitude. If only one of the keys are present, RevenueCat will only send the available key. If no keys are present, RevenueCat will send the current RevenueCat App User ID. This property can be set and removed manually, like any other Subscriber Attribute. For more information how Amplitude tracks unique users, view their docs here.

2. Send RevenueCat Events to Amplitude

πŸ“˜

Amplitude EU Data Centre

Contact RevenueCat support to have RevenueCat send data to Amplitude's EU data centre if your Amplitude account is hosted on EU servers.

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 sales reported as gross revenue (before app store commission), or after store commission and/or estimated taxes.
18111811

Amplitude configuration page

Sample Event

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

{
  "api_key": "yourAmplitudeAPIKey",
  "event": {
    "event_type": "Trial Conversion Event",
    "partner_id": "revenuecat", 
    "insert_id": "d61ed8b3-d4ed-436e-80b6-a69dabe44855", 
    "time": 1655322275000, 
    "platform": "iOS", 
    "revenue": 139.993, 
    "productId": "rc_3999_1y_1w0", 
    "event_properties": {
      "subscriber_attributes": {
        "$attConsentStatus": "denied", 
        "$amplitudeDeviceId": "123a4b56-7890-12cd-345e-67f90gh1ij1k"
       }, 
       "period_type": "NORMAL", 
       "purchased_at": "2022-06-15T19:44:35Z", 
       "expiration_at": "2022-06-22T19:44:35Z", 
       "environment": "SANDBOX", 
       "entitlement_id": null, 
       "entitlement_ids": ["premium"], 
       "presented_offering_id": null, 
       "transaction_id": "2000000080909203", 
       "original_transaction_id": "2000000080909203", 
       "aliases": ["$RCAnonymousID:e35dd5b6732f4e1aad8c398d635e83e0"], 
       "original_app_user_id": "$RCAnonymousID:e35dd5b6732f4e1aad8c398d635e83e0", 
       "store": "APP_STORE", 
       "app_user_id": "$RCAnonymousID:e35dd5b6732f4e1aad8c398d635e83e0", 
       "product_id": "rc_3999_1y_1w0", 
       "currency": "USD", 
       "revenue": 139.993
      }, 
    "user_id": "$RCAnonymousID:e35dd5b6732f4e1aad8c398d635e83e0""
  }
}

Did this page help you?