Android 拡張ディファードディープリンク

概要

拡張ディファードディープリンクを使用すると、特定のシナリオで新規ユーザーにディープリンクを使用できます:

  • When UDL returns NOT_FOUND even though a relevant install occurred.
  • When UDL returns FOUND but the deep linking data is missing parameters, which are not deep_link_value and deep_link_sub1-10.
    Main examples for such scenarios:
    • Meta adsやTwitterなどのSRN(Self Reporting Network)内のリンクをクリックした場合
    • Clicking a link that doesn't contain deep_link_value or deep_link_sub1-10 used for deep-linking, for example, old links created before deep_link_value existed that are still in use.
    • クリックからインストールまでの時間が UDLルックバック期間 (15 分) を超えた場合

To allow deferred deep linking when UDL returns NOT_FOUND, onConversionDataSuccess callback should check whether it should handle the deferred deep linking.
onConversionDataSuccess is part of the Get Conversion Data(GCD) API. Its main purpose is to gather conversion data inside the device.
In the use case outlined here onConversionDataSuccess takes advantage of the fact that all deferred deep linking parameters are passed to the callback, on top of the conversion data.

前提条件

実装

  1. onConversionDataSuccess should detect cases where deferred deep linking should occur that UDL didn't handle.

    詳細:コード分析

  2. onConversionDataSuccess {0} は、UDLが処理しなかったディファードディープリンクが発生するケースを検出する必要があります。

コードの例

Code dissect

  1. Implement the Get Conversion Data API listener AppsFlyerConversionListener.

    All methods of the listener must be implemented, even though onAppOpenAttribution and onAttributionFailure are mutually exclusive with UDL, and will not be called.

  2. コンバージョンデータのペイロードをフィルターすることで、ディファードディープリンクシナリオを検出します:
    • af_status == Non-Organic
    • is_first_launch == true
  3. When deferred deep linking is detected, filter-out the cases that were already handled by UDL.
    In the example that follows, all the links contain deep_link_value.
    It is recommended for UDL to signal with a flag that deferred deep linking is already handled, and onConversionDataSuccess should skip.
  4. onConversionDataSuccess should verify the conversion data holds parameters that are used to route users inside the application. For example fruit_name in the example that follows.
  5. ユーザーをディファードディープリンク先にルーティングします。

Code snippet

    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")){
                if( Objects.requireNonNull(conversionDataMap.get("is_first_launch")).toString().equals("true")){
                    Log.d(LOG_TAG,"Conversion: First Launch");
                    //Deferred deep link in case of a legacy link
                    if(conversionDataMap.containsKey("fruit_name")){
                        if (conversionDataMap.containsKey("deep_link_value")) { //Not legacy link
                            Log.d(LOG_TAG,"onConversionDataSuccess: Link contains deep_link_value, deep linking with UDL");
                        }
                        else{ //Legacy link
                            conversionDataMap.put("deep_link_value", conversionDataMap.get("fruit_name"));
                            String fruitNameStr = (String) conversionDataMap.get("fruit_name");
                            DeepLink deepLinkData = mapToDeepLinkObject(conversionDataMap);
                            goToFruit(fruitNameStr, deepLinkData);
                        }
                    }
                } else {
                    Log.d(LOG_TAG,"Conversion: Not First Launch");
                }
            } else {
                Log.d(LOG_TAG, "Conversion: This is an organic install.");
            }
        }

        @Override
        public void onConversionDataFail(String errorMessage) {
            Log.d(LOG_TAG, "error getting conversion data: " + errorMessage);
        }

        @Override
        public void onAppOpenAttribution(Map<String, String> attributionData) {
            Log.d(LOG_TAG, "onAppOpenAttribution: This is fake call.");
        }

        @Override
        public void onAttributionFailure(String errorMessage) {
            Log.d(LOG_TAG, "error onAttributionFailure : " + errorMessage);
        }
    };

⇲ Github リンク:Java

テスト

📘

重要

