Attribution callbacks

You can register a delegate callback to notify you of tracker attribution changes. The Adjust SDK cannot provide this information synchronously. This is due to the different sources considered for attribution.

Follow the steps in this article to implement the optional delegate protocol in your app.

Important:
You need to add the attribution callback to your config instance before you start the SDK.
Java
Javascript
AdjustConfig config = new AdjustConfig(this, appToken, environment);

config.setOnAttributionChangedListener(new OnAttributionChangedListener() {
    @Override
    public void onAttributionChanged(AdjustAttribution attribution) {}
});

Adjust.onCreate(config);

The SDK will call the listener function when it receives the final attribution data. Within the listener function, you'll have access to the AdjustAttribution object. Here is a quick summary of its properties:

All properties are returned as a JSON object. Any values that are not populated will be sent back as nil.

Note:
Cost data (costType, costAmount, and costCurrency) are only available when the needsCost property on the config object is set to true.
ValuesData typeDescription
trackerTokenStringThe token of the tracker to which the device is currently attributed.
trackerNameStringThe name of the tracker to which the device is currently attributed.
networkStringThe name of the network to which the device is currently attributed.
campaignStringThe name of the campaign to which the device is currently attributed.
adgroupStringThe name of the adgroup to which the device is currently attributed.
creativeStringThe name of the creative to which the device is currently attributed.
clickLabelStringThe click label that the install is tagged with.
adidStringThe unique Adjust ID assigned to the device.
costTypeStringThe campaign pricing model (e.g. cpi).
costAmountNumberThe cost of the install.
costCurrencyStringThe code of the currency associated with the cost. This should be a three character string that follows the ISO 4217 standard
fbInstallReferrerStringThe Facebook Install Referrer information. This is populated if the install came from a Facebook ad.

Facebook install referrer

The Adjust SDK receives Facebook install referrer information as a string property in the AdjustAttribution object. You can access this information by serializing the content as a JSON object.

Java
Kotlin
config.setOnAttributionChangedListener(new OnAttributionChangedListener() {
      @Override
      public void onAttributionChanged(AdjustAttribution adjustAttribution) {
        JSONObject fbInstallReferrerJSONObject = extractFBInstallReferrerJSON(adjustAttribution);
      }
});

@Nullable
JSONObject extractFBInstallReferrerJSON(AdjustAttribution adjustAttribution) {
  try {
    return new JSONObject(adjustAttribution.fbInstallReferrer);  
  } catch (JSONException e) {
    Log.d("example", e.getMessage());  
  }
  return null;
}

User attribution

Note:
This method is available in Adjust SDK v4.11.0 and later.

You can call the Adjust.getAttribution method to get the user's current attribution. This will return all the information found in the AdjustAttribution object.

Java
Javascript
AdjustAttribution attribution = Adjust.getAttribution();
Note:
Information about current attribution is available after the backend has tracked the installation. The attribution callback will fetch this information for you to use.