AppsFlyer Destination
AppsFlyer is the worldâs leading mobile attribution & marketing analytics platform, helping app marketers around the world make better decisions. Our AppsFlyer destination code is open-source. You can browse the code on GitHub for iOS and Android.
This document was last updated on April 27, 2018. If you notice any gaps, outdated information or simply want to leave some feedback to help us improve our documentation, let us know!
Getting Started
Before you start, make sure AppsFlyer supports the source type and connection mode youâve chosen to implement. You can learn more about connection modes here.
Web | Mobile | Server | |
---|---|---|---|
đ± Device-mode | â | ||
âïž Cloud-mode | â | â |
- From the Segment web app, click Catalog.
- Search for âAppsFlyerâ in the Catalog, select it, and choose which of your sources to connect the destination to.
- In the destination settings, enter your
AppsFlyer Dev Key
, which can be retrieved from the App Settings section of your AppsFlyer account. - Follow the instructions in the GitHub repos: iOS SDK and Android SDK.
- After you build and release to the app store, we start translating and sending your data to AppsFlyer automatically.
Important: If you plan on using the server-side destination for an Android project, make sure to enter your Android App ID. If you are using only the mobile SDK, Android projects only require the AppsFlyer Dev Key. iOS projects always require both the AppsFlyer Dev Key and the Apple App ID. Also, note that if you do use the server-side destination, you will not be able to selectively disable calls sent to AppsFlyer using your Segment dashboard.
Additional device-mode set up for iOS 14 support
Segment updated the AppsFlyer iOS SDK to use version 6.0 beta
to prepare for tracking changes in iOS 14. The SDK beta version is compatible with the beta version of iOS 14 released by Apple, and supports both AppsFlyerâs aggregate attribution, and Appleâs AppTrackingTransperancy
framework, and more. See the AppsFlyer blog post about AppsFlyerâs new privacy-centric attribution model.
To use the latest AppsFlyer SDK to collect IDFAs, do the following:
- Upgrade to use Xcode12.
- Update your Segment AppsFlyer SDK to version 6.0.2 or later.
- Import and implement the AppTrackingTransparency (ATT) Framework.
- Navigate to your project
Info.plist
and add a âPrivacy - Tracking Usage Descriptionâ. This description appears in a popup when the application initializes in iOS 14. Users are prompted to indicate whether or not they want to allow tracking.
- Navigate to your project
-
Add and customize the following code in your
AppDelegate.m
file ondidFinishLaunchingWithOptions
to allow AppsFlyer collect IDFAs.// The following block is for applications wishing to collect IDFA. // for iOS 14 and later - The user will be prompted for permission to collect IDFA. // If permission granted, the IDFA will be collected by the SDK. // for iOS 13 and earlier - The IDFA will be collected by the SDK. The user will NOT be prompted for permission. if #available(iOS 14, *) { // Set a timeout for the SDK to wait for the IDFA collection before handling app launch AppsFlyerLib.shared().waitForAdvertisingIdentifier(withTimeoutInterval: 60) // Show the user the Apple IDFA consent dialog (AppTrackingTransparency) // Can be called in any place ATTrackingManager.requestTrackingAuthorization { (status) in } }
- Follow Segmentâs guide for collecting IDFA
Additional iOS Cloud Mode Set up for iOS 14
With the release of Segmentâs latest Analytics-iOS SDK, which includes support for upcoming iOS 14 tracking changes, you must decide if you need to collect the userâs IDFA or not. If you do not need to collect IDFA, you can update your Analytics-iOS SDK to the next version, and Segment sets device.adTrackingEnabled
to false
, and starts deleting the device.advertisingId
from the context object in your payloads. If you do need to collect the IDFA, you must import the IDFA closure as a config to the library, or import the Ad Tracking Transparency framework from Apple.
If you have the Can Omit AppsFlyerID setting enabled, but arenât sending an IDFA (either because you arenât passing one, or the user denied permission to collect it), AppsFlyer rejects the event.
To prevent this, you can enable the new Fallback to send IDFV when advertisingId key not present setting in your AppsFlyer destination settings. With this enabled, when you send data using cloud-mode (through the Segment servers), Segment sends the userâs IDFV (the device.id
) when device.advertisingId
is missing or blank AND âCan Omit AppsFlyerIDâ is enabled.
Server
AppsFlyer offers an augmentative server-side HTTP API intended for use along side the AppsFlyer mobile SDK. Use the cloud-mode destination with the mobile SDK to link out-of-app events (such as website or offline purchases) with attributed users and devices.
Important: The cloud-mode destination is not meant to replace the device-mode destination, and you should not use the cloud-mode destination by itself. AppsFlyer requires that you bundle the mobile SDK to correctly attribute user actions. Remember that if you pass in an appsFlyerId
on cloud-mode calls, you cannot prevent events from sending to AppsFlyer from the Segment app.
If you want to use AppsFlyer server-side only, contact your AppsFlyer representative, as this is an Enterprise Customer Feature.
Identify
If youâre not familiar with the Segment Specs, take a look to understand what the Identify method does. An example iOS call would look like:
[[SEGAnalytics sharedAnalytics] identify:@"12091906-01011992"
traits:@{ @"email": @"john.doe@example.com" }];
When you call .identify()
, we will use AppsFlyerâs setCustomerUserID
to send the userId
that was passed in.
Note: identify
calls are not supported using AppsFlyerâs HTTP API at the moment. You can only send .identify
calls if you have the AppsFlyer SDK bundled.
Track
If youâre not familiar with the Segment Specs, take a look to understand what the Track method does. An example iOS call would look like:
[[SEGAnalytics sharedAnalytics] track:@"Article Completed"
properties:@{ @"title": @"How to Create a Tracking Plan", @"course": @"Intro to Analytics" }];
When you call track
, Segment translates it automatically and sends the event to AppsFlyer.
We include all the event properties as callback parameters on the AppsFlyer event, and automatically translate properties.revenue
to the appropriate AppsFlyer purchase event properties based on our specâd properties.
Finally, we automatically use AppsFlyerâs transactionId
deduplication when you send an an orderId
(see the e-commerce spec).
Server
If youâd like to attribute offline events with a certain user or device, the server-side destination may be employed.
AppsFlyer requires the following properties for this attribution:
AppsFlyer Device ID
Send the AppsFlyer Device ID with each event at integrations.AppsFlyer.appsFlyerId
, see example below.
This identifier is unique to each device and can be retrieved using the AppsFlyer SDK. It is a good idea to store this value in an external database where it may be easily accessible by a server or website environments.
Device Type
AppsFlyer requires the userâs device type as either 'ios'
or 'android'
, passed at context.device.type
object, see example below.
Advertising ID
AppsFlyer requires the passing of an Advertising ID (referred to as IDFA on iOS and Advertising ID on Android) at context.device.advertisingId
, see example below:
// node.js library example
analytics.track({
event: 'Membership Upgraded',
userId: '97234974',
context: {
device: {
type: 'ios',
advertisingId: '159358'
}
},
integrations: {
AppsFlyer: {
appsFlyerId: '1415211453000-6513894'
}
}
});
Check your specific serverside library docs for specifics on how to format the method properly.
Finally, the serverside component will look for the following properties
and handle them specially:
ip
(this should be theip
of your customerâthis is not collected by Segmentâs libraries out-of-the-box)timestamp
(refer to AppsFlyerâs docs on how they process timestamps. Since our libraries generate a timestamp, we will always set this value)currency
(defaults to"USD"
)revenue
(ForOrder Completed
events, precedence is given tototal
, falling back toproperties.revenue
)
All other properties
will be sent to AppsFlyer as custom properties inside eventValue
.
Note: Be sure to calibrate/update the time window in AppsFlyerâs dashboard to see your events!
Install Attributed
Client
Segment will automatically trigger an Install Attributed
event if you have trackAttributionData enabled in your settings, and the Segment-AppsFlyer integration installed in your app. The event payload will adhere to our Install Attributed
event specification documented here and will propagate to your other downstream destinations.
Server
If you are tracking events server-side, AppsFlyer can still send attribution postbacks but you will need to configure this functionality in your AppsFlyer account. To enable this, navigate to your AppsFlyer app and on the sidebar of the main screen click on Integrated Partners and search for Segment. You will be prompted with a couple of configuration options and asked to input your Segment Write Key. Once enabled, successfully attributed app installs will begin showing up as Install Attributed
events similar to the client side behavior documented above.
If you are sending in the attribution data yourself, for iOS be sure the following properties are sent in within the campaign object on the Install Attributed
or Application Opened
event so Appsflyer can correctly attribute it as an Apple Search Ad event. These values should be returned by the Apple Search Ads API:
"campaign": {
"content": "keyword1keyword2",
"ad_creative": "OrgName",
"conversion_date": "2018-03-07T04:05:50Z",
"ad_group": "US-iOS-campaign-Exact",
"id": "123",
"ad_group_id": "456",
"name": "US-iOS-campaign",
"click_date": "2018-03-06T04:05:50Z",
"lineitem_id":"789",
"attribution":"true",
"lineitem_name":"US-iOS-campaign-Name"
}
For example, an attribution event coming from an attribution partner would look like:
[[SEGAnalytics sharedAnalytics] track:@"Install Attributed", properties: @{
@"provider" : @"Appsflyer/Tune/Kochava/Branch",
@"campaign" : @{
@"source" : @"Network/FB/AdWords/MoPub/Source",
@"name" : @"Campaign Name",
@"content" : @"Organic Content Title",
@"ad_creative" : @"Red Hello World Ad",
@"ad_group" : @"Red Ones",
@"conversion_date": @"2018-03-07T04:05:50Z",
@"id": @"123",
@"ad_group_id": @"456",
@"click_date": @"2018-03-06T04:05:50Z",
@"lineitem_id":@"789",
@"attribution":@"true",
@"lineitem_name":@"US-iOS-campaign-Name"
}
}];
Other Features
Revenue Tracking
The destination automatically recognizes specâd revenue
property and translates them to AppsFlyerâs revenue tracking method.
Transaction De-duplication
The destination automatically recognizes the specâd orderId
 property, and sends it as the Transaction ID to AppsFlyer for revenue de-duplication.
