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
- Tealium for React Native
- 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:
- The AppsFlyer native SDK
- The remote commands module that wraps the AppsFlyer methods
- 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
- In your Xcode project, select File > Add Packages… > Add Package Dependency.
- Enter the repository URL:
https://github.com/tealium/tealium-ios-appsflyer-remote-command
. - Configure the version rules. Typically,
Up to next major
is recommended. If the currentTealiumAppsFlyer
version does not appear in the list, then reset your Swift package cache. - Select the
TealiumAppsFlyer
module to install, and select the app target you want the module to be installed in.
If your project has more than one app target and needs TealiumAppsFlyer
module in more app targets, you have to manually add them in the Frameworks, Libraries, and Embedded Content section.
To install TealiumAppsFlyer
in additional app targets:
- Select your Xcode project in the Project Navigator.
- In your Xcode project, select the app target under the TARGETS section.
- Navigate to General > Frameworks, Libraries & Embedded Content and select the
TealiumAppsFlyer
module to add it to your app target.
To add additional modules from the Tealium Swift library, follow the Swift Package Manager instructions.
-
Remove
tealium-swift
andpod "AppsFlyerFramework"
if they exist in your Podfile. The dependency fortealium-swift
is already included in theTealiumAppsFlyer
framework. -
Add the following dependency to your Podfile:
pod "TealiumAppsFlyer"
The
TealiumAppsFlyer
pod includes the followingTealiumSwift
dependencies:'tealium-swift/Core' 'tealium-swift/RemoteCommands' 'tealium-swift/TagManagement'
-
Import the modules
TealiumSwift
andTealiumAppsFlyer
in yourTealiumHelper
file, and any other files that access theTealium
class, or the AppsFlyer remote command.
To install AppsFlyer remote commands for iOS using Carthage:
-
Remove
tealium-swift
from your Cartfile. The dependency fortealium-swift
is already included in theTealiumAppsFlyer
framework. -
Remove the following line if it exists in your Cartfile:
`binary "https://raw.githubusercontent.com/AppsFlyerSDK/AppsFlyerFramework/master/AppsFlyerLib.json"`
-
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.
-
Install Tealium for Android (Kotlin) or Tealium for Android (Java) and add the Tealium Maven URL to your project’s top-level
build.gradle
file, if you haven’t done so already.allprojects { repositories { jcenter() maven { url "https://maven.tealiumiq.com/android/releases/" } } }
-
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' }
Follow the installation instructions for the main Tealium React Native library installation. Ensure you have installed version 2.2.0 or newer.
Navigate to the root of your React Native project.
Download and install the tealium-react-appsflyer
package with the following command:
Install the AppsFlyer Remote Command package
yarn add tealium-react-appsflyer
Manual Installation
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:
-
Install the AppsFlyer SDK, if you haven’t already done so.
-
Clone the Tealium iOS AppsFlyer remote command repo and drag the files within the
Sources
folder into your project. -
Set the
remoteAPIEnabled
configuration flag totrue
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:
-
Add
flatDir
to your project rootbuild.gradle
file:allprojects { repositories { jcenter() flatDir { dirs 'libs' } } }
-
Add
tealium-appsflyer.aar
to<PROJECT_ROOT>/<MODULE>/libs
. -
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.
Initialize remote commands with a JSON configuration file or the Remote Command tag for Tealium’s iOS (Swift) library:
// 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);
}
Initialize remote commands with a JSON configuration file or the Remote Command tag for Tealium’s Android (Kotlin) library:
val config = TealiumConfig(application,
"ACCOUNT",
"PROFILE",
Environment.DEV,
dispatchers = mutableSetOf(Dispatchers.RemoteCommands, Dispatchers.TagManagement));
val appsFlyer = AppsFlyerRemoteCommand(applicationm, appsFlyerDevKey = devKey);
var tealium = Tealium.create(TEALIUM_MAIN, config) {
// Webview Tag
remoteCommands?.add(appsFlyer);
// Local JSON
//remoteCommands?.add(appsFlyer, filename = "appsFlyer.json");
// Remote JSON
//remoteCommands?.add(appsFlyer, remoteUrl = "https://some.domain.com/appsFlyer.json");
}
Initialize remote commands with the Remote Command tag for Tealium’s Android (Java) library:
// 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);
import AppsflyerRemoteCommand from 'tealium-react-appsflyer';
AppsflyerRemoteCommand.initialize();
let config = TealiumConfig {
// ...
remoteCommands: [{
id: AppsflyerRemoteCommand.name,
// Optional - path to local JSON mappings
// path: "appsflyer.json"
// Optional - path to remote JSON mappings
// url: "https://some.domain.com/appsflyer.json"
}]
}
Tealium.initialize(config, success => {});
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:
- In the
TealiumHelper.swift
file, initialize an empty array of objects that conform to theTealiumRegistration
protocol. For example:var pushMessagingTrackers = [TealiumRegistration]()
- Initialize the
AppsFlyerInstance
before theAppsFlyerRemoteCommand
- 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
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
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
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
Other Options
Set Host
Remote Command | AppsFlyer Method |
---|---|
sethost |
setHost |
Parameter | Type |
---|---|
host (required) |
String |
hostPrefix (required) |
String |
AppsFlyer API Reference: Set Host
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
Set Currency Code
Remote Command | AppsFlyer Property |
---|---|
setcurrencycode |
currencyCode |
Parameter | Type |
---|---|
currency (required) |
String |
AppsFlyer API Reference: Set Currency Code
Set Customer ID
Remote Command | AppsFlyer Property |
---|---|
setcustomerid |
customerUserID |
Parameter | Type |
---|---|
customerId (required) |
String |
Resolve Deep Link Urls
Remote Command | AppsFlyer Property |
---|---|
resolvedeeplinkurls | resolveDeepLinkURLs |
Parameter | Type |
---|---|
deepLinkUrls (required) |
[String] |
AppsFlyer API Reference: Resolve Deep Link URLs
Consent Options
Disable Tracking
Remote Command | AppsFlyer Property |
---|---|
disabletracking | isStopTracking |
Parameter | Type |
---|---|
stopTracking (required) |
Bool |
AppsFlyer Additional APIs: Stop Tracking (Opt-out)
This page was last updated: August 24, 2023