Getting the App Install Source
There are two ways to retrieve the installation source: via Google Play or via AppsFlyer.
- Add the AppsFlyer library.
dependencies {
...
implementation 'com.appsflyer:af-android-sdk:6.3.2'
implementation "com.android.installreferrer:installreferrer:2.2"
}-
Integrate AppsFlyer according to their documentation.
-
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.");
}
}
}-
Create a method that adds an action to cusomer's profile and/or populates customer's additional field.
-
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>}")Instruction
- Add the installreferrer library in build.gradle file.
dependencies {
...
implementation "com.android.installreferrer:installreferrer:2.2"
}- Connect to Google Play Services.
InstallReferrerClient referrerClient;
referrerClient = InstallReferrerClient.newBuilder(this).build();
referrerClient.startConnection(new InstallReferrerStateListener() {
@Override
public void onInstallReferrerSetupFinished(int responseCode) {
switch (responseCode) {
case InstallReferrerResponse.OK:
ReferrerDetails response = referrerClient.getInstallReferrer();
String referrerUrl = response.getInstallReferrer();
long referrerClickTime = response.getReferrerClickTimestampSeconds();
long appInstallTime = response.getInstallBeginTimestampSeconds();
boolean instantExperienceLaunched = response.getGooglePlayInstantParam();
break;
case InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
// API not available on the current Play Store app.
break;
case InstallReferrerResponse.SERVICE_UNAVAILABLE:
// Connection couldn't be established.
break;
}
}
@Override
public void onInstallReferrerServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
});-
Create a method that adds an action to cusomer's profile and/or populates customer's additional field.
-
Use the the previously created method from step 3 to send the obtained referrerUrl e.g., utm_source=google-play&utm_medium=organic as an action's custom field in Maestra.
Mindbox.executeAsyncOperation(applicationContext, "<operationSystemName>", "{<Request body with the obtained referrerUrl>}")Updated 7 months ago

