AppsFlyer Push API
Note that data generated by third-party data integration counts toward the cluster's data consumption
Summary
Interface overview
| Interface | Type | Granularity | Attribution | Cost | Revenue | Impressions | Clicks | Conversions |
|---|---|---|---|---|---|---|---|---|
| Push API | Callback | User level | ✅ | ✅ | ✅ | ✅ | ✅ |
Push API provides real-time AppsFlyer user-level data, including ad impression, click, install, and revenue data. Cost data may not be available due to AF platform data restrictions.
Before you start connecting AF data, make sure you have read the AE system user identification rules and understand how AE identifies a user by #distinct_id and #account_id
Integration process
- Integrate the AppsFlyer client SDK and the AE SDK, and set the AE user identification ID in the AF SDK
- Log in to the AE backend, go to the Third-party Integration module, add an AppsFlyer Push API plan, and complete the related configuration
- Log in to the AppsFlyer dashboard and complete the callback configuration
- Check whether the AE system receives the data successfully, and build reports
1. Client SDK configuration
The first step in integrating AppsFlyer data is to connect the AE SDK and the AF SDK on the client by setting the AE system's user identification ID in the AF SDK
1.1 Option 1 (automatic integration)
-
If you integrate the Android or iOS SDK:
- If the SDK version is 2.8.0~2.8.1, you can use this option directly
- If the SDK version is 2.8.2 or later, you also need to install the third-party data plugin. For details, see Android SDK third-party data and iOS SDK third-party data
-
If you integrate Unity SDK 2.4.0 or later, or Unreal SDK 1.5.0 or later, you can use this option directly
Note that the AE SDK initialization and the code that enables automatic integration must run before the AppsFlyer SDK is initialized. Follow these steps:
1. Initialize the AE SDK.
2. Call `enableThirdPartySharing` to set the distinct ID automatically.
3. Initialize the AppsFlyer SDK.
The following are code samples for the SDK on each platform:
- Android
- iOS
- Unity
- Unreal
// 1. Initialize the Android SDK
TDConfig config = TDConfig.getInstance(this, APPID, TE_SERVER_URL);
TDAnalytics.init(config);
// 2. Call the enableThirdPartySharing API to set ta_distinct_id in appsflyer events
TDAnalytics.enableThirdPartySharing(TDThirdPartyType.APPS_FLYER);
// 3. We strongly recommend that you use setCustomerUserId() to set the distinct ID again
String distinctId = TDAnalytics.getDistinctId();
AppsFlyerLib.getInstance().setCustomerUserId(distinctId);
// 4. Initialize the Appsflyer SDK
// ...
// 5. After registration or character creation, call login to set the account ID, then sync the data again (optional)
TDAnalytics.login("account_id");
TDAnalytics.enableThirdPartySharing(TDThirdPartyType.APPS_FLYER);
// 1. Initialize the iOS SDK
TDConfig *config = [[TDConfig alloc] init];
config.appid = appid;
config.serverUrl = url;
[TDAnalytics startAnalyticsWithConfig:config];
// 2. Call the enableThirdPartySharing API to set ta_distinct_id in appsflyer events
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeAppsFlyer];
// 3. We strongly recommend that you use setCustomerUserId() to set the distinct ID again
NSString *distinctId = [TDAnalytics getDistinctId];
[AppsFlyerLib shared].customerUserID = distinctId;
// 4. Initialize the Appsflyer SDK
// ...
// 5. After registration or character creation, call login to set the account ID, then sync the data again (optional)
[TDAnalytics login:@"account_id"];
[TDAnalytics enableThirdPartySharing:TDThirdPartyTypeAppsFlyer];
// 1. Initialize the Unity SDK
TDConfig config = new TDConfig("APPID","SERVER");
TDAnalytics.Init(config);
// 2. Call enableThirdPartySharing to set ta_distinct_id in AF events
TDAnalytics.EnableThirdPartySharing(TDThirdPartyType.APPSFLYER);
// 3. We strongly recommend that you use setCustomerUserId() to set the distinct ID again
var distinctId = TDAnalytics.GetDistinctId();
AppsFlyer.setCustomerUserId(distinctId);
// 4. Initialize the AF SDK
// ...
// 5. After registration or character creation, call login to set the account ID, then sync the data again (optional)
TDAnalytics.Login("account_id");
TDAnalytics.EnableThirdPartySharing(TDThirdPartyType.APPSFLYER);
// 1. Initialize the Unreal SDK
UTDAnalytics::Initialize();
// 2. Call enableThirdPartySharing to set ta_distinct_id in Appsflyer events
TArray<FString> EventTypeList;
EventTypeList.Emplace(TEXT("TAThirdPartyShareTypeAPPSFLYER"));
UTDAnalytics::EnableThirdPartySharing(EventTypeList, AppID);
// 3. Initialize the Appsflyer SDK
// ...
// 4. After registration or character creation, call login to set the account ID, then sync the data again (optional)
UTDAnalytics::Login("account_id", AppID);
UTDAnalytics::EnableThirdPartySharing(EventTypeList, AppID);
If you call the login() or identify() method of the AE SDK, call enableThirdPartySharing() again to sync the data.
If you also need to call the setAdditionalData() method of the AF SDK, calling it multiple times overwrites the previous parameters. In this case, you can use the following code to pass the parameters to the AE SDK, which concatenates and merges them internally. The following code is an Android SDK integration sample.
Map<String, Object> additionalData = new HashMap<>();
additionalData.put("af_test_key1", "test1");
additionalData.put("af_test_key2", "test2");
instance.enableThirdPartySharing(
TDThirdPartyShareType.TD_APPS_FLYER,
additionalData
);
This option works by automatically calling AF's setAdditionalData() method internally and passing in the distinct ID and account ID of the AE project.
1.2 Option 2 (manual integration)
For manual integration, you need to use the setAdditionalData() API in the AF SDK to set the distinct ID and account ID of the AE project.
Note that the AE SDK initialization and the setAdditionalData call must be completed before the AF SDK is initialized. Follow these steps:
1. Initialize the AE SDK.
2. Call `setAdditionalData` to set the distinct ID.
3. Initialize the AF SDK.
The following are manual integration code samples for the SDK on each platform:
- Android
- iOS
- Unity
// 1. Initialize the Android SDK
TDConfig config = TDConfig.getInstance(this, APPID, TE_SERVER_URL);
TDAnalytics.init(config);
// 2. Get the AE distinct ID, which corresponds to #distinct_id in AE
String distinctId = TDAnalytics.getDistinctId();
// 3. Set the distinct ID in the events collected by AF
HashMap<String,Object> CustomDataMap = new HashMap<>();
CustomDataMap.put("ta_distinct_id",distinctId);
AppsFlyerLib.getInstance().setAdditionalData(CustomDataMap);
// 4. We strongly recommend that you use setCustomerUserId() to set the distinct ID again
AppsFlyerLib.getInstance().setCustomerUserId(distinctId);
// 5. Initialize the AppsFlyer SDK
...
// 6. After registration or character creation, call login to set the account ID, then sync the data again (optional)
String accountId = "your_account_id";
instance.login(accountId);
HashMap<String,Object> CustomDataMap = new HashMap<>();
CustomDataMap.put("ta_distinct_id", distinctId);
CustomDataMap.put("ta_account_id",accountId);
AppsFlyerLib.getInstance().setAdditionalData(CustomDataMap);
// 1. Initialize the iOS SDK
TDConfig *config = [[TDConfig alloc] init];
config.appid = appid;
config.serverUrl = url;
[TDAnalytics startAnalyticsWithConfig:config];
// 2. Get the AE distinct ID, which corresponds to #distinct_id in AE
NSString *distinctId = [TDAnalytics getDistinctId];
// 3. Set the distinct ID in the events collected by AF
NSDictionary *distinctData = @{@"ta_distinct_id": distinctId};
[[AppsFlyerLib shared] setAdditionalData:distinctData];
// 4. We strongly recommend that you use setCustomerUserId() to set the distinct ID again
[AppsFlyerLib shared].customerUserID = distinctId;
// 5. Initialize the AF SDK
// ...
// 6. After registration or character creation, call login to set the account ID, then sync the data again (optional)
NSString *accountId = @"account_id";
[TDAnalytics login:accountId];
NSDictionary *customDataDict = @{
@"ta_distinct_id": distinctId,
@"ta_account_id": accountId
};
[[AppsFlyerLib shared] setAdditionalData:customDataDict];
// 1. Initialize the Unity SDK
TDConfig config = new TDConfig("APPID","SERVER");
TDAnalytics.Init(config);
// 2. Get the AE distinct ID, which corresponds to #distinct_id in AE
var distinctId = TDAnalytics.GetDistinctId();
// 3. Set the distinct ID in the events collected by AF
var distinctData = new Dictionary<string, string>
{
{ "ta_distinct_id" , distinctId}
};
AppsFlyer.setAdditionalData(distinctData);
// 4. We strongly recommend that you use setCustomerUserId() to set the distinct ID again
AppsFlyer.setCustomerUserId(distinctId);
// 5. Initialize the AF SDK
// ...
// 6. After registration or character creation, call login to set the account ID, then sync the data again (optional)
var accountId = "account_id";
TDAnalytics.Login(accountId);
var additionalData = new Dictionary<string, string>
{
{ "ta_distinct_id" , distinctId},
{"ta_account_id" , accountId}
};
AppsFlyer.setAdditionalData(additionalData);
After these settings, custom_data in the returned data carries the two fields ta_distinct_id and ta_account_id, and customer_user_id equals the distinct ID.
2. Plan configuration
After completing the SDK configuration, log in to the AE system backend and configure AppsFlyer in the Third-party Integration module. The image below shows the AppsFlyer configuration page:
2.1 User identification fields
Because AppsFlyer sends back user-level data, you need to set user identification rules for it, that is, the fields in the AF callback data that correspond to #distinct_id and #account_id. Based on this configuration, the AE system sets these fields as the user identification fields of the data when it converts the callback data.
If you configured the client SDK as described in the previous step of this document, use the following configuration:
- Account ID association field: custom_data.ta_account_id
- Distinct ID association field: customer_user_id,custom_data.ta_distinct_id
2.2 Event Data Configuration
After you turn on the Event Data Configuration switch, the data sent back (including activation events and in-app events) is written to the event table
We recommend that you enable event data ingestion. Note, however, that by default we receive all data sent back by AF. If too many event types are sent back, the event volume of the AE project grows excessively. Therefore, when you set up callbacks on the AF platform, we recommend that you select only the necessary events.
2.3 User Properties Configuration
By default, the AE system automatically writes the attribution fields in the data returned by AF to standardized user properties. The following are the fields written to user properties and their meanings:
| AppsFlyer field | Standardized field | Description |
|---|---|---|
| media_source | te_ads_object.media_source | Media source |
| campaign | te_ads_object.campaign_name | Campaign name |
| af_adset | te_ads_object.ad_group_name | Ad group name |
| af_ad | te_ads_object.ad_name | Ad name |
The default user property ingestion rules in earlier versions differ from the current ones, so be careful to distinguish them. To merge the old and new properties, you can use the custom property feature
To make changes, click Configure Rules to go to the ingestion rule configuration page, as shown below
Here, you can change which events user properties come from. If you don't want user properties to be written frequently, turn off Include all events and change Source event name to install. With this configuration, the AE system extracts the fields to write to user properties only from the install events sent back by AF. Integration method defaults to user_setOnce, which keeps only the first reported information.
Click the Property Mapping button to add fields to write to user properties. You can also click the Rule button on the left to add a new set of rules. For example, you may want to extract ad revenue from the monetization data returned by AF and write it to user properties with user_add to record each user's cumulative ad revenue.
To turn off user property ingestion, stop all rules:
2.4 End Point
End Point shows the address where the AE system receives AppsFlyer callback data. Copy this address directly, and enter it when you configure AF callbacks in the next step:
If no address is shown here, go to Project Settings → Settings → Implementation in the upper-right menu to configure the public network address. You can also click the TE Receiver Host URL link in the tip bar on the configuration page to go there. This address is the receiver URL configured in the AE SDK. After configuring it, return to the AppsFlyer configuration page and copy the address from End Point.
2.5 Event ingestion rules
- The time and time zone information in the event_time_selected_timezone field of the data is used: the time is used as #event_time, and the time zone is written as #zone_offset. If event_time_selected_timezone is empty, event_time is used as #event_time, and the time zone #zone_offset is set to 0
- The event name of the data is the event's name in AppsFlyer
- All other fields are stored
2.6 Standardized fields
The following event properties are standardized:
| Original field | Standardized field | Description |
|---|---|---|
| media_source | te_ads_object.media_source | Media source |
| monetization_network (ad monetization data) | te_ads_object.media_source | Monetization channel |
| campaign | te_ads_object.campaign_name | Campaign name |
| af_c_id | te_ads_object.campaign_id | Campaign ID |
| af_adset | te_ads_object.ad_group_name | Ad group name |
| ad_unit (ad monetization data) | te_ads_object.ad_group_name | Unit name of the monetization ad |
| af_adset_id | te_ads_object.ad_group_id | Ad group ID |
| af_ad | te_ads_object.ad_name | Ad name |
| af_ad_id | te_ads_object.ad_id | Ad ID |
| placement (ad monetization data) | te_ads_object.placement | Ad placement |
| af_cost_value | te_ads_object.cost | Campaign cost |
| af_cost_currency | te_ads_object.currency | Currency of the user acquisition spend |
| event_revenue | te_ads_object.revenue | Monetization revenue |
| event_revenue_currency (ad monetization data) | te_ads_object.currency | Currency of the monetization revenue |
| country_code | te_ads_object.country | Country or region code |
| platform | te_ads_object.platform | Platform, such as Android or iOS |
| app_id | te_ads_object.app_id | App ID |
| app_name | te_ads_object.app_name | App name |
3. AppsFlyer Push API configuration
After completing the configuration in the AE backend, log in to the AppsFlyer dashboard with an admin account, find the Push API section under Integration - API Access, and set the callback URL as follows:
-
Push API Version
- Select version 2.0
-
HTTP method
- The AE system supports both POST and GET callbacks. We recommend POST
-
Endpoint URL
- Get the address from the End Point field on the AppsFlyer configuration page in the AE system backend and paste it directly
-
Event Messages
- You need to select at least the Install event. If you want to send back other in-app events, select Install in-app events here and enter the names of the events to send back in In-app events
-
Message Fields
-
The message fields must include at least the following:
- Mobile attribution fields: media_source, channel, af_adset, af_ad, and so on
- User identification ID fields: custom_data, customer_user_id, event_value, and so on
- Fields to use as event properties or user properties, such as app_version and platform
- Event fields: event_time_selected_timezone
-
-
In-app events
- Select the events to send back as needed. To send them back, select Install in-app events in Event Messages
To send back Facebook data, you need to accept the Facebook data use agreement (Terms of Service) in the Facebook channel settings in the AF dashboard. Otherwise, Facebook user-level data can't be obtained.
4. Next steps
4.1 Check data ingestion
You can check on the Management page whether the callback events and user properties have been created.
You can also check whether the data has been stored by running analyses in analysis models, such as the Events Analysis model and the Composition Analysis model.
4.2 Recommended reports
Here are a few suggestions for building reports:
- In the Events Analysis model, use the AF callback data to build core ad delivery and ad monetization metrics, and create ad analysis reports
- In the Retention Analysis model, combine ad monetization from callback data with in-game payment events to calculate LTV including ad monetization at granularities such as media source and campaign
- In the Funnel Analysis model, add the install event to the new user conversion funnel, and analyze the conversion of users from different sources at granularities such as media source and campaign

