Getting the App Install Source

There are two ways to retrieve the installation source: via Google Play or via AppsFlyer.

  1. Add the AppsFlyer library.
dependencies {
    ...
    implementation 'com.appsflyer:af-android-sdk:6.3.2'
    implementation "com.android.installreferrer:installreferrer:2.2"
}
  1. Integrate AppsFlyer according to their documentation.

  2. Implement the AppsFlyerConversionListener, specifically the onConversionDataSuccess method.
    This method is triggered on the app’s first launch after installation via a tracking link and provides attribution data such as install details, media source, campaign, and other related parameters.

AppsFlyerConversionListener conversionListener = new AppsFlyerConversionListener() {
    @Override
    public void onConversionDataSuccess(Map<String, Object> conversionDataMap) {
        String status = Objects.requireNonNull(conversionDataMap.get("af_status")).toString();
        
        if (status.equals("Non-organic")) {
            String sourceID = (String) conversionData.get("media_source");
            String campaign = (String) conversionData.get("campaign");
            if (Objects.requireNonNull(conversionDataMap.get("is_first_launch")).toString().equals("true")) {
                Log.d(LOG_TAG, "Conversion: First Launch");
            } else {
                Log.d(LOG_TAG, "Conversion: Not First Launch");
            }
        } else {
            Log.d(LOG_TAG, "Conversion: This is an organic install.");
        }
    }
}
  1. Create a method that adds an action to cusomer's profile and/or populates customer's additional field.

  2. Use the the previously created method from step 4 to send the obtained sourceID as an action's custom field.

Mindbox.executeAsyncOperation(applicationContext, "<operationSystemName>", "{<request body with the obtained sourceId>}")