AppsFlyer Destination

Segment makes it easy to send your data to AppsFlyer (and lots of other destinations). Once you've tracked your data through our open source libraries we'll translate and route your data to AppsFlyer in the format they understand. Learn more about how to use AppsFlyer with Segment.

AppsFlyer helps marketers to pinpoint targeting, optimize ad spend and boost ROI.

Getting Started

Mobile Components

The Segment<>AppsFlyer SDK must be packaged in your app for both iOS and Android. The most detailed steps for setting up AppsFlyer via Segment may be found in each Github repo: iOS app and Android app

Server-Side Components

AppsFlyer offers an augmentative server side HTTP API intended for use along side their mobile SDK. Use the server side destination alongside the mobile SDK to associate out-of-app events such as website or offline purchases with attributed users/devices. Please read further for more information on this functionality.

Important: Keep in mind that the server side destination is not meant to supplant the client side SDK! In order for AppsFlyer to properly attribute, you must bundle their mobile SDK! The server side destination should not be used alone. Also, keep in mind if you are passing in appsFlyerId for server-side calls, you will not be able to disable events from sending to AppsFlyer via your Segment dashboard.

Dashboard steps

To enable AppsFlyer in Segment dashboard, take the following steps:

  • Enter your unique AppsFlyer Dev Key, which is accessible from your AppsFlyer account, in Segment’s destination settings.
  • 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, please 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 via your Segment dashboard.

Identify

When you call .identify(), we will use AppsFlyer’s setCustomerUserID to send the userId that was passed in. We will lookup and send the following traits:

  • email
  • firstName
  • lastName
  • username
  • currencyCode

We will send these traits using AppsFlyer’s setAdditionalData.

identify calls are not supported via AppsFlyer’s HTTP API at the moment. You can only send .identify calls if you have the AppsFlyer SDK bundled.

Track

When you call track, we translate it automatically and send 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-based de-duplication when you send an an orderId (see the e-commerce spec).

Server-Side Tracking

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 (Optional)

AppsFlyer recommends passing 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 the ip 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 (For Order Completed / Completed Order events, precedence is given to total, falling back to properties.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!

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, please 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, please review the AppsFlyer OneLink Setup Guide. More information is available in the AppsFlyer SDK Integration Guides (iOS, Android) and Segment’s mobile FAQs (iOS, Android).


Supported Sources and Connection Modes

WebMobileServer
📱 Device-based
☁️ Cloud-based

To learn more about about Connection Modes and what dictates which we support, see here.

Segment offers an optional Device-based Connection Mode for Mobile data with AppsFlyer. If you’d like to use those features that require client-based functionality, follow the steps above to ensure you have packaged the AppsFlyer SDK with Segment’s.

Settings

Segment lets you change these destination settings via your Segment dashboard without having to touch any code.

Enable HTTP fallback (Android)

If selected, HTTPS calls will fallback on HTTP

Track Attribution Data

Send attribution data to Segment and other tools as a track call (mobile libraries only).

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.


If you have any questions or see anywhere we can improve our documentation, please let us know or kick off a conversation in the Segment Community!