AppsFlyer Destination

Send your event data from RudderStack to AppsFlyer.

AppsFlyer is a mobile attribution and marketing analytics platform. It offers intuitive dashboards, real-time data reports, and a unique deep linking technology to understand your customers better.

Find the open source code for this destination in the GitHub repository.

Connection compatibility

Destination info
  • Status: Generally Available
  • Supported sources: Android, iOS , Web, Unity, AMP , Cloud, Warehouse, React Native , Flutter, Cordova, Shopify
  • Refer to it as AF in the Integrations object.

Connection modes
SourceCloud modeDevice modeHybrid mode
AMPsupportednot supportednot supported
Androidsupportedsupportednot supported
Cloudsupportednot supportednot supported
Cordovasupportedsupportednot supported
Fluttersupportedsupportednot supported
iOSsupportedsupportednot supported
React Nativesupportedsupportednot supported
Shopifysupportednot supportednot supported
Unitysupportednot supportednot supported
Warehousesupportednot supportednot supported
Websupportednot supportednot supported
Supported message types
SourceIdentifyPageTrackScreenGroupAlias
Cloud mode
Supported sourcesnot supportedsupportedsupportedsupportednot supportednot supported
Device mode
Androidsupportednot supportedsupportedsupportednot supportednot supported
Cordovasupportednot supportedsupportedsupportednot supportednot supported
Fluttersupportednot supportedsupportedsupportednot supportednot supported
iOSsupportednot supportedsupportedsupportednot supportednot supported
React Nativesupportednot supportedsupportedsupportednot supportednot supported
warning

RudderStack recommends sending events to AppsFlyer in cloud mode only in the following scenarios:

  • To transform your events using a transformation.
  • To send server-side events.

Get started

Once you have confirmed that the source platform supports sending events to AppsFlyer, follow these steps:

  1. From your RudderStack dashboard, add a source. Then, from the list of destinations, select AppsFlyer.
  2. Assign a name to the destination and click Continue.

Connection settings

info

To connect a source other than Android or Apple (iOS, watchOS, iPadOS, tvOS), you need to add a user transformation that adds the OS information required in the events.

See Connect AppsFlyer to non-Android/iOS sources for more information.

SettingDescription
Authorization TypeSelect the authorization type from the dropdown:

  • Authorization with dev key: In the AppsFlyer Dev Key field, enter the AppsFlyer dev key.
  • Authorization with server to server key: In the AppsFlyer server to server Key field, enter the server to server token.
App IDEnter your Apple or Android app ID.

  • Android App ID: This the application ID used in your app/build.gradle file.
  • Apple App ID: This is the iTunes Application ID and it is mandatory for the iOS applications.
Use Rich Event NamesTurn on this setting to include your app’s screen or page name in the screen or page event names.
Add properties at root in eventValueTurn on this setting to include the custom properties at the root level of eventValue field. Otherwise, RudderStack sends them in the properties field inside eventValue.
Sharing FilterUse this setting to meet any regulatory requirements like GDPR and CCPA, complying with user opt-out mechanisms, and for any other business use-case. For more information, see the AppsFlyer Help Center.

By default, the value for this setting is set to all.
Client-side Event FilteringThis setting is applicable only if you are sending events to AppsFlyer in device mode. It lets you specify which events should be blocked or allowed to flow through to AppsFlyer. See the Client-side Event Filtering guide for more information.
Status Callback URLsSpecify the callback URLs to be used for user deletion requests. You can provide multiple callback URLs by separating them by a comma.
API TokenEnter your AppsFlyer API token.

Note: For user deletion, you must specify both Status Callback URLs and API Token.
Use device-mode to send eventsTurn on this setting to send events from the Android/iOS SDK to Appsflyer in device mode.

Add device mode integration

info
Starting from v2.3.0 of AppsFlyer Android and iOS device mode, RudderStack supports sending all the custom properties of track events, along with the standard properties.

Once you add AppsFlyer as a destination in the RudderStack dashboard, follow these steps to add it to your project depending on your integration platform:

Connect AppsFlyer to non-Android/iOS sources

AppsFlyer supports all RudderStack sources in addition to Android and iOS. However, you need to add a transformation that adds the OS information to the event payload.

  1. Add a transformation as shown below:
export function transformEvent(event, metadata) {
  event.context.os = {
    name: "android",
    version: "8.1.0"
  };
  return event;
}
  1. Save the transformation and connect it to your AppsFlyer destination in the RudderStack dashboard.

Send events in cloud mode

warning

RudderStack recommends sending events to AppsFlyer in cloud mode only in the following scenarios:

  • To transform your events using a transformation.
  • To send server-side events.

To send events to AppsFlyer in cloud mode, you need the AppsFlyer ID generated by the Appsflyer SDK integrated with your app.

Once you obtain the AppsFlyer ID, you can send events to AppsFlyer in cloud mode by including the externalId key within your events’ context. The format of externalId is as shown:

"externalId": [
  {
    "id": "AppsFlyer_ID",
    "type": "appsflyerExternalId"
  }
]

The following table lists the externalId fields:

FieldDescription
idYour AppsFlyer ID.
typeThe type of externalId. This must always be set to appsflyerExternalId.

Get AppsFlyer ID

