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 exciting features to understand your customers better, through intuitive dashboards, real-time data reports, and a unique deep linking technology.

RudderStack allows you to configure AppsFlyer as a destination and send your event data to it directly.

Getting Started

To enable sending data to AppsFlyer, you will first need to add it as a destination to the source from which you are sending your event data. Once the destination is enabled, events from our SDK will start flowing to AppsFlyer.

Before configuring your source and destination on the RudderStack, please 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

-

-

-

Once you have confirmed that the platform supports sending events to AppsFlyer, perform the steps below:

Please follow our guide on How to Add a Source and Destination in RudderStack to add a source and destination in RudderStack.

  • Give a name to the destination and click on Next. You should then see the following screen:

AppsFlyer Connection Settings in RudderStack
  • Enter the AppsFlyer Dev Key.

  • Apple App ID is the iTunes Application ID, and it is a mandatory for iOS applications.

  • Turn on the Use native SDK to send events button so that we can send data to AppsFlyer using the native SDK.

  • Click on Next to complete the configuration.

AppsFlyer should now be added and enabled as a destination in RudderStack.

Adding AppsFlyer to your project

Depending on your platform of integration, follow these steps below to add AppsFlyer to your project:

iOS
Android
ReactNative
iOS

To add AppsFlyer to your iOS project:

  • Add the following line to your CocoaPods Podfile

pod 'Rudder-Appsflyer'
  • After adding the dependency, you must register the RudderAppsflyerFactory with your RudderClient initialization as a factory of RudderConfig. To do this, run the following command to import the RudderAppsflyerFactory.h file in your AppDelegate.m file.

#import <Rudder-Appsflyer/RudderAppsflyerFactory.h>
  • Then, change the SDK initialization to the following:

RSConfigBuilder *builder = [[RSConfigBuilder alloc] init];
[builder withDataPlaneUrl:DATA_PLANE_URL];
[builder withTrackLifecycleEvens:YES];
[builder withRecordScreenViews:YES];
[builder withFactory:[RudderAppsflyerFactory instance]];
[builder withLoglevel:RSLogLevelDebug];
[RSClient getInstance:WRITE_KEY config:[builder build]];
Android

To add AppsFlyer to your Android project:

  • Add the repository as shown:

repositories {
maven { url "https://dl.bintray.com/rudderstack/rudderstack" }
}
  • Add the following line to your app/build.gradle file under dependencies section:

implementation 'com.rudderstack.android.sdk:core:1.0.1'
implementation 'com.rudderstack.android.integration:appsflyer:0.1.1'
  • Finally change the initialization of your RudderClient in your Application class.

val rudderClient: RudderClient = RudderClient.getInstance(
this,
<WRITE_KEY>,
RudderConfig.Builder()
.withDataPlaneUrl(<DATA_PLANE_URL>)
.withFactory(AppsFlyerIntegrationFactory.FACTORY)
.build()
)
ReactNative

To add AppsFlyer to your ReactNative project:

  • Add the RudderStack-AppsFlyer module to your app using :

    npm install @rudderstack/rudder-integration-appsflyer-react-native
    // OR //
    yarn add @rudderstack/rudder-integration-appsflyer-react-native
  • Import the module you added above and add it to your SDK initialization code in the following manner:

    import rudderClient from '@rudderstack/rudder-sdk-react-native';
    import appsflyer from "@rudderstack/rudder-integration-appsflyer-react-native";
    const config = {
    dataPlaneUrl: <DATAPLANE_URL>,
    trackAppLifecycleEvents: true,
    withFactories: [appsflyer]
    };
    rudderClient.setup(<WRITE_KEY>, config);

Identify

The identify call from RudderStack sets the userId through the setCustomerUserId method from AppsFlyerLib .

RudderStack sets the email from RudderTraits to AppsFlyer using the setUserEmails method from the native SDK.

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

Track

The track call from RudderStack is mapped to the appropriate standard events of AppsFlyer wherever possible.

We map the events as per the following table:

RudderStack Event

AppsFlyer Event

Products Searched

af_search

Product Viewed

af_content_view

Product List Viewed

af_list_view

Product Added to Wishlist

af_add_to_wishlist

Product Added

af_add_to_cart

Checkout Started

af_initiated_checkout

Order Completed

af_purchase

Product Removed

remove_from_cart

Also, for any event with name not matching with the table above, RudderStack makes the following changes to the event name:

  • Convert the entire event name to lower case

  • Replace <space> with <underscore>

After these steps, RudderStack passes the event to AppsFlyer via the native SDK, along with the properties for that event.

Along with the above event mapping, the event property mapping is done as well, as shown:

RudderStack Property Name

AppsFlyer Property Name

query

af_search_string

price

af_price

product_id

af_content_id

category

af_content_type

currency

af_currency

products

We formulate the list as per List View specification and pass it to the property af_content_list

quantity

af_quantity

order_id

af_receipt_id

A Sample track call for an iOS application will look like the below.

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

Screen

For all the screen calls from the SDK, RudderStack calls the trackEvent method of the AppsFlyer SDK with the eventName as screen . Then, all the properties are passed to AppsFlyer as is.

RudderStack performs the same task for the automatically recorded screen calls as well. For those calls, a Boolean property called automatic is obtained in the properties.

Debugging

We set the logLevel in AppsFlyer based on the logLevel set for the RudderClient. If it is set for 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.

Contact Us

If you come across any issues while configuring AppsFlyer with RudderStack, please feel free to contact us or start a conversation on our Discord channel. We will be happy to help you.