In order for us to provide optimal support, we would kindly ask you to submit any issues to [email protected]
When submitting an issue please specify your AppsFlyer sign-up (account) email , your app ID , production steps, logs, code snippets and any additional relevant information.
AppsFlyer SDK provides app installation and event tracking functionality. We have developed an SDK that is highly robust (7+ billion SDK installations to date), secure, lightweight and very simple to embed.
You can track installs, updates and sessions and also track additional in-app events beyond app installs (including in-app purchases, game levels, etc.) to evaluate ROI and user engagement levels.
Built with AppsFlyer Android SDK v4.10.0
- What Is Segment
- Quick Start
- API Methods
- SDK Initialization
- Tracking In-App Events
- Get Conversion Data
- Sample App
Segment makes it easy to send your data to AppsFlyer. Once you have tracked your data through Segment's open source libraries, the data is translated and routed to AppsFlyer in the appropriate format. AppsFlyer helps marketers to pinpoint targeting, optimize ad spend and boost ROI.
The AppsFlyer integration code is open-source on GitHub if you want to check it out.
Check out the Segment AppsFlyer docs here.
To enable AppsFlyer in the Segment dashboard, follow these steps:
- Enter your unique AppsFlyer Dev Key, which is accessible from your AppsFlyer account, in Segment’s destination settings.
- After you build and release to the app store, your data is translated and sent to AppsFlyer automatically.
The Segment AppsFlyer integration is entirely handled through Segment's servers, so you don’t need to bundle AppsFlyer's iOS or Android SDKs. Your Segment SDK will be enough.
AppsFlyer supports the identify
and track
methods.
Add the AppsFlyer Segment Integration dependency to your app build.gradle
file.
compile 'com.appsflyer:segment-android-integration:1.+'
compile 'com.android.installreferrer:installreferrer:1.0'
The AndroidManifest.xml should include the following permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
static final String SEGMENT_WRITE_KEY = "<YOUR_KEY>";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Analytics.Builder builder = new Analytics.Builder(this , SEGMENT_WRITE_KEY)
.use(AppsflyerIntegration.FACTORY)
...
(optional)
.logLevel(Analytics.LogLevel.VERBOSE)
.recordScreenViews()
.trackAttributionInformation() // Install Attributed event
.trackApplicationLifecycleEvents() // Application Opened , Application Updated , Application Installed events
.build();
Analytics.setSingletonInstance(builder.build());
}
Adding .trackAttributionInformation()
will send the Install Attributed
event to AppsFlyer.
Adding .trackApplicationLifecycleEvents()
will send Application Opened
, Application Updated
and Application Installed
events to AppsFlyer.
When you call track
, Segment translates it automatically and sends the event to AppsFlyer.
Segment includes all the event properties as callback parameters on the AppsFlyer event, and automatically translates properties.revenue
to the appropriate AppsFlyer purchase event properties based on Segment's spec’d properties.
Finally, Segment automatically uses AppsFlyer’s transactionId-based de-duplication when sending an an orderId
.
Purchase Event Example:
Map<String, Object> eventValue = new HashMap<String, Object>();
eventValue.put("productId","com.test.id");
eventValue.put("revenue","1.00");
eventValue.put("currency","USD");
Analytics analytics = Analytics.with(this);
Properties properties = new Properties();
properties.putAll(eventValue);
analytics.track("purchase", properties);
Note: AppsFlyer will map revenue -> af_revenue
and currency -> af_currency
.
Check out the Segment docs on track here.
When you identify
a user, that user’s information is passed to AppsFlyer with customer user Id
as AppsFlyer’s External User ID. Segment’s special traits recognized as AppsFlyer’s standard user profile fields (in parentheses) are:
customerUserId
(Customer User Id
)
currencyCode
(Currency Code
)
All other traits will be sent to AppsFlyer as custom attributes.
Analytics analytics = Analytics.with(this);
analytics.identify("a user's id", new Traits()
.putName("a user's name")
.putEmail("[email protected]"),
null);
Check out the Segment docs on indentify here.
For Conversion data your should call the method below. Based on the type
parameter you can differentiate between install data (for deferred deep linking) and deep link data (for direct deep linking)
AppsflyerIntegration.cld = new AppsflyerIntegration.ConversionListenerDisplay() {
@Override
public void display(Map<String, String> attributionData) {
if (attributionData.get("type").equals("onInstallConversionData")) {
for (String attrName : attributionData.keySet()) {
Log.d(TAG, "GCD attribute: " + attrName + " = " +
attributionData.get(attrName));
}
if (attributionData.get("is_first_launch").equals("true")) {
// Process Deferred Deep Linking here
Log.d(TAG, "GCD This is first launch");
} else {
Log.d(TAG, "GCD This is not first launch");
}
} else {
// Process Direct Deep Linking here
for (String attrName : attributionData.keySet()) {
Log.d(TAG, "OAOA attribute: " + attrName + " = " +
attributionData.get(attrName));
}
}
}
};
In order for Conversion Data to be sent to Segment, make sure you have enabled "Track Attribution Data" in AppsFlyer destination settings:
AppsFlyer has created a sample Android application that integrates AppsFlyer via Segment. Check it out at the Github repo.