Conversion data

In this guide you will learn how to get conversion data using AppsFlyerConversionListener, as well as examples for using the conversion data.

Learn more about what is conversion data.

Before you begin

The following code examples require you import AppsFlyerLib and AppsFlyerConversionListener:

import com.appsflyer.AppsFlyerLib;
import com.appsflyer.AppsFlyerConversionListener;

Setting-up AppsFlyerConversionListener in Android SDK

AppsFlyerConversionListener overview

The AppsFlyerConversionListener interface lets you listen to conversions.

If you implement and register AppsFlyerConversionListener when calling init, its onConversionDataSuccess callback is invoked whenever:

  • A user opens the app
  • A user moves the app to the foreground

If for whatever reason the SDK fails to fetch the conversion data, onConversionDataFail is invoked.

Accessing attribution data

When invoked, onConversionDataSuccess returns a Map (called conversionDataMap in the example) that contains the conversion data for that install. The conversion data is cached the first time onConversionDataSuccess is called and will be identical on consecutive calls.

Organic vs. Non-organic conversions

A conversion can be either Organic or Non-organic:

  • An Organic conversion is an unattributed conversion that is usually the result of a direct install from an app store.
  • A Non-organic conversion is a conversion that is attributed to a media source

You can get the conversion type by checking the value of af_status in onConversionDataSuccess's payload. It can be one of the following values:

  • Organic
  • Non-organic

Example

AppsFlyerConversionListener conversionListener =  new AppsFlyerConversionListener() {
    @Override
    public void onConversionDataSuccess(Map<String, Object> conversionDataMap) {
        for (String attrName : conversionDataMap.keySet())
            Log.d(LOG_TAG, "Conversion attribute: " + attrName + " = " + conversionDataMap.get(attrName));
        String status = Objects.requireNonNull(conversionDataMap.get("af_status")).toString();
        if(status.equals("Organic")){
            // Business logic for Organic conversion goes here
        }
        else {
            // Business logic for Non-organic conversion goes here
        }
    }

    @Override
    public void onConversionDataFail(String errorMessage) {
        Log.d(LOG_TAG, "error getting conversion data: " + errorMessage);
    }

    @Override
    public void onAppOpenAttribution(Map<String, String> attributionData) {
        // Business logic goes here when UDL is not implemented
    }

    @Override
    public void onAttributionFailure(String errorMessage) {
        Log.d(LOG_TAG, "error onAttributionFailure : " + errorMessage);
    }

};

Deferred deep linking (Legacy method)

When the app is opened via deferred deep linking, onConversionDataSuccess's payload returns deep linking data, as well as attribution data.

Updated 4 days ago


Conversion data


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.