In-App Purchase Receipts
The destination does not currently support in-app purchase receipts. If this is important to you, email support@appsflyer.com.
Deeplinking
The destination does not automatically support out-of-the-box deeplinking (you need to write code here regardless!).
Therefore, you can use AppsFlyerâs OneLink integration which is a single, smart, tracking link that can be used to track on both Android and iOS. OneLink tracking links can launch your app when it is already installed instead of redirecting the user to the app store.
For more details, review the AppsFlyer OneLink set up Guide. More information is available in the AppsFlyer SDK Integration Guides (iOS, Android) and Segmentâs mobile FAQs (iOS, Android).
Personas
You can send computed traits and audiences generated using Segment Personas to this destination as a user property. To learn more about Personas, contact us for a demo.
For user-property destinations, an identify call is sent to the destination for each user being added and removed. The property name is the snake_cased version of the audience name, with a true/false value to indicate membership. For example, when a user first completes an order in the last 30 days, Personas sends an Identify call with the property order_completed_last_30days: true
. When the user no longer satisfies this condition (for example, itâs been more than 30 days since their last order), Personas sets that value to false
.
When you first create an audience, Personas sends an Identify call for every user in that audience. Later audience syncs only send updates for users whose membership has changed since the last sync.
Settings
Segment lets you change these destination settings from the Segment app without having to touch any code.
Android App ID
Your Android Appâs ID. Find this in your AppsFlyerâs âMy Appâ dashboard. It should look something like âcom.appsflyer.myappâ. This is required for Android projects if you want to send events using the server side integration.
Apple App ID (iOS)
Your Appâs ID, which is accessible from iTunes or in AppsFlyerâs âMy Appâ dashboard. This is optional for Android projects, and only required for iOS projects.
AppsFlyer Dev Key
Your unique developer ID from AppsFlyer, which is accessible from your AppsFlyer account.
Can Omit AppsFlyerId
Only applicable for Appsflyerâs Business Tiers customers using server-side or cloud mode destination. Please contact your AppsFlyer representative for more information. This setting allows to use the advertising ID as appsflyer ID.
Enable HTTP fallback (Android)
If selected, HTTPS calls will fallback on HTTP
Fallback to send IDFV when advertisingId key not present (Server-Side Only)
With the update to use analytics-ios v4.x SDK if adTrackingEnabled is set to false, the advertisingId key will be deleted from the event. If you have the setting enabled âCan Omit AppsFlyerIdâ, these events will fail when sent to AppsFlyer API. To prevent these event failures in this scenario enable this send the IDFV instead. When the âCan Omit AppsFlyerIdâ setting is enabled if the IDFA is zeroed out, we will also send an IDFV when this setting is enabled.
Roku App ID
IMPORTANT: In order to send Roku data, you must contact your AppsFlyer representative as this type of data stream requires a full server to server integration which is available but is gated as a AppsFlyer Enterprise Customer feature. Without AppsFlyerâs consent we are unable to forward your Roku data. Your Roku Appâs ID. Find this in your AppsFlyerâs âMy Appâ dashboard. This is required for Roku projects if you want to send events using the server side integration.
Track Attribution Data
Send attribution data to Segment and other tools as a track call (mobile libraries only).
This page was last modified: 26 Oct 2020
Need support?
Questions? Problems? Need more info? Contact us, and we can help!