Remote Command: AppsFlyer
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:
- 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
We recommend using one of the following dependency managers for installation:
To install AppsFlyer remote commands for iOS using CocoaPods:
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.
To install AppsFlyer remote commands for Android using Maven:
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' }
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:
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
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:
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.
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:
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
Disable Tracking
Remote Command | AppsFlyer Property |
---|---|
disabletracking | isStopTracking |
Parameter | Type |
---|---|
stopTracking (required) |
Bool |
AppsFlyer Additional APIs: Stop Tracking (Opt-out)
Was this article helpful?
This page was last updated: March 2, 2022