AppsFlyer
Step-by-step guide to send event data from RudderStack to AppsFlyer
AppsFlyer is an industry-leading mobile attribution and marketing analytics platform, provided as a Software-as-a-Service (SaaS). It offers intuitive dashboards, real-time data reports, and a unique deep linking technology to understand your customers better.
RudderStack supports AppsFlyer as a destination to which you can seamlessly send your customer data.
Find the open-source transformer code for this destination in our GitHub repository.
Getting started
Before configuring AppsFlyer as a destination in RudderStack, verify if the source platform is supported by AppsFlyer by referring to the table below:
Connection Mode | Web | Mobile | Server |
Device mode | - | Supported | - |
Cloud mode | Supported | Supported | Supported |
To know more about the difference between the cloud mode and device mode in RudderStack, refer to the RudderStack Connection Modes guide.
It is recommended to use the the cloud mode to send events to AppsFlyer in the following scenarios:
If you want to use RudderStack's Transformations feature
If you want to send server-side events
Once you have confirmed that the platform supports sending events to AppsFlyer, perform the steps below:
From your RudderStack dashboard, add the source. From the list of destinations, select AppsFlyer.
Assign a name to the destination and click on Next. You should then see the following screen:
Connection settings
The following connection settings are required to configure AppsFlyer as a destination in RudderStack:
AppsFlyer Dev Key: Enter your AppsFlyer Dev key here.
Refer to the FAQs section below for more information on obtaining the AppsFlyer dev key.
App ID: Enter 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.
If you are connecting a source other than Android or the Apple (iOS, watchOS, iPadOS, tvOS), you need to add a user transformation that adds the OS information required in the events.
Refer to the Connecting AppsFlyer to non-Android/iOS sources section below for more information.
Sharing Filter: By default, the value for this setting is set to
all
. You can use 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 on this field, refer to the AppsFlyer Help Center page.
Client-side Event Filtering: This setting is applicable only if you are sending events to AppsFlyer via the device mode.
Refer to the Client-side Event Filtering guide for more information on this setting.
Use native SDK to send events: By default, this setting is enabled. To send events via the cloud mode or device mode, you can toggle this setting on or off.
This setting is not applicable for the JavaScript (web) source as RudderStack does not support sending events to AppsFlyer via the web device mode. Refer to the connection modes table in the Getting started section above for more information.
Finally, click on Next to complete the configuration. AppsFlyer will be added and enabled as a destination in RudderStack.
Adding AppsFlyer to your project
Depending on your integration platform, follow the steps to add AppsFlyer to your project:
iOS Android React Native Cordova To add AppsFlyer to your iOS project:
Add the following line to your CocoaPods
Podfile
:After adding the dependency, you need to register the
RudderAppsflyerFactory
with yourRudderClient
initialization as afactory
ofRudderConfig
. To do this, run the following command to import theRudderAppsflyerFactory.h
file in yourAppDelegate.m
file:Starting from AppsFlyer iOS device mode version
2.0.0
and above, the RudderStack SDK does not automatically initialize the AppsFlyer SDK. You need to initialize the AppsFlyer SDK as shown:Then, change the iOS SDK initialization to the following:
To add AppsFlyer to your Android project:
Add the
mavenCentral()
repository, as shown:Then, add the following lines to your
app/build.gradle
file underdependencies
:Starting from AppsFlyer Android device mode version
2.0.0
and above, the RudderStack SDK does not automatically initialize the AppsFlyer SDK. You need to initialize the AppsFlyer SDK as shown:Finally, change the SDK initialization in your
Application
class, as shown:
To add AppsFlyer to your React Native project:
Add the RudderStack-AppsFlyer module to your app using the following command:
For AppsFlyer React Native device mode version less than 1.1.0, follow the below step:
Import the module and add it to your SDK initialization code, as shown:
For AppsFlyer React Native device mode version 1.1.0 or above, follow these steps:
Initialize the AppsFlyer SDK as shown:
As seen above, the properties
onInstallConversionDataListener
andonDeepLinkListener
are set totrue
in thesetOptions
API to get access to the conversion as well as the attribution data.Then, register the callbacks with the listeners, as shown:
Depending on the React Native components you are using, you can trigger an appropriate method, for example:
If it's a class-based component, trigger the
remove()
method incomponentWillUnMount()
, as shown:If it's a functional component, trigger the
useEffect()
hook, as shown:
Finally, open
AppDelegate.m
in theios
folder of your app and include the following snippet:
To add AppsFlyer to your Cordova project, follow these steps:
Navigate to the root folder of your application and run the following command:
Add the platforms that you want to target for your app:
Run the following command to build the project for all the platforms:
Finally, add the following code in the
onDeviceReady()
function of your home page to initialize the SDK, as shown:Make sure to use the
await
keyword with theinitialize
call.
Connecting AppsFlyer to non-Android/iOS sources
AppsFlyer supports all the RudderStack sources in addition to Android and iOS. However, you will need to add a transformation to the destination by following these steps:
Go to your RudderStack dashboard.
In the left navigation bar, select Transformations followed by New transformation.
In the Transformation Settings window, assign a Name and Description for the transformation.
Then, add the following function:
Click on Save to save the transformation.
Finally, configure your AppsFlyer destination and connect it to the transformation in the Choose an existing transformation window, as shown:
If you have already configured your AppsFlyer destination, navigate to the Transformation option, as shown:
Click on Add a transformation and select the transformation you created above.
Sending events via the RudderStack cloud mode
We recommend sending events to AppsFlyer via the cloud mode only in the following two scenarios:
To use RudderStack's Transformations feature to transform your events
To send server-side events
To send events to AppsFlyer, you need the AppsFlyer ID generated by the Appsflyer SDK that is integrated with your app.
Refer to the Obtaining the AppsFlyer ID section below for more information.
Once you obtain the AppsFlyer ID, you can send events to AppsFlyer via the cloud mode by including the externalId
key within your events' context
. The format of externalId
is as shown:
The following table lists the externalId
fields:
Field | Description |
---|---|
| Your AppsFlyer ID. |
| The type of |
Obtaining the 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, refer to 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:
iOS Android React Native
Identify
The identify
call sets userId
through the setCustomerUserId
method of AppsFlyerLib
.
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, as shown:
Track
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 event | AppsFlyer event |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 property name | AppsFlyer property name |
---|---|
|
|
|
|
|
|
|
|
|
|
| RudderStack formulates this list as per the List View specification and passes it to the property |
|
|
|
|
|
|
A sample track
call for an iOS app is shown below:
Screen
For all the 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:
For iOS: Advertisement ID documentation
For Android: Advertisement ID documentation
You can find the advertising ID in your event's context.device.advertisementId
.
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
.
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 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. Refer to the Sending events via the RudderStack cloud mode section for more information on setting the appsflyerExternalId
.
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.
FAQs
Where do I get 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, refer to 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:
How do I get the AppsFlyer ID to send events from my mobile sources via the RudderStack cloud mode?
To send events to AppsFlyer via the 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 via 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:
iOS Android React Native
Once you obtain the AppsFlyer ID, you can send events via the cloud mode by by including the externalId
key within your events' context
. For more information, refer to the Sending events via the RudderStack cloud mode section above.
Contact us
For queries on any of the sections covered in this guide, you can contact us or start a conversation in our Slack community.
Last updated