AppsFlyer
This guide describes how to add and configure AppsFlyer integration.
AppsFlyer is the world's leading mobile attribution & marketing analytics platform, helping app marketers around the world make better decisions.

How does Integration Work?

This integration works in two ways.

1. Receive Attribution Data from AppsFlyer

Once you successfully configured AppsFlyer integration, Apphud will receive attribution data from it. You can view this data on user's page:

2. Send Subscription Events to AppsFlyer

Apphud can also send all subscription events to AppsFlyer. So you could view these events in AppsFlyer dashboard and AppsFlyer could pass this data to their partners. This will help to measure efficiency of your ad campaigns.

How to Add Integration?

Step 1
2
3
4
5
✅ 6
At Apphud go to "Integrations" section and add AppsFlyer:
Paste AppsFlyer Dev Key into "Developer key" field:
You may have one more app created in AppsFlyer used for testing purposes not to mix test and live data. If you have such app, paste test App Store app ID or test Package Name into "Test App ID" field.
Information about how to create app for debug purposes can be found in AppsFlyer documentation.
You can enter your custom event names or disable some.
You can use AppsFlyer built-in rich events names. View more information here.
From AppsFlyer help: each network has its own limitations regarding the permitted characters in event names. To avoid problems, use only lower-case alpha-numeric characters (a-z and 0-9) for your in-app event names.
Enable integration and Save changes:

Pass Attribution Data to Apphud (required)

Send attribution data to Apphud (or at least Appsflyer ID). Implement delegate methods or listener.
Swift
Objective-C
Kotlin
1
AppsFlyerLib.shared().delegate = self
2
...
3
4
func onConversionDataSuccess(_ conversionInfo: [AnyHashable : Any]!) {
5
Apphud.addAttribution(data: conversionInfo, from: .appsFlyer, identifer: AppsFlyerLib.shared().getAppsFlyerUID()) { _ in }
6
}
7
8
func onConversionDataFail(_ error: Error) {
9
Apphud.addAttribution(data: ["error" : error.localizedDescription], from: .appsFlyer, identifer: AppsFlyerLib.shared().getAppsFlyerUID()) { _ in }
10
}
Copied!
1
[AppsFlyerTracker sharedTracker].delegate = self;
2
...
3
4
- (void)onConversionDataSuccess:(NSDictionary *)conversionInfo{
5
[Apphud addAttributionWithData:conversionInfo from:ApphudAttributionProviderAppsFlyer identifer:AppsFlyerTracker.sharedTracker.getAppsFlyerUID callback:^(BOOL callback) {}];
6
}
7
8
- (void)onConversionDataFail:(NSError *)error{
9
[Apphud addAttributionWithData:@{@"error" : error.localizedDescription} from:ApphudAttributionProviderAppsFlyer identifer:AppsFlyerTracker.sharedTracker.getAppsFlyerUID callback:^(BOOL result){}];
10
}
Copied!
1
val listener = object : AppsFlyerConversionListener {
2
override fun onConversionDataSuccess(map: MutableMap<String, Any>?) {
3
val uid = AppsFlyerLib.getInstance().getAppsFlyerUID(app)
4
Apphud.addAttribution(ApphudAttributionProvider.appsFlyer, map, uid)
5
}
6
override fun onConversionDataFail(p0: String?) {
7
val uid = AppsFlyerLib.getInstance().getAppsFlyerUID(app)
8
Apphud.addAttribution(ApphudAttributionProvider.appsFlyer, null, uid)
9
}
10
}
11
AppsFlyerLib.getInstance().init("APPSFLYER_DEV_KEY", listener, this)
12
AppsFlyerLib.getInstance().startTracking(this)
13
// initialize Apphud
14
val uid = AppsFlyerLib.getInstance().getAppsFlyerUID(this)
15
Apphud.addAttribution(ApphudAttributionProvider.appsFlyer, null, uid)
Copied!
While configuring integration you can also choose between sending revenue as sales or proceeds (without Apple / Google 15%-30% commission).
You can read more how Apple and Google calculate their commissions here and here.
In order to receive AppsFlyer attribution data from Facebook, you should accept Facebook’s "Advanced Mobile Measurement Agreement" using this link.

Request IDFA Consent (required)

Starting iOS 14.5 access to IDFA requires user consent. You should request IDFA manually using AppTrackingTransparency framework and pass it to Apphud. Read more here.

Events Cheat Sheet

This is a list of all possible events and their parameters that are being sent to AppsFlyer.
You can read more about subscription events here and parameters here.
Trial
Cancellations
Introductory Offer
Regular
Promo Offer
Other Events

Trial period started

Default event name: apphud_trial_started
Parameters:
    af_content_id: String

Successful conversion from trial period to regular subscription

Default event name: apphud_trial_converted
Parameters:
    af_content_id: String
    af_revenue: Float
    af_currency: String

Failed conversion from trial period to regular subscription

