AppsFlyer
With our AppsFlyer integration you can:
- Accurately track subscriptions generated from AppsFlyer campaigns, allowing you to know precisely how much revenue your campaigns generate.
- Send trial conversions and renewals directly from RevenueCat to AppsFlyer, allowing for tracking without an app open.
- Continue to follow your cohorts for months to know the long tail revenue generated by your campaigns.
Integration at a Glanceβ
Includes Revenue | Supports Negative Revenue | Sends Sandbox Events | Includes Customer Attributes | Sends Transfer Events | Optional Event Types |
---|---|---|---|---|---|
β | β | Requires Sandbox API key | β | β | non_subscription_purchase_event expiration_event billing_issue_event product_change_event |
1. Install Appsflyer SDKβ
Before RevenueCat can integrate with Appsflyer, your app should be running the latest Appsflyer SDK. Refer to the Appsflyer developer documentation for the latest installation instructions.
2. Send device data to RevenueCatβ
The Appsflyer integration requires some device-specific data. RevenueCat will only send events into Appsflyer if the below Customer Attributes keys have been set for the device.
Key | Description | Required |
---|---|---|
$appsflyerId | Appsflyer Id. The unique Appsflyer identifier for the user | β (required) |
$idfa | iOS advertising identifier UUID | β (recommended) |
$gpsAdId | Google advertising identifier | β (recommended) |
$idfv | iOS vender identifier UUID | β (recommended) |
$ip | The IP address of the device | β (optional) |
Due to policy changes from the Play Store, Android ID is no longer collected by RevenueCat's Android SDKs starting on versions 6.9.8+, 7.11.1+, and later major versions.
Therefore, Google's Advertising ID acts as the primary device identifier for Android devices in RevenueCat and when connecting with third-party integrations.
These properties can be set manually, like any other Attributes, or through the helper methods to collectDeviceIdentifiers()
and setAppsflyerId()
.
- Swift
- Kotlin
import AdSupport
// ...
Purchases.configure(withAPIKey: "public_sdk_key")
// ...
// Automatically collect the $idfa, $idfv, and $ip values
Purchases.shared.attribution.collectDeviceIdentifiers()
// Set the Appsflyer Id
Purchases.shared.attribution.setAppsflyerID(AppsFlyerLib.shared().getAppsFlyerUID())
//..
Purchases.configure(this, "public_sdk_key")
//..
// Automatically collect the $gpsAdId and $ip values
Purchases.sharedInstance.collectDeviceIdentifiers()
// Set the Appsflyer Id
Purchases.sharedInstance.setAppsflyerID(AppsFlyerLib.getInstance().getAppsFlyerUID(this));
You should make sure to set attributes after the Purchases SDK is configured, and before the first purchase occurs. It's safe to set this multiple times, as only the new/updated values will be sent to RevenueCat. If the AppsFlyer ID is not set, the customer's App User ID will be used instead.
If you are requesting the App Tracking permission through ATT to access the IDFA, you can call .collectDeviceIdentifiers()
again if the customer accepts the permission to update the $idfa
attribute in RevenueCat.
The AdSupport framework is required to access the IDFA parameter on iOS. Don't forget to import this into your project.
Make sure to remove all client-side tracking of revenue. Since RevenueCat will be sending events for all revenue actions, tracking purchases with the Appsflyer SDK directly can lead to double counting of revenue in Appsflyer.
(Optional) Send campaign data to RevenueCatβ
RevenueCat itself is not an attribution network, and can't determine which specific ad drove an install/conversion. However, if you're able to collect this information from another source, such as Appsflyer, it's possible to attach it to a Customer in RevenueCat using Attributes as well.
The below reserved key names can be used to optionally attach campaign data to a user. This data will then be sent through to other downstream analytics integrations and accessible via APIs and webhooks.
Key |
---|
$mediaSource |
$campaign |
$adGroup |
$ad |
$keyword |
$creative |
(Optional) Block sharing of eventsβ
To fulfill regulatory requirements like GDPR and CCPA, comply with user opt-out mechanisms, and other business reasons, you can limit sharing events with AppsFlyer's integrated partners and other third-party integrations. This is accomplished by setting the $appsflyerSharingFilter
Attribute, which will block the sharing of S2S events via postbacks/API with the specified partners.
This Attribute accepts the following formats:
- String with the word
all
- Array in the format
["partner_1", "partner_2"]
; stringifyβed as"[\"partner_1\", \"partner_2\"]"
If you are setting or editing the list of partner IDs through the dashboard, use the format partner_1,partner_2
For a list of partner IDs, please contact your AppsFlyer CSM or AppsFlyer support.
The $appsflyerSharingFilter
has a limit of 50 partner IDs. If your team encounters issues with this limit, please reach out to our RevenueCat Support via the dashboard Contact Us form in your account settings.
3. Send RevenueCat events into AppsFlyerβ
After you've set up the Purchases SDK to send attribution data from AppsFlyer to RevenueCat, you can "turn on" the integration and configure the event names from the RevenueCat dashboard.
- Navigate to your project in the RevenueCat dashboard and find the Integrations card in the left menu. Select + New
- Choose AppsFlyer from the Integrations menu
- Add your generic developer key if you use one AppsFlyer project for both iOS and android in the Developer Key field OR If you have specific developer keys for iOS and/or Android, add those in the associated UI fields
- If you have specific sandbox developer keys for iOS and/or Android, add those in the associated UI fields
- Enter the event names that RevenueCat will send or choose the default event names
- Select whether you want sales reported as gross revenue (before app store commission), or after store commission and/or estimated taxes.
4. Testing the Appsflyer integrationβ
You can test the Appsflyer integration end-to-end before going live. It's recommended that you test the integration is working properly for new users, and any existing users that may update their app to a new version.
Add a sandbox API key in the RevenueCat dashboardβ
Before you test the integration, make sure you have an Appsflyer API key set in the "Sandbox developer key" field in RevenueCat. This is required if you want the integration to trigger for sandbox purchases.
Make a sandbox purchase with a new userβ
Simulate a new user installing your app, and go through your app flow to complete a sandbox purchase.
Check that the required device data is collectedβ
Navigate the the Customer View for the test user that just made a purchase. Make sure that all of the required data from step 1 above is listed as attributes for the user.
Check that the Appsflyer event delivered successfullyβ
While still on the Customer View, click into the test purchase event in the Customer History and make sure that the AppsFlyer integration event exists and was delivered successfully.
Under the Events view, AppsFlyer displays in-app events according to the install date of the user. This means if you select Jan 1 through Jan 8, you'll see the events that were performed by users who installed within the selected date range.
Refer to AppsFlyer's docs for more information about this.
You should start seeing events from RevenueCat appear in AppsFlyer.