As mentioned above, the AppsFlyer ID is generated by the Appsflyer SDK integrated with your app.

  • If the AppsFlyer SDK is directly loaded on your app, see this AppsFlyer documentation to obtain the AppsFlyer ID.
  • If your AppsFlyer SDK is loaded through RudderStack (device mode integration), then you can obtain the AppsFlyer ID by including the code snippet in your app, depending on your platform of integration:

Identify

The identify call sets userId through the setCustomerUserId method of AppsFlyerLib.

info
RudderStack supports the identify calls only in the device mode.

RudderStack sets email from the event traits to AppsFlyer using the native SDK’s setUserEmails method:

[[RSClient sharedInstance] identify:@"developer_user_id"
      traits:@{@"email": @"bar@foo.com"}];

Delete user

warning
To delete a user in AppsFlyer, you must configure the Status Callback URLs and API Token settings in the RudderStack dashboard.

You can delete a user in AppsFlyer using the Suppression with Delete regulation of the RudderStack User Suppression API.

info

To delete a user, you must specify their userId in the event. Additionally, you can specify any of the following in the event:

A sample regulation request body for deleting a user in AppsFlyer is shown below:

Track

warning
This destination does not strictly adhere to the RudderStack Ecommerce Event Spec.

RudderStack’s track call is mapped to the standard AppsFlyer events wherever possible.

The following table lists the event mapping from RudderStack to AppsFlyer:

RudderStack eventAppsFlyer event
Products Searchedaf_search
Product Viewedaf_content_view
Product List Viewedaf_list_view
Product Added to Wishlistaf_add_to_wishlist
Product Addedaf_add_to_cart
Checkout Startedaf_initiated_checkout
Order Completedaf_purchase
Product Removedremove_from_cart
first_purchasefirst_purchase
Promotion Viewedaf_ad_view
Promotion Clickedaf_ad_click
Payment Info Enteredaf_add_payment_info
Product Sharedaf_share
Cart Sharedaf_share
Product Reviewedaf_rate

For any event not present in the above table, RudderStack makes the following changes to the event name before sending it to AppsFlyer via the native SDK:

  • Converting the entire event name to lower case
  • Replacing any space with an underscore

Along with the above event mapping, RudderStack also maps the event properties to the corresponding AppsFlyer event properties, as shown below:

RudderStack propertyAppsFlyer property
queryaf_search_string
priceaf_price
product_idaf_content_id
categoryaf_content_type
currencyeventCurrency
productsRudderStack formulates this list as per the List View specification and passes it to the property af_content_list.
quantityaf_quantity
order_idaf_receipt_id
revenueaf_revenue

A sample track call for an iOS app is shown below:

[[RSClient sharedInstance] track:@"Accepted Terms of Service"
    properties:@{
        @"foo": @"bar",
        @"foo_int": @134
}];

Screen

For all screen calls sent from the SDK, RudderStack calls AppsFlyer’s trackEvent method with screen as the event name. All the event properties are passed to AppsFlyer without any modification.

For the automatically recorded screen calls, RudderStack obtains a Boolean property called automatic.

Advertising ID

RudderStack utilizes the advertising ID for the AppsFlyer destination if it is set as per the following specifications:

You can find the advertising ID in your event’s context.device.advertisingId.

ATTrackingManager

If the ATTrackingManager.trackingAuthorizationStatus is passed according to ATTrackingManager authorization consent, RudderStack will utilize it for the AppsFlyer destination.

You can find trackingAuthorizationStatus in your event’s context.device.attTrackingStatus.

Debugging

RudderStack sets the logLevel in AppsFlyer based on the logLevel set for the RudderClient. If it is set to DEBUG or more, RudderStack sets the logLevel to VERBOSE for AppsFlyer.

For anything below that, RudderStack sets the logLevel to NONE for AppsFlyer.

Error messages

This section covers some of the possible error messages you may encounter while using this integration.

Invalid platform / required androidAppId / appleAppId missing

This error occurs when either the OS Name or your respective App ID is not set. You can set the App ID in your connection settings.

The SDK automatically sets the OS Name and it can be found in context.os.name.

Appsflyer ID is not set. Rejecting the event.

This error occurs when the appsflyerExternalId is not set. See the Sending events in the RudderStack cloud mode section for more information on setting the appsflyerExternalId.

FAQ

Where can I find the AppsFlyer dev key?

You can find the AppsFlyer Dev Key by logging into your AppsFlyer account and navigating to the Apps Settings page in your dashboard. For more information, see this AppsFlyer Help Center page.

I get an error saying “Build input file cannot be found” for iOS device mode. What should I do?

The latest AppsFlyer SDK requires XCode 12. Make sure you meet this requirement. You may have to downgrade your AppsFlyer SDK to build with a lower version of XCode.

You can declare the pod version in your Podfile as shown:

pod 'Rudder-Appsflyer',' 1.0.0'

How do I get the AppsFlyer ID to send events from my mobile sources in cloud mode?

To send events to AppsFlyer in cloud mode, you first need to obtain the AppsFlyer ID generated by the Appsflyer SDK.

You can get this ID by either directly loading the native AppsFlyer SDK on your app, or loading it in RudderStack (device mode integration).

In case of a device mode integration, include the following code snippet (depending on your platform of integration) in your app to get the AppsFlyer ID:

Once you obtain the AppsFlyer ID, you can send events in cloud mode by by including the externalId key within your events’ context. For more information, see the Send events in cloud mode section above.



Questions? Contact us by email or on Slack