LogoLogo
  • Contributing to RudderStack
  • Destination_Name
  • LICENSE
  • RudderStack Docs
  • docs
    • FAQ
    • Identity Resolution
    • Home
    • cloud-extract-sources
      • ActiveCampaign Source
      • Bing Ads
      • Chargebee
      • Common Settings
      • Facebook Ads
      • Freshdesk
      • Google Ads Source
      • Google Analytics
      • Google Search Console
      • Google Sheets
      • Cloud Extract Sources
      • Intercom v2
      • Intercom
      • Mailchimp
      • Marketo
      • Mixpanel
      • NetSuite
      • Pipedrive
      • QuickBooks
      • Salesforce Pardot
      • Sendgrid Source
      • Stripe Source
      • Xero
      • Zendesk Chat
      • Zendesk
      • hubspot
        • HubSpot Data Model and Schema Information
        • HubSpot
      • salesforce
        • Salesforce
        • Schema Comparison: RudderStack vs. Segment
    • connections
      • Connection Modes: Cloud Mode vs. Device Mode
    • data-governance
      • Data Governance
      • RudderTyper
      • Data Governance API
      • RudderTyper
      • tracking-plans
        • Tracking Plans
        • Tracking Plan Spreadsheet
    • data-warehouse-integrations
      • Amazon Redshift
      • Azure Data Lake
      • Azure Synapse
      • ClickHouse
      • Databricks Delta Lake
      • Google Cloud Storage Data Lake
      • Google BigQuery
      • Identity Resolution
      • Warehouse Destinations
      • Microsoft SQL Server
      • PostgreSQL
      • Amazon S3 Data Lake
      • Snowflake
      • FAQ
      • Warehouse Schema
    • destinations
      • Destinations
      • Webhooks
      • advertising
        • Bing Ads
        • Criteo
        • DCM Floodlight
        • Facebook App Events
        • Facebook Custom Audience
        • Facebook Pixel
        • Google Ads (gtag.js)
        • Google AdWords Enhanced Conversions
        • Google Adwords Remarketing Lists (Customer Match)
        • Advertising
        • LinkedIn Insight Tag
        • Lotame
        • Pinterest Tag
        • Reddit Pixel
        • Snap Pixel
        • TikTok Ads
      • analytics
        • Amplitude
        • AWS Personalize
        • Chartbeat
        • Firebase
        • FullStory
        • Google Analytics 360
        • Google Analytics
        • Heap.io
        • Hotjar
        • Analytics
        • Indicative
        • Keen
        • Kissmetrics
        • Kubit
        • Lytics
        • Mixpanel
        • Pendo
        • PostHog
        • Quantum Metric
        • Singular
        • adobe-analytics
          • Adobe Analytics Heartbeat Measurement
          • Mobile Device Mode Settings
          • Web Device Mode Settings
          • E-commerce Events
          • Adobe Analytics
          • Setting Up Adobe Analytics in RudderStack
        • google-analytics-4
          • Cloud Mode
          • Device Mode
          • Google Analytics 4
          • Setting up Google Analytics 4
        • profitwell
          • ProfitWell
          • Cloud Mode
          • Device Mode
      • attribution
        • Adjust
        • AppsFlyer
        • Branch
        • Attribution
        • Kochava
        • TVSquared
      • business-messaging
        • Business Messaging
        • Intercom
        • Kustomer
        • Slack
        • Trengo
      • continuous-integration
        • Visual Studio App Center
        • Continuous Integration
      • crm
        • Delighted
        • HubSpot
        • CRM
        • Salesforce
        • Variance
        • Zendesk
      • customer-data-platform
        • Customer Data Platform
        • Segment
      • error-reporting
        • Bugsnag
        • Error Reporting
        • Sentry
      • marketing
        • ActiveCampaign
        • AdRoll
        • Airship
        • Appcues
        • Autopilot
        • Blueshift
        • Braze
        • CleverTap
        • Customer.io
        • Gainsight PX
        • Gainsight
        • Marketing
        • Iterable
        • Klaviyo
        • Leanplum
        • Mailchimp
        • Marketo Lead Import
        • Marketo
        • MoEngage
        • Ometria
        • Pardot
        • Post Affiliate Pro
        • Qualtrics
        • SendGrid
        • Salesforce Marketing Cloud
        • Userlist
        • drip
          • Cloud Mode
          • Device Mode
          • Drip
          • Setting Up Drip in RudderStack
      • productivity
        • Google Sheets
        • Productivity
      • storage-platforms
        • Amazon S3
        • DigitalOcean Spaces
        • Google Cloud Storage
        • Storage Platforms
        • Azure Blob Storage
        • MinIO
        • Redis
      • streaming-platforms
        • Amazon EventBridge
        • Amazon Kinesis Firehose
        • Amazon Kinesis
        • Azure Event Hubs
        • BigQuery Stream
        • Confluent Cloud
        • Google Pub/Sub
        • Streaming Platforms
        • Apache Kafka
      • tag-managers
        • Google Tag Manager
        • Tag Managers
      • testing-and-personalization
        • Algolia Insights
        • Candu
        • Google Optimize
        • A/B Testing & Personalization
        • LaunchDarkly
        • Monetate
        • Optimizely Full Stack
        • Optimizely Web
        • Split.io
        • Statsig
        • VWO (Visual Website Optimizer)
    • get-started
      • RudderStack Cloud vs. RudderStack Open Source
      • Glossary
      • Get Started
      • RudderStack Architecture
    • reverse-etl
      • Amazon Redshift
      • Amazon S3
      • ClickHouse
      • FAQ
      • Google BigQuery
      • Reverse ETL
      • PostgreSQL
      • Snowflake
      • common-settings
        • Importing Data using Models
        • Importing Data using Tables
        • Common Settings
        • Sync Modes
        • Sync Schedule
      • features
        • Airflow Provider
        • Features
        • Models
        • Visual Data Mapper
    • rudderstack-api
      • Data Regulation API
      • HTTP API
      • RudderStack API
      • Personal Access Tokens
      • Pixel API
      • Test API
      • api-specification
        • Application Lifecycle Events Specification
        • API Specification
        • Video Events Specification
        • rudderstack-ecommerce-events-specification
          • Browsing
          • Coupons
          • E-Commerce Events Specification
          • Ordering
          • Promotions
          • Reviewing
          • Sharing
          • Wishlist
        • rudderstack-spec
          • Alias
          • Common Fields
          • Group
          • Identify
          • RudderStack Event Specification
          • Page
          • Screen
          • Track
    • rudderstack-cloud
      • Audit Logs
      • Dashboard Overview
      • Destinations
      • RudderStack Cloud
      • Live Events
      • Connection Modes: Cloud Mode vs. Device Mode
      • Sources
      • Teammates (User Management)
      • connections
        • Adding a Destination
        • Connections
    • rudderstack-open-source
      • Control Plane Setup
      • RudderStack Open Source
      • installing-and-setting-up-rudderstack
        • Developer Machine Setup
        • Docker
        • Data Plane Setup
        • Kubernetes
        • Sending Test Events
    • stream-sources
      • App Center
      • AppsFlyer
      • Auth0
      • Braze
      • Customer.io
      • Extole
      • Event Stream Sources
      • Iterable
      • Looker
      • PostHog
      • Segment
      • Shopify
      • Webhook Source
      • rudderstack-sdk-integration-guides
        • Client-side Event Filtering
        • SDKs
        • AMP Analytics
        • Cordova
        • .NET
        • Go
        • Java
        • Node.js
        • PHP
        • Python
        • React Native
        • Ruby
        • Rust
        • Unity
        • SDK FAQs
        • rudderstack-android-sdk
          • Adding Application Class
          • Flushing Events Periodically
          • Android
        • rudderstack-flutter-sdk
          • Flutter SDK v1
          • Flutter v2
          • Flutter
        • rudderstack-ios-sdk
          • iOS
          • tvOS
          • watchOS
        • rudderstack-javascript-sdk
          • Data Storage in Cookies
          • Detecting Ad-blocked Pages
          • JavaScript
          • JavaScript SDK Enhancements
          • JavaScript SDK FAQs
          • Querystring API
          • Quick Start Guide
          • Version Migration Guide
          • consent-managers
            • Consent Managers
            • OneTrust
    • transformations
      • Access Token
      • FAQ
      • Transformations
      • Transformations API
    • user-guides
      • User Guides
      • administrators-guide
        • Troubleshooting Guide
        • Alerting Guide
        • Bucket Configuration Settings for Event Backups
        • Configuration Parameters
        • Event Replay
        • High Availability
        • Horizontal Scaling
        • Administrator's Guides
        • Infrastructure Provisioning
        • Monitoring and Metrics
        • Okta SSO Setup
        • OneLogin SSO Setup
        • RudderStack Grafana Dashboard
        • Software Releases
      • how-to-guides
        • How to Use Custom Domains
        • How to Develop Integrations for RudderStack
        • How to Configure a Destination via the Event Payload
        • How to Filter Events using Different Methods
        • How to Filter Selective Destinations
        • How to Submit a Pull Request for a New Integration
        • How-to Guides
        • How to Debug Live Destination Events
        • How to Use AWS Lambda Functions with RudderStack
        • create-a-new-destination-transformer-for-rudder
          • Best Practices for Coding Transformation Functions in JavaScript
          • How to Create a New Destination Transformation for RudderStack
        • implement-native-js-sdk-integration
          • How to Add a Device Mode SDK to RudderStack JavaScript SDK
          • How to Implement a Native JavaScript SDK Integration
        • rudderstack-jamstack-integration
          • How to Integrate RudderStack with Your JAMstack Site
          • How to Integrate Rudderstack with Your Angular App
          • How to Integrate Rudderstack with Your Astro Site
          • How to Integrate Rudderstack with Your Eleventy Site
          • How to Integrate Rudderstack with Your Ember.js App
          • How to Integrate Rudderstack with a Gatsby Website
          • How to Integrate Rudderstack with a Hugo Site
          • How to Integrate Rudderstack with Your Jekyll Site
          • How to Integrate Rudderstack with Your Next.js App
          • How to Integrate Rudderstack with Your Nuxt.js App
          • How to Integrate Rudderstack with Your Svelte App
          • How to Integrate Rudderstack with Your Vue App
      • migration-guides
        • Migrating from Blendo to RudderStack
        • Migrating Your Warehouse Destination from Segment to RudderStack
        • Migration Guides
        • Migrating from Segment to RudderStack
  • src
    • @rocketseat
      • gatsby-theme-docs
        • text
          • Home