Default event name: apphud_trial_expired
Parameters:
    af_content_id: String
    reason: String (iOS)

Trial Canceled

Default event name: apphud_trial_canceled
Parameters:
    af_content_id: String

Subscription Canceled

Default event name: apphud_subscription_canceled
Parameters:
    af_content_id: String

Autorenew disabled (Deprecated)

Default event name: apphud_autorenew_disabled
Parameters:
    af_content_id: String

Autorenew enabled

Default event name: apphud_autorenew_enabled
Parameters:
    af_content_id: String

Introductory offer started

Default event name: apphud_intro_started
Parameters:
    af_content_id: String
    af_revenue: Float
    af_currency: String
    offer_type: String (iOS)
    unit: String (iOS)
    units_count: Integer (iOS)

Introductory offer renewed

Default event name: apphud_intro_renewed
Parameters:
    af_content_id: String
    af_revenue: Float
    af_currency: String
    offer_type: String (iOS)
    unit: String (iOS)
    units_count: Integer (iOS)

Successful conversion from introductory offer to regular subscription

Default event name: apphud_intro_converted
Parameters:
    af_content_id: String
    af_revenue: Float
    af_currency: String
    offer_type: String (iOS)

Failed conversion from introductory offer to regular subscription or failed renew

Default event name: apphud_intro_expired
Parameters:
    af_content_id: String
    reason: String (iOS)
    offer_type: String (iOS)

Refund during introductory offer

Default event name: apphud_intro_refunded
Parameters:
    af_content_id: String
    af_revenue: Float
    af_currency: String
    reason: String (iOS)
    offer_type: String (iOS)

Subscription started

Default event name: apphud_subscription_started
Parameters:
    af_content_id: String
    af_revenue: Float
    af_currency: String

Subscription renewed

Default event name: apphud_subscription_renewed
Parameters:
    af_content_id: String
    af_revenue: Float
    af_currency: String

Subscription expired

Default event name: apphud_subscription_expired
Parameters:
    af_content_id: String
    reason: String (iOS)

Subscription refunded

Default event name: apphud_subscription_refunded
Parameters:
    af_content_id: String
    af_revenue: Float
    af_currency: String
    reason: String (iOS)

Promotional offer started

Default event name: apphud_promo_started
Parameters:
    af_content_id: String
    offer_id: String (iOS)
    af_revenue: Float
    af_currency: String
    offer_type: String (iOS)
    unit: String (iOS)
    units_count: Integer (iOS)

Promotional offer renewed

Default event name: apphud_promo_renewed
Parameters:
    af_content_id: String
    offer_id: String (iOS)
    af_revenue: Float
    af_currency: String
    offer_type: String (iOS)
    unit: String (iOS)
    units_count: Integer (iOS)

Successful conversion from promotional offer to regular subscription

Default event name: apphud_promo_converted
Parameters:
    af_content_id: String
    offer_id: String (iOS)
    af_revenue: Float
    af_currency: String
    offer_type: String (iOS)

Failed conversion from promotional offer to regular subscription or failed renew

Default event name: apphud_promo_expired
Parameters:
    af_content_id: String
    offer_id: String (iOS)
    reason: String (iOS)
    offer_type: String (iOS)

Refund during promotional offer

Default event name: apphud_promo_refunded
Parameters:
    af_content_id: String
    offer_id: String (iOS)
    af_revenue: Float
    af_currency: String
    reason: String (iOS)
    offer_type: String (iOS)

Non renewing purchase

Default event name: apphud_non_renewing_purchase
Parameters:
    af_content_id: String
    af_revenue: Float
    af_currency: String

Non renewing purchase refunded

Default event name: apphud_non_renewing_purchase_refunded
Parameters:
    af_content_id: String
    af_revenue: Float
    af_currency: String
    reason: String (iOS)

Billing Issue

Default event name: apphud_billing_issue
Parameters:
    af_content_id: String

Billing issue Resolved

Default event name: [Apphud] billing_issue_resolved
Parameters:
    af_content_id: String

Testing AppsFlyer with Sandbox Purchases

If you want sandbox purchases not to mix with your production purchases in AppsFlyer, you should create a Test App ID.
    Create a new app in AppsFlyer as described here.
    Enter newly created Test App ID toTest App ID field in AppsFlyer Integration page in Apphud.
    iOS: Change App ID to a Test App ID when initializing AppsFlyer SDK:
1
AppsFlyerLib.shared().appleAppID = "0123456789"
Copied!
    Android: Change Package Name to a Test Package Name.

Testing Subscription Events

Step 1
2
3
4
✅ 5
Please make sure AppsFlyer SDK is properly integrated in your app and AppsFlyer integration is configured in Apphud.
Re-install the app and launch again.
Make a test purchase in your app.
You can read more about testing purchases here.
You will see attribution data in user's page:
Open "Events" tab in AppsFlyer and you will see Apphud events there:
Last modified 7mo ago