• Platforms
  • Partners
  • Forums
  • TLC Tealium Learning Center Tealium Learning
    Community
  • Discussions & Ideas Dicussions & Ideas
  • Product Guides Product Guides
  • Knowledge Base Knowledge Base
  • Developer Docs Developer Docs
  • Education Education
  • TLC Blog TLC Blog
  • Support Desk Support Desk
  • CDH Customer Data Hub Customer Data Hub

Table of Contents

  • Requirements
  • How It Works
  • Install
    • Dependency Manager
    • Manual (iOS)
    • Manual (Android)
  • Initialize
    • Android (Kotlin)
    • Android (Java)
    • iOS (Swift)
  • Push Message Tracking
  • JSON Template
  • Supported Methods
    • Standard Event Names
    • SDK Setup
    • Location
    • Other Options
REMOTE COMMANDS/INTEGRATIONS

Remote Command: AppsFlyer

Tealium remote command integration for AppsFlyer on Android and Swift/iOS.

Requirements

  • AppsFlyer app ID and dev key
  • One of these mobile libraries:
    • Tealium for Android-Kotlin (1.0.0+)
    • Tealium for Android-Java (5.9.0+ for AppsFlyer 1.0.0+ or <5.9.0 for previous versions)
    • Tealium for iOS-Swift
  • One of these remote command integrations:
    • AppsFlyer Remote Command JSON File (Requires Android-Kotlin 1.0.0+ or iOS-Swift 2.1.0+)
    • AppsFlyer Remote Command tag in Tealium iQ Tag Management

How It Works

The AppsFlyer integration uses three items:

  1. The AppsFlyer native SDK
  2. The remote commands module that wraps the AppsFlyer methods
  3. Either the JSON configuration file or Remote Command tag that translates event tracking into native AppsFlyer calls

Adding the AppsFlyer remote command module to your app automatically installs and builds the required AppsFlyer libraries, without having to add vendor-specific code to your app. If you are using a dependency manager installation, there is no need to install the AppsFlyer SDK separately.

There are two remote command options: A JSON configuration file, or using iQ Tag Management to configure the mappings. A JSON configuration file is the recommended option for your vendor integration, hosted either remotely or locally within your app. If using iQ Tag Management, add the Remote Command tag for the vendor integration. Learn more about vendor integrations.

iOS: For AppsFlyer version 4.8.11+, the SDK automatically adds the following native frameworks: AdSupport.framework and iAd.framework. Learn more in the AppsFlyer iOS SDK integration guide.

Install

Dependency Manager