Powered by GitBook
On this page
  • Getting started
  • Connection settings
  • Adding AppsFlyer to your project
  • Connecting AppsFlyer to non-Android/iOS sources
  • Sending events via the RudderStack cloud mode
  • Obtaining the AppsFlyer ID
  • Identify
  • Track
  • Screen
  • Advertising ID
  • ATTrackingManager
  • Error messages
  • Invalid platform / required androidAppId / appleAppId missing
  • Appsflyer ID is not set. Rejecting the event.
  • Debugging
  • FAQs
  • Where do I get the AppsFlyer dev key?
  • I get an error saying "Build input file cannot be found" for iOS device mode. What should I do?
  • How do I get the AppsFlyer ID to send events from my mobile sources via the RudderStack cloud mode?
  • Contact us

Was this helpful?

  1. docs
  2. destinations
  3. attribution

AppsFlyer

Step-by-step guide to send event data from RudderStack to AppsFlyer

PreviousAdjustNextBranch

Last updated 3 years ago

Was this helpful?

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 .

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 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 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:

  1. From your , add the source. From the list of destinations, select AppsFlyer.

  2. 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.

  • 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.

  • 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.

  • Client-side Event Filtering: This setting is applicable only if you are sending events to AppsFlyer via the device mode.

  • 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.

  • 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:

  1. pod 'Rudder-Appsflyer'
  2. After adding the dependency, you need to 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>
  3. 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:

    #import <AppsFlyerLib/AppsFlyerLib.h>
    
    [[AppsFlyerLib shared] setAppsFlyerDevKey:<devKey>];
    [[AppsFlyerLib shared] setAppleAppID:<appleAppId>];
    [AppsFlyerLib shared].isDebug = YES;
    [[AppsFlyerLib shared] start];
  4. Then, change the iOS 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]];

