Importing attributions on Android

To set up import, call the attribution retrieval method on the client, then call the attribution sending method AppMetrica.reportExternalAttribution in the АppMetrica SDK.

AppsFlyer

  1. Register AppsflyerConversionListener.
  2. Set up the sending of attribution data (the AppMetrica.reportExternalAttribution method) in the AppMetrica SDK from AppsflyerConversionListener.
val appsflyerConversionListener = object : AppsFlyerConversionListener {
    // ...
    override fun onConversionDataSuccess(value: MutableMap<String, Any>?) {
        AppMetrica.reportExternalAttribution(ExternalAttributions.appsflyer(value))
    }
    // ...
}

AppsFlyerLib.getInstance().init(appsflyerKey, appsFlyerConversionListener, context)

AppsFlyerConversionListener appsFlyerConversionListener = new AppsFlyerConversionListener() {
    // ...
    @Override
    public void onConversionDataSuccess(Map<String, Object> value) {
        AppMetrica.reportExternalAttribution(ExternalAttributions.appsflyer(value));
    }
    // ....
};

AppsFlyerLib.getInstance().init(appsflyerKey, appsFlyerConversionListener, context);

Adjust

  1. Register OnAttributionChangedListener.
  2. Set up the sending of attribution data (the AppMetrica.reportExternalAttribution method) in the AppMetrica SDK from OnAttributionChangedListener.
val config = AdjustConfig(context, adjustToken, adjustEnvironment)

config.setOnAttributionChangedListener { attribution ->
    AppMetrica.reportExternalAttribution(ExternalAttributions.adjust(attribution))
}

Adjust.onCreate(config)

AdjustConfig config = new AdjustConfig(context, adjustToken, adjustEnvironment);

config.setOnAttributionChangedListener(attribution -> {
    // ...
    AppMetrica.reportExternalAttribution(ExternalAttributions.adjust(attribution));
    // ...
});

Adjust.onCreate(config);

Kochava

  1. Make an asynchronous attribution request by calling Tracker#retrieveInstallAttribution().
  2. Set up the sending of attribution data (the AppMetrica.reportExternalAttribution method) in the AppMetrica SDK from RetrievedInstallAttributionListener.
Tracker.getInstance().retrieveInstallAttribution { installAttribution ->
    AppMetrica.reportExternalAttribution(ExternalAttributions.kochava(installAttribution.toJson()))
}
Tracker.getInstance().retrieveInstallAttribution(installAttribution ->        
    AppMetrica.reportExternalAttribution(ExternalAttributions.kochava(installAttribution.toJson()))
);

Tenjin

  1. Make an asynchronous attribution request by calling TenjinSDK#getAttributionInfo.
  2. Set up the sending of attribution data (the AppMetrica.reportExternalAttribution method) in the AppMetrica SDK from AttributionInfoCallback.
val tenjinSdk = TenjinSDK.getInstance(context, tenjinToken)
tenjinSdk.connect()

tenjinSdk.getAttributionInfo { attribution ->
    // ...
    AppMetrica.reportExternalAttribution(ExternalAttributions.tenjin(attribution))
    // ...
}

TenjinSDK tenjinSDK = TenjinSDK.getInstance(context, tenjinToken);
tenjinSDK.connect();

tenjinSDK.getAttributionInfo(attribution ->
    // ...
    AppMetrica.reportExternalAttribution(ExternalAttributions.tenjin(attribution))
    // ...
).

Airbridge

  1. Register OnAttributionResultReceiveListener.
  2. Set up the sending of attribution data (the AppMetrica.reportExternalAttribution method) in the AppMetrica SDK from OnAttributionResultReceiveListener.
val config = AirbridgeConfig.Builder(airbridgeAppName, airbridgeSdkAppToken)
    .setOnAttributionResultReceiveListener { map ->
      // ...
      AppMetrica.reportExternalAttribution(ExternalAttributions.airbridge(map))
      // ...
  }
  .build()

Airbridge.init(context, config)

AirbridgeConfig config = new AirbridgeConfig.Builder(airbridgeAppName, airbridgeSdkAppToken)
    .setOnAttributionResultReceiveListener(map -> {
      // ...
      AppMetrica.reportExternalAttribution(ExternalAttributions.airbridge(map));
      // ...
  })
  .build();

Airbridge.init(application, config);

Singular

  1. Register SingularDeviceAttributionHandler.
  2. Set up the sending of attribution data (the AppMetrica.reportExternalAttribution method) in the AppMetrica SDK from SingularDeviceAttributionHandler.
val config = SingularConfig(SINGULAR_SDK_KEY, SINGULAR_SDK_SECRET)
    .withSingularDeviceAttribution { map ->
      // ...
      AppMetrica.reportExternalAttribution(ExternalAttributions.singular(map))
      // ...
    }

Singular.init(context, config)

SingularConfig singularConfig = new SingularConfig(SINGULAR_SDK_KEY, SINGULAR_SDK_SECRET)
    .withSingularDeviceAttribution(map -> {
        // ...
        AppMetrica.reportExternalAttribution(ExternalAttributions.singular(map));
        // ...
    });

Singular.init(context, singularConfig);

If you didn't find the answer you were looking for, you can use the feedback form to submit your question. Please describe the problem in as much detail as possible. Attach a screenshot if possible.

Contact support