We recommend using one of the following dependency managers for installation:

    To install AppsFlyer remote commands for iOS using CocoaPods:

    1. Remove tealium-swift and pod "AppsFlyerFramework" if they exist in your Podfile. The dependency for tealium-swift is already included in the TealiumAppsFlyer framework.

    2. Add the following dependency to your Podfile:

      pod "TealiumAppsFlyer"

      The TealiumAppsFlyer pod includes the following TealiumSwift dependencies:

      'tealium-swift/Core'
      'tealium-swift/RemoteCommands'
      'tealium-swift/TagManagement'
    3. Import the modules TealiumSwift and TealiumAppsFlyer in your TealiumHelper file, and any other files that access the Tealium class, or the AppsFlyer remote command.

    To install AppsFlyer remote commands for iOS using Carthage:

    1. Remove tealium-swift from your Cartfile. The dependency for tealium-swift is already included in the TealiumAppsFlyer framework.

    2. Remove the following line if it exists in your Cartfile:

      `binary "https://raw.githubusercontent.com/AppsFlyerSDK/AppsFlyerFramework/master/AppsFlyerLib.json"`
    3. Add the following dependency to your Cartfile:

      github "tealium/tealium-ios-appsflyer-remote-command"

    Tealium for Swift SDK (version 1.x) and TealiumAppsFlyer version 1.x requires the TealiumDelegate module to be included with your installation.

    To install AppsFlyer remote commands for Android using Maven:

    1. Install Tealium for Android (Kotlin) or Tealium for Android (Java), if you haven’t done so already.

    2. Add the Tealium Maven URL to your project’s top-level build.gradle file:

      allprojects {
        repositories {
          jcenter()
          maven {
            url "https://maven.tealiumiq.com/android/releases/"
          }
        }
      }
    3. Import both the AppsFlyer SDK and Tealium-AppsFlyer remote commands by adding the following dependencies in your app project’s build.gradle file:

      dependencies {
      implementation 'com.tealium.remotecommands:appsflyer:1.0.0'
      }

    Manual (iOS)

    The manual installation for AppsFlyer remote commands requires the Tealium for Swift library to be installed. To install the AppsFlyer remote commands for your iOS project:

    1. Install the AppsFlyer SDK, if you haven’t already done so.

    2. Clone the Tealium iOS AppsFlyer remote command repo and drag the files within the Sources folder into your project.

    3. Set the remoteAPIEnabled configuration flag to true

    Manual (Android)

    The manual installation for AppsFlyer remote commands requires Tealium for Android (Kotlin) or Tealium for Android (Java) to be installed. To install the AppsFlyer remote commands for your Android project:

    1. Add flatDir to your project root build.gradle file:

      allprojects {
        repositories {
           jcenter()
           flatDir {
               dirs 'libs'
           }
        }
      }
    2. Add tealium-appsflyer.aar to <PROJECT_ROOT>/<MODULE>/libs.

    3. Add the Tealium library dependency to your build.gradle file:

      dependencies {
        implementation(name:'tealium-appsflyer', ext:'aar')
      }

    Initialize

    For all Tealium libraries, register the AppsFlyer Remote Command when you initialize.

    Android (Kotlin)

    Initialize remote commands with a JSON configuration file or the Remote Command tag for Tealium’s Android (Kotlin) library.

      The following code is designed for use with the JSON Remote Command feature, using the local file option:

      // Sets up a config object and creates a Tealium instance
      val config = TealiumConfig(application,
              "ACCOUNT",
              "PROFILE",
              Environment.DEV,
              dispatchers = mutableSetOf(Dispatchers.RemoteCommands));
      var tealium = Tealium.create(TEALIUM_MAIN, config) {
          // New code to add the AppsFlyer Remote Command
          val appsFlyerRemoteCommand = AppsFlyerRemoteCommand(application,
                                            appsFlyerDevKey = devKey)
          // register the command
          remoteCommands?.add(appsFlyerRemoteCommand, filename = "appsflyer.json");
      }

      The following code is designed for use with the Remote Command tag feature:

      // Sets up a config object and creates a Tealium instance
      val config = TealiumConfig(application,
              "ACCOUNT",
              "PROFILE",
              Environment.DEV,
              dispatchers = mutableSetOf(Dispatchers.RemoteCommands));
      var tealium = Tealium.create(TEALIUM_MAIN, config) {
          // New code to add the AppsFlyer Remote Command
          val appsFlyer = AppsFlyerRemoteCommand(application,
                                            appsFlyerDevKey = devKey)
          // register the command
          remoteCommands?.add(appsFlyer);
      }

      Android (Java)

        The JSON Remote Command file feature for Android is only available in the Kotlin SDK.

        The following code is designed for use with the Remote Command tag feature:

        // Sets up a config object and creates a Tealium instance
        Tealium.Config config = Tealium.Config.create(application, "ACCOUNT", "PROFILE", "ENVIRONMENT");
        Tealium teal = Tealium.createInstance(TEALIUM_MAIN, config);
            // New code to add the AppsFlyer Remote Command
        AppsFlyerRemoteCommand appsFlyer = new AppsFlyerRemoteCommand(application, appsFlyerDevKey = devKey)
        teal.addRemoteCommand(appsFlyer);

        iOS (Swift)

        Initialize remote commands with a JSON configuration file or the Remote Command tag for Tealium’s iOS (Swift) library.

          The following code is designed for use with the JSON Remote Command feature, using the local file option:

          var tealium : Tealium?
          let config = TealiumConfig(account: "ACCOUNT",
                                     profile: "PROFILE",
                                     environment: "ENVIRONMENT",
                                     dataSource: "DATASOURCE",
                                     optionalData: nil)
          
          config.remoteAPIEnabled = true // Required to use Remote Commands
          
          tealium = Tealium(config: config) { _ in
              guard let remoteCommands = self.tealium?.remoteCommands else {
                  return
              }
          
              let appsflyer = AppsFlyerRemoteCommand(type: .local(file: "appsflyer"))
              remoteCommands.add(appsflyer)
          }

          The following code is designed for use with the Remote Command tag feature:

          var tealium : Tealium?
          let config = TealiumConfig(account: "ACCOUNT",
                                     profile: "PROFILE",
                                     environment: "ENVIRONMENT",
                                     dataSource: "DATASOURCE",
                                     optionalData: nil)
          
          config.remoteAPIEnabled = true // Required to use Remote Commands
          
          tealium = Tealium(config: config) { _ in
              guard let remoteCommands = self.tealium?.remoteCommands else {
                  return
              }
          
              let appsFlyer = AppsFlyerRemoteCommand()
              remoteCommands.add(appsFlyer)
          }

          Push Message Tracking

          The Tealium Swift library includes a TealiumRegistration protocol for handling push message tracking via Tealium and the AppsFlyer Remote Command. We conform to this protocol in the wrapper class AppsFlyerInstance which is used to send push message authorization events, push message open events, and to uninstall tracking. We recommend taking advantage of the push message tracking capability.

          The following steps integrate push message tracking for your iOS project:

          1. In the TealiumHelper.swift file, initialize an empty array of objects that conform to the TealiumRegistration protocol. For example:

            var pushMessagingTrackers = [TealiumRegistration]()
          2. Initialize the AppsFlyerInstance before the AppsFlyerRemoteCommand

          3. Append the AppsFlyerInstance to the array described above

          The following is full example of the push message tracking integration:

          var pushMessagingTrackers = [TealiumRegistration]()
          var tealium : Tealium?
          let config = TealiumConfig(account: "ACCOUNT",
                                     profile: "PROFILE",
                                     environment: "ENVIRONMENT",
                                     dataSource: "DATASOURCE",
                                     optionalData: nil)
          config.remoteAPIEnabled = true // Required to use Remote Commands
          
          tealium = Tealium(config: config) { _ in
              guard let remoteCommands = self.tealium?.remoteCommands else {
                  return
              }
          
          	let appsflyerInstance = AppsFlyerInstance()
          	let appsflyer = AppsFlyerRemoteCommand(appsflyerInstance: appsflyerInstance, type: .local(file: "appsflyer"))
          	pushMessagingTrackers.append(appsflyerInstance)
          	remoteCommands.add(appsflyer)
          }

          To see the entire TealiumHelper.swift file, explore the AppsFlyer Remote Command sample app. To send an event to AppsFlyer once a user has registered for notifications, opened a push message, or uninstalled the app, see the file AppDelegate.swift.

          Learn more about AppsFlyer’s push message and uninstall tracking functionality in the iOS SDK integration for developers guide.

          JSON Template

          If you are configuring remote commands using a JSON configuration file, refer to the following template to get started. The template includes common mappings used in a standard e-commerce installation. Edit the mappings as needed.

          {
              "config": {
                  "app_id": "YOUR_APP_ID",
                  "app_dev_key": "YOUR_APPSFLYER_DEV_KEY",
                  "settings": {
                      "custom_data": {"custom_key": "custom_value"},
                      "debug": true,
                      "disable_ad_tracking": false,
                      "disable_apple_ad_tracking": false,
                      "time_between_sessions": 30,
                      "anonymize_user": false,
                      "collect_device_name": false
                  }
              },
              "mappings": {
                  "latitude": "af_lat",
                  "longitude": "af_long",
                  "customer_email": "customer_emails",
                  "hash_type": "email_hash_type",
                  "currency_code": "af_currency",
                  "customer_id": "af_customer_user_id",
                  "signup_method": "event.signup_method",
                  "achievement_id": "event.achievement_id",
                  "checkout_option": "event.checkout_option",
                  "checkout_step": "event.checkout_step",
                  "content": "event.content",
                  "content_type": "event.content_type",
                  "coupon": "event.coupon",
                  "product_brand": "event.product_brand",
                  "product_category": "event.product_category",
                  "product_id": "event.af_content_id",
                  "product_list": "event.product_list",
                  "product_location_id": "event.product_location_id",
                  "product_name": "event.product_name",
                  "product_variant": "event.product_variant",
                  "product_unit_price": "event.af_price",
                  "product_quantity": "event.af_quantity",
                  "current_level": "event.level",
                  "score": "event.score",
                  "search_keyword": "event.search_keyword",
                  "order_shipping_amount": "event.order_shipping",
                  "order_tax_amount": "event.order_tax",
                  "order_id": "event.af_order_id",
                  "order_total": "event.af_revenue",
                  "currency_type": "event.currency_type",
              },
              "commands": {
                  "launch": "initialize,launch",
                  "geofence_entered": "tracklocation",
                  "geofence_exited": "tracklocation",
                  "user_login": "login",
                  "user_register": "setuseremails,setcustomerid,completeregistration",
                  "show_offers": "adclick",
                  "cart_add": "addtocart",
                  "wishlist_add": "addtowishlist",
                  "payment": "addpaymentinfo",
                  "unlock_achievement": "unlockachievement",
                  "level_up": "achievelevel,customersegment",
                  "email_signup": "subscribe",
                  "product": "viewedcontent",
                  "category": "listview",
                  "share": "share",
                  "search": "search",
                  "checkout": "initiatecheckout",
                  "order":"purchase"
              }
          }

          Supported Methods

          The following AppsFlyer methods are triggered using a data mapping in the AppsFlyer Remote Command tag using these Tealium commands:

          Remote Command AppsFlyer Method
          initialize initialize()
          trackLaunch trackLaunch()
          Any of the below event names trackEvent()
          setHost setHost()
          setUserEmails setUserEmails()
          setCurrencyCode currencyCode (property on the AppsFlyerTracker.shared object)
          setCustomerId customerUserID (property on the AppsFlyerTracker.shared object)
          disableDeviceTracking setDeviceTrackingDisabled
          disableTracking isStopTracking (property on the AppsFlyerTracker.shared object)
          resolveDeeplinkUrls resolveDeepLinkURLs (property on the AppsFlyerTracker.shared object)
          Manually called in AppDelegate within didReceiveRemoteNotification handlePushNotification()
          Manually called in AppDelegate within didReceiveRemoteNotification trackEvent() - event name: af_opened_from_push_notification
          Manually called in AppDelegate within didRegisterForRemoteNotificationsWithDeviceToken registerPushToken()

          Standard Event Names

          The following is a list of standard event names supported with the trackEvent method. If any of the below command names are sent, they are automatically triggered in the AppsFlyer SDK. This is assuming all the required variables are also mapped and defined for that particular event. Learn more about recording in-app events and the see the full list of recommended in-app events per vertical.

          Remote Command AppsFlyer Event Name
          achievedLevel "af_level_achieved"
          addPaymentInfo "af_add_payment_info"
          addToCart "af_add_to_cart"
          addToWishlist "af_add_to_wishlist"
          completeRegistration "af_complete_registration"
          completeTutorial "af_tutorial_completion"
          initiateCheckout "af_initiated_checkout"
          purchase "af_purchase"
          subscribe "af_subscribe"
          startTrial "af_start_trial"
          rate "af_rate"
          search "af_search"
          spentCredits "af_spent_credits"
          unlockAchievement "af_achievement_unlocked"
          contentView "af_content_view"
          listView "af_list_view"
          adClick "af_ad_click"
          adView "af_ad_view"
          travelBooking "af_travel_booking"
          share "af_share“
          invite "af_invite"
          reEngage "af_re_engage"
          update "af_update"
          login "af_login"
          customerSegment "af_customer_segment"
          pushNotificationOpened "af_opened_from_push_notification"

          Since the AppsFlyer SDK is installed alongside the Tealium SDK, you are able to trigger any native AppsFlyer functionality given the corresponding tag configuration.

          SDK Setup

          Initialize

          The AppsFlyer SDK is initialized automatically upon launch. The AppsFlyer API key is set in the tag configuration.

          Remote Command AppsFlyer Method
          initialize initialize()

          AppsFlyer Developer Guide: Initial SDK Setup

          • iOS

          There are several configuration options available that can be configured in the AppsFlyer Remote Command tag. If any of the below are set on launch, they are sent during the initialize method.

          Configuration Options
          Name iQ variable mapping Type
          debug debug Bool
          disableIAdTracking disable_apple_ad_tracking Bool
          minTimeBetweenSessions time_between_sessions Int
          anonymizeUser anonymize_user Bool
          shouldCollectDeviceName collect_device_name Bool
          customData custom_data Dictionary or Map

          AppsFlyer Developer Guide: Additional APIs

          • iOS
          • Android

          Track Launch

          Remote Command AppsFlyer Method
          initialize or launch trackLaunch()

          If you have the lifecycle module installed, this event automatically sends every app launch.

          AppsFlyer Developer Guide: Initializing the SDK

          • iOS
          • Android

          Location

          Track Location

          Remote Command AppsFlyer Method
          tracklocation trackEvent() - event name af_location_coordinates
          Parameter Type
          latitude (required) Bool
          longitude (required) Bool

          If you have the location module installed, the latitude and longitude are sent with every event.

          AppsFlyer API Reference: Location Tracking

          • iOS

          Other Options

          Set Host

          Remote Command AppsFlyer Method
          sethost setHost
          Parameter Type
          host (required) String
          hostPrefix (required) String

          AppsFlyer API Reference: Set Host

          • iOS

          Set User Emails

          Remote Command AppsFlyer Method
          setsermails setUserEmails
          Parameter Type
          emails (required) [String]
          cryptType (required) Int
          Crypt Type Reference
          Value Type
          0 None
          1 SHA1
          2 MD5
          3 SHA256

          AppsFlyer API Reference: Set User Email

          • iOS

          Set Currency Code

          Remote Command AppsFlyer Property
          setcurrencycode currencyCode
          Parameter Type
          currency (required) String

          AppsFlyer API Reference: Set Currency Code

          • iOS

          Set Customer ID

          Remote Command AppsFlyer Property
          setcustomerid customerUserID
          Parameter Type
          customerId (required) String
          • AppsFlyer Additional APIs: Set Customer ID
          • iOS
          • Android

          Resolve Deep Link Urls

          Remote Command AppsFlyer Property
          resolvedeeplinkurls resolveDeepLinkURLs
          Parameter Type
          deepLinkUrls (required) [String]

          AppsFlyer API Reference: Resolve Deep Link URLs

          • iOS
          • Android

          Disable Tracking

          Remote Command AppsFlyer Property
          disabletracking isStopTracking
          Parameter Type
          stopTracking (required) Bool

          AppsFlyer Additional APIs: Stop Tracking (Opt-out)

          • iOS
          • Android
          Remote Command: Braze

           
          • Mobile
          • Getting Started
            • Overview
            • Quick Start Guide
            • Mobile Concepts
            • Client-Side
            • Server-Side
            • Tracking Webviews
            • Data Layer
            • Consent Management
            • Event Batching
            • User Location and Geofencing
            • Deep Links
            • Timed Events
            • Trace
            • Hosted Data Layer
            • Feature Comparison
            • Troubleshooting
          • Remote Commands
            • Overview
            • How It Works
            • Integrations
              • AppsFlyer
              • Braze
              • Contentsquare
              • Facebook
              • Firebase
              • Kochava
              • Usabilla
          • Android (Java)
            • Overview
            • Install
            • Track
            • Data Layer
            • Data Management
            • Consent Management
            • Module List
              • Ad Identifier Module
              • Crash Reporter Module
              • Install Referrer Module
              • Lifecycle Tracking Module
              • Location Module
              • Optimizely X Tracking Module
            • Android TV
            • Android Wear
            • API Reference
              • ConsentManager
              • DataSources
              • Lifecycle
              • Tealium
              • Tealium.Config
              • TealiumLocation
            • Release Notes
          • Android (Kotlin)
            • Overview
            • Install
            • Track
            • Data Layer
            • Consent Management
            • Identity Resolution
            • Module List
              • Collect Module
              • Collectors Module
              • Crash Reporter Module
              • Install Referrer Module
              • Lifecycle Tracking Module
              • Location Manager Module
              • Tag Management Dispatcher Module
              • Visitor Service Module
            • Android TV
            • API Reference
              • ConsentCategory
              • ConsentManager
              • CurrentVisit
              • DataLayer
              • Lifecycle
              • LocationManager
              • Tealium
              • TealiumConfig
              • VisitorProfile
              • VisitorService
            • Release Notes
          • Cordova
            • Overview
            • Install
            • Track
            • Data Management
            • Module List
              • Ad Identifier Module
              • Crash Reporter Module
              • Install Referrer Module
            • API Reference
            • Release Notes
          • Flutter
            • Overview
            • Install
            • Track
            • Consent Management
            • Data Management
            • API Reference
            • Release Notes
          • iOS (Objective-C)
            • Overview
            • Install
            • Track
            • Data Layer
            • Data Management
            • Consent Management
            • Tag Management
            • Module List
              • Lifecycle Tracking Module
              • Optimizely X Tracking Module
            • tvOS
            • watchOS
            • API Reference
            • Release Notes
          • iOS (Swift) 1.x
            • Overview
            • Install
            • Track
            • Data Layer
            • Data Management
            • App Extensions
            • Identity Resolution
            • Consent Management
            • Modules
            • Module List
              • AppData Module
              • Attribution Module
              • AutoTracking Module
              • Collect Module
              • Connectivity Module
              • CrashReporter Module
              • DataSource Module
              • DefaultStorage Module
              • Delegate Module
              • DeviceData Module
              • DispatchQueue Module
              • FileStorage Module
              • Lifecycle Module
              • Location Module
              • Logger Module
              • PersistentData Module
              • RemoteCommands Module
              • TagManagement Module
              • VisitorService Module
              • VolatileData Module
            • Feature Comparison
            • Working with Objective-C
            • API Reference
              • TealiumConfig
              • TealiumConsentCategories
              • TealiumConsentManagerDelegate
              • TealiumConsentManager
              • TealiumInstanceManager
              • TealiumPersistentData
              • TealiumVolatileData
              • Tealium
            • Release Notes
          • iOS (Swift) 2.x
            • Overview
            • Install
            • Track
            • Data Layer
            • Consent Management
            • App Extensions
            • Identity Resolution
            • Modules
            • Module List
              • AppData Module
              • Attribution Module
              • AutoTracking Module
              • Collect Module
              • Connectivity Module
              • CrashReporter Module
              • DeviceData Module
              • Lifecycle Module
              • Location Module
              • RemoteCommands Module
              • TagManagement Module
              • VisitorService Module
            • Working with Objective-C
            • API Reference
              • Tealium
              • TealiumConfig
              • TealiumConsentCategories
              • TealiumConsentManager
              • TealiumDataLayer
              • TealiumInstanceManager
            • Release Notes
          • React Native
            • Overview
            • Install
            • Track
            • API Reference
            • Release Notes
          • Unity
            • Overview
            • Install
            • Track
            • API Referencee
          • Xamarin
            • Overview
            • Install
            • Track
            • Data Management
            • Consent Management
            • API Reference
            • Release Notes
          • Web
          • AMP
            • Overview
            • Install
            • Track
            • Data Layer
          • Angular
            • Overview
            • Install
            • Track
            • API Reference
          • Google Tag Manager
            • Overview
            • Install
            • Data Layer
          • JavaScript (Web)
            • Overview
            • Install
            • Track
            • Data Layer
            • Universal Data Object (utag_data)
            • Universal Tag (utag.js)
            • Data Layer Object (b)
            • Single-Page Applications
            • Settings
            • Debugging
            • API Reference
              • Cookie Functions
              • GDPR Functions
              • Tracking Functions
              • Utility Functions
            • Release Notes
          • Server
          • C#
            • Overview
            • Install
            • Track
            • Data Layer
            • API Reference
            • Release Notes
          • HTTP API
            • Overview
            • Endpoint
            • Data Layer
          • Java
            • Overview
            • Install
            • Track
            • API Reference
            • Release Notes
          • Node
            • Overview
            • Install
            • Track
            • API Reference
          • Python
            • Overview
            • Install
            • Track
            • API Reference
          • Roku
            • Overview
            • Install
            • Track
            • API Reference
          • Ruby
            • Overview
            • Install
            • Track
            • API Reference

          Was this article helpful?

          This page was last updated: November 12, 2020       Thank you for your feedback!
          • Platforms
          • Partners
          • Forums
          • Mobile
          • Getting Started
          • Remote Commands
          • Android (Java)
          • Android (Kotlin)
          • Cordova
          • Flutter
          • iOS (Objective-C)
          • iOS (Swift) 1.x
          • iOS (Swift) 2.x
          • React Native
          • Unity
          • Xamarin
          • Web
          • AMP
          • Angular
          • Google Tag Manager
          • JavaScript (Web)
          • Server
          • C#
          • HTTP API
          • Java
          • Node
          • Python
          • Roku
          • Ruby