To add AppsFlyer to your Android project:

  1. Add the mavenCentral() repository, as shown:

    repositories {
        mavenCentral()
    }
  2. Then, add the following lines to your app/build.gradle file under dependencies:

    implementation 'com.rudderstack.android.sdk:core:1.+'
    implementation 'com.rudderstack.android.integration:appsflyer:1.+'
    
    implementation 'com.appsflyer:af-android-sdk:6.+'
    implementation 'com.android.installreferrer:installreferrer:2.+'
  3. 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:

    import com.appsflyer.AppsFlyerLib;
    import com.appsflyer.AFLogger;
    
    AppsFlyerLib.getInstance().init(DEV_KEY, null, this);
    AppsFlyerLib.getInstance().setLogLevel(AFLogger.LogLevel.DEBUG);
    AppsFlyerLib.getInstance().start(this);
  4. Finally, change the SDK initialization in your Application class, as shown:

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

To add AppsFlyer to your React Native project:

  1. Add the RudderStack-AppsFlyer module to your app using the following command:

    npm install @rudderstack/rudder-integration-appsflyer-react-native
    // OR //
    yarn add @rudderstack/rudder-integration-appsflyer-react-native
  2. For AppsFlyer React Native device mode version less than 1.1.0, follow the below step:

  3. Import the module and add it to your SDK initialization code, as shown:

    import rudderClient from "@rudderstack/rudder-sdk-react-native"
    import appsflyer from "@rudderstack/rudder-integration-appsflyer-react-native"
    const config = {
      dataPlaneUrl: DATA_PLANE_URL,
      trackAppLifecycleEvents: true,
      withFactories: [appsflyer],
    }
    rudderClient.setup(WRITE_KEY, config)
  4. For AppsFlyer React Native device mode version 1.1.0 or above, follow these steps:

  5. Initialize the AppsFlyer SDK as shown:

    import rc from '@rudderstack/rudder-sdk-react-native';
    import appsflyer from 'rudder-integration-appsflyer-react-native'
    import {
        setOptions
    } from 'rudder-integration-appsflyer-react-native/src/appsflyer';
    
    // Setting options for initializing the appsflyer sdk
    setOptions({
        // dev key from the appsflyer dashboard
        "devKey": "<dev_key>",
        // whether we want to run the appsflyer SDK in the debug mode
        "isDebug": true,
        // whether we want to register for the listeners which would return the conversion data
        "onInstallConversionDataListener": true,
        // ID assigned by the Apple app store for any app which is either published or in the process of getting published
        "appleAppId": "<apple_app_id>",
        // whether we want to register for the listeners which would return the deeplink data
        "onDeepLinkListener": true
    })
    
    // Configuration object to be passed while initializing the Rudder React Native // SDK
    const config = {
        dataPlaneUrl: DATA_PLANE_URL
            trackAppLifecycleEvents: true,
        // Passing appsflyer factory here, since we want to run appsflyer as a device 
        // mode destination.
        withFactories: [appsflyer]
    };
    
    // Finally, initializing the RudderStack React Native SDK
    await rc.setup( WRITE_KEY , config);

    As seen above, the properties onInstallConversionDataListener and onDeepLinkListener are set to true in the setOptions API to get access to the conversion as well as the attribution data.

  6. Then, register the callbacks with the listeners, as shown:

    import {
        onAppOpenAttribution,
        onAttributionFailure,
        onDeepLink,
        onInstallConversionData,
        onInstallConversionFailure
    } from 'rudder-integration-appsflyer-react-native/src/appsflyer';
    
    var onInstallConversionDataCanceller = onInstallConversionData((data) => {
        console.log("On Install Conversion Success data is ", data);
        if (JSON.parse(res.data.is_first_launch) == true) {
            if (res.data.af_status === 'Non-organic') {
                var media_source = res.data.media_source;
                var campaign = res.data.campaign;
                console.log('This is first launch and a Non-Organic install. Media source: ' + media_source + ' Campaign: ' + campaign);
            } else if (res.data.af_status === 'Organic') {
                console.log('This is first launch and a Organic Install');
            }
        } else {
            console.log('This is not first launch');
        }
    
    })
    
    var onAppOpenAttributionCanceller = onAppOpenAttribution((data) => {
        console.log("On App Open Attribution Success and the data is ", data);
        // write your own custom logic here
    })
    
    var onAttributionFailureCanceller = onAttributionFailure((data) => {
        console.log("On App Attribution Failure and the data is ", data);
        // write your own custom logic here
    })
    
    var onInstallConversionFailureCanceller = onInstallConversionFailure((data) => {
        console.log("On Install Conversion Failure data is ", data);
        // write your own custom logic here
    })
    
    var onDeepLinkCanceller = onDeepLink((data) => {
        console.log("On Deeplink data is ", data);
        // write your own custom logic here
    })
  7. 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 in componentWillUnMount(), as shown:

      import React, {
          Component
      } from 'react';
      import {
          AppState,
          Platform,
          StyleSheet,
          Text,
          View,
          Button
      } from 'react-native';
      import appsFlyer from 'react-native-appsflyer';
      
      const options = {
          devKey: "********",
          isDebug: true,
          onInstallConversionData: true
      };
      
      if (Platform.OS === 'ios') {
          options.appId = "123456789";
      }
      this.onInstallConversionDataCanceller = appsFlyer.onInstallConversionData(
          data => {
              console.log("GCD");
              console.log(data);
      
          }
      );
      
      this.onAppOpenAttributionCanceller = appsFlyer.onAppOpenAttribution(
          data => {
              console.log("OAOA");
              console.log(data);
          }
      );
      appsFlyer.initSdk(options, (result) => {
          console.log(result);
      }, (error) => {
          console.error(error);
      });
      type Props = {};
      export default class App extends Component < Props > {
      
              componentWillUnmount() {
                  if (onInstallConversionDataCanceller) {
                      onInstallConversionDataCanceller();
                      console.log('unregister onInstallConversionDataCanceller');
                      onInstallConversionDataCanceller = null;
                  }
                  if (onAppOpenAttributionCanceller) {
                      onAppOpenAttributionCanceller();
                      console.log('unregister onAppOpenAttributionCanceller');
                      onAppOpenAttributionCanceller = null;
                  }
    • If it's a functional component, trigger the useEffect() hook, as shown:

      import React, {useEffect, useState} from 'react';
      import {AppState, SafeAreaView, Text, View} from 'react-native';
      import appsFlyer from 'react-native-appsflyer';
      
      var onInstallConversionDataCanceller = appsFlyer.onInstallConversionData(
          (res) => {
              if (JSON.parse(res.data.is_first_launch) == true) {
                  if (res.data.af_status === 'Non-organic') {
                      var media_source = res.data.media_source;
                      var campaign = res.data.campaign;
                      console.log('This is first launch and a Non-Organic install. Media source: ' + media_source + ' Campaign: ' + campaign);
                  } else if (res.data.af_status === 'Organic') {
                      console.log('This is first launch and a Organic Install');
                  }
              } else {
                  console.log('This is not first launch');
              }
          },
      );
      
      var onAppOpenAttributionCanceller = appsFlyer.onAppOpenAttribution((res) => {
          console.log(res);
      });
      
      
      appsFlyer.initSdk(
          {
              devKey: 'K2a*********99',
              isDebug: false,
              appId: '41******5',
          },
          (result) => {
              console.log(result);
          },
          (error) => {
              console.error(error);
          },
      );
      
      const Home = (props) => {
      
          useEffect(() => {
              return () => {
                  // Optionaly remove listeners for deep link data if you no longer need them after componentWillUnmount
                  if (onInstallConversionDataCanceller) {
                    onInstallConversionDataCanceller();
                    console.log('unregister onInstallConversionDataCanceller');
                    onInstallConversionDataCanceller = null;
                  }
                  if (onAppOpenAttributionCanceller) {
                    onAppOpenAttributionCanceller();
                    console.log('unregister onAppOpenAttributionCanceller');
                    onAppOpenAttributionCanceller = null;
                  }
              };
          });
      
          return (                   
                      {'App'}        
          );
      };
  8. Finally, open AppDelegate.m in the ios folder of your app and include the following snippet:

    #import "RudderIntegrationAppsflyerReactNative.h"
    
    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *) options {
      [[AppsFlyerAttribution shared] handleOpenUrl:url options:options];
        return YES;
    }
    
    // Open URI-scheme for iOS 8 and below
    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation {
      [[AppsFlyerAttribution shared] handleOpenUrl:url sourceApplication:sourceApplication annotation:annotation];
      return YES;
    }
    
    // Open Universal Links
    - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler {
        [[AppsFlyerAttribution shared] continueUserActivity:userActivity restorationHandler:restorationHandler];
        return YES;
    }

To add AppsFlyer to your Cordova project, follow these steps:

  1. Navigate to the root folder of your application and run the following command:

    cordova plugin add rudder-integration-appsflyer-cordova
  2. Add the platforms that you want to target for your app:

    cordova platform add ios
    cordova platform add android
  3. Run the following command to build the project for all the platforms:

    cordova build
  4. Finally, add the following code in the onDeviceReady() function of your home page to initialize the SDK, as shown:

    RudderClient.initialize(WRITE_KEY , {
      dataPlaneUrl: DATA_PLANE_URL,
      factories: [RudderAppsflyerFactory]
    })

    Make sure to use the await keyword with the initialize 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:

  • 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:

export function transformEvent(event, metadata) {
  event.context.os = {
    name: "android",
    version: "8.1.0"
  };
  return event;
}
  • 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

  • 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.

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:

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

The following table lists the externalId fields:

Field
Description

id

Your AppsFlyer ID.

type

The type of externalId. This must always be set to appsFlyerExternalId.

Obtaining the AppsFlyer ID

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

  • 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

#import <AppsFlyerLib/AppsFlyerLib.h>
NSString *appsflyerId = [AppsFlyerLib shared].getAppsFlyerUID;
import com.appsflyer.AppsFlyerLib;
String appsFlyerId = AppsFlyerLib.getInstance().getAppsFlyerUID(this);
import AppsFlyerIntegrationFactory from "@rudderstack/rudder-integration-appsflyer-react-native/src/bridge"
const appsFlyerId = await AppsFlyerIntegrationFactory.getAppsFlyerId()

Identify

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

RudderStack sets email from the event traits to AppsFlyer using the native SDK's setUserEmails method, as shown:

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

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

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

first_purchase

first_purchase

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

query

af_search_string

price

af_price

product_id

af_content_id

category

af_content_type

currency

af_currency

products

quantity

af_quantity

order_id

af_receipt_id

revenue

af_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 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:

You can find the advertising ID in your event's context.device.advertisementId.

ATTrackingManager

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.

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

Appsflyer ID is not set. Rejecting the event.

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?

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 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

#import <AppsFlyerLib/AppsFlyerLib.h>
NSString *appsflyerId = [AppsFlyerLib shared].getAppsFlyerUID;
import com.appsflyer.AppsFlyerLib;
String appsFlyerId = AppsFlyerLib.getInstance().getAppsFlyerUID(this);
import AppsFlyerIntegrationFactory from "@rudderstack/rudder-integration-appsflyer-react-native/src/bridge"
const appsFlyerId = await AppsFlyerIntegrationFactory.getAppsFlyerId()

Contact us

Refer to the section below for more information on obtaining the AppsFlyer dev key.

Refer to the section below for more information.

For more information on this field, refer to the page.

Refer to the guide for more information on this setting.

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 section above for more information.

Add the following line to your Podfile:

Go to your .

We recommend sending events to AppsFlyer via the only in the following two scenarios:

To use RudderStack's feature to transform your events

Refer to the section below for more information.

If the AppsFlyer SDK is directly loaded on your app, refer to this to obtain the AppsFlyer ID.

RudderStack supports the identify calls only in the .

RudderStack formulates this list as per the and passes it to the property af_content_list.

For iOS:

For Android:

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

You can set the App ID in your .

This error occurs when the appsflyerExternalId is not set. Refer to the section for more information on setting the appsflyerExternalId.

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 page.

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 section above.

For queries on any of the sections covered in this guide, you can or start a conversation in our community.

AppsFlyer Help Center
Client-side Event Filtering
CocoaPods
RudderStack dashboard
cloud mode
Transformations
AppsFlyer documentation
device mode
Advertisement ID documentation
Advertisement ID documentation
ATTrackingManager authorization consent
settings
Sending events via the RudderStack cloud mode
AppsFlyer Help Center
contact us
Slack
FAQs
Connecting AppsFlyer to non-Android/iOS sources
Getting started
Obtaining the AppsFlyer ID
Sending events via the RudderStack cloud mode
List View specification
AppsFlyer
GitHub repository
RudderStack Connection Modes
Transformations
RudderStack dashboard
AppsFlyer connection settings in RudderStack
Transformation settings after adding destination
AppsFlyer transformation settings in RudderStack