The following testing scenario demonstrates the handling of deferred deep linking from links that contain custom parameters but not deep_link_value and deep_link_sub1-10 parameters.
This testing scenario is also relevant for all extended deferred deep linking described earlier.

Before you begin

Test link

既存のOneLinkリンクを使用することも、テスト用にマーケティング担当者に新しいリンクを作成してもらうこともできます。OneLinkのURLは、ショートリンクとロングリンクのどちらでも使用できます。

リンクへ一時的なパラメータを追加する

  • リンクのドメインとOneLinkテンプレートのみを使用してください。
    例: {0} https://onelink-basic-app.onelink.me/H5hv.
  • Add OneLink custom parameters other than deep_link_value and deep_link_sub1-10, as expected by your application.
  • パラメータは、クエリパラメータとして追加する必要があります。

    • 例: https://onelink-basic-app.onelink.me/H5hv?deep_link_value=apples&deep_link_sub1=23

Perform the test

  1. 端末でリンクをクリックします。
  2. OneLinkの設定内容に基づき Google PlayまたはWebサイトにリダイレクトされます。
  3. アプリをインストールします。

    重要

    • アプリがまだ開発中で、まだストアにアップロードされていない場合は、次の画像が表示されます:
      drawing
    • - *アンドロイドスタジオ*またはあなたが使用する他のIDEからアプリケーションをインストールします。
  4. UDL detects the deferred deep linking, matches the install to the click, and retrieves the OneLink parameters to onDeepLinking callback. UDL will not find any parameters to route and exit.
  5. onConversionDataSuccess callback is called with the conversion data, which holds both custom parameters and attribution data.
  6. onConversionDataSuccess sets the custom parameters to route the user inside the application.

Expected logs results

📘

📘 次のログは、デバッグモードが有効になっている場合にのみ使用できます。

  • SDKが初期化された場合:

    D/AppsFlyer_6.9.0: Initializing AppsFlyer SDK: (v6.9.0.126)
    
  • 次のログは直接ディープリンクを参照しており、ディファードディープリンクシナリオでは無視できます:

    D/AppsFlyer_6.9.0: No deep link detected
    
  • UDL APIの開始:

    D/AppsFlyer_6.9.0: [DDL] start
    
  • UDLがAppsFlyerにクエリを送信し、このインストールとの一致を問い合わせる:

    D/AppsFlyer_6.9.0: [DDL] Preparing request 1
    ...
    I/AppsFlyer_6.9.0: call = https://dlsdk.appsflyer.com/v1.0/android/com.appsflyer.onelink.appsflyeronelinkbasicapp?af_sig=<>&sdk_version=6.9; size = 239 bytes; body = {
          ...
          TRUNCATED
          ...
    }
    
  • UDL は応答を受け取り、呼び出します onDeepLinking コールバック status=FOUND およびOneLinkリンクデータ:

    D/AppsFlyer_6.9.0: [DDL] Calling onDeepLinking with:
      {"deepLink":"{\"campaign_id\":\"\",\"af_sub3\":\"\",\"match_type\":\"probabilistic\",\"af_sub1\":\"\",\"deep_link_value\":\"\",\"campaign\":\"\",\"af_sub4\":\"\",\"timestamp\":\"2022-12-07T09:32:52.256\",\"click_http_referrer\":\"\",\"af_sub5\":\"\",\"media_source\":\"\",\"af_sub2\":\"\",\"is_deferred\":true}","status":"FOUND"}
    
  • GCDがコンバージョンデータを取得:

GET:https://gcdsdk.appsflyer.com/install_data/v4.0/com.appsflyer.onelink.appsflyeronelinkbasicapp?devkey=XXXXXXXXX&device_id=1670405582645-822555416155480367
  • onConversionDataSuccess is called with conversion data as input:
 D/AppsFlyer_6.9.0: [GCD-A02] Calling onConversionDataSuccess with:
    {
        ...
        is_first_launch=true, 
        ...
        fruit_amount=56,
        fruit_name=apples, 
        ...
        af_status=Non-organic,
        ...
    }