컨버전 데이터

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

전환 데이터란에 대해 더 알아봅니다.

시작하기 전에

The following code examples require you import AppsFlyerLib and AppsFlyerConversionListener:

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

안드로이드 SDK에서 AppsFlerConversionListener 설정하기

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:

  • 사용자가 앱을 여는 경우
  • 사용자가 앱을 휴대폰 화면(foreground)으로 이동하는 경우

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

어트리뷰션 데이터 액세스하기

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

전환 데이터 메시지 로데이터. 오가닉이거나 논오가닉일 수 있습니다.

  • 오가닉 전환은 일반적으로 앱 스토어에서 직접 설치하여 발생하는 어트리뷰션되지 않은 전환입니다.
  • 논오가닉 전환은 미디어소스에 어트리뷰트된 전환입니다.

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

import com.appsflyer.AppsFlyerConversionListener;
import com.appsflyer.AppsFlyerLib;
import com.appsflyer.AppsFlyerLibCore.LOG_TAG;

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) {
      // Must be overriden to satisfy the AppsFlyerConversionListener interface.
      // Business logic goes here when UDL is not implemented.
    }

    @Override
    public void onAttributionFailure(String errorMessage) {
      // Must be overriden to satisfy the AppsFlyerConversionListener interface.
      // Business logic goes here when UDL is not implemented.
      Log.d(LOG_TAG, "error onAttributionFailure : " + errorMessage);
    }

};
import com.appsflyer.AppsFlyerConversionListener
import com.appsflyer.AppsFlyerLib
import com.appsflyer.AppsFlyerLibCore.LOG_TAG
  
class AFApplication : Application() {
    // ...
    override fun onCreate() {
        super.onCreate()
        val conversionDataListener  = object : AppsFlyerConversionListener{
            override fun onConversionDataSuccess(data: MutableMap<String, Any>?) {
                // ...
            }
            override fun onConversionDataFail(error: String?) {
                Log.e(LOG_TAG, "error onAttributionFailure :  $error")
            }
            override fun onAppOpenAttribution(data: MutableMap<String, String>?) {
                // Must be overriden to satisfy the AppsFlyerConversionListener interface.
                // Business logic goes here when UDL is not implemented.
                data?.map {
                    Log.d(LOG_TAG, "onAppOpen_attribute: ${it.key} = ${it.value}")
                }
            }
            override fun onAttributionFailure(error: String?) {
                // Must be overriden to satisfy the AppsFlyerConversionListener interface.
                // Business logic goes here when UDL is not implemented.
                Log.e(LOG_TAG, "error onAttributionFailure :  $error")
            }
        }
        AppsFlyerLib.getInstance().init(devKey, conversionDataListener, applicationContext)
        AppsFlyerLib.getInstance().start(this)
    }

}

Github 링크

디퍼드 딥링킹(레거시 메서드)

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