どのようにお手伝いできますか?

Google Analytics(GA4)連携ガイド

  • 更新

概要:AppsFlyerとGoogle Analytics(GA4)の連携により、広告主はAppsFlyerからGA4へアトリビューションデータと選択したアプリ内イベントを送信することができます。この連携は、Google Analytics for Firebase SDKがすでに実装されているiOSおよびAndroidアプリで動作します。

Important!

この連携は、Google Analytics for Firebase SDKがすでに実装されているiOSおよびAndroidアプリで動作します。連携を成功させるには、AppsFlyer SDKがFirebase SDKから値 app_instance_id を収集する必要があります。詳細は Firebase SDKからアプリのインスタンスIDを取得する方法を参照してください。

How does it work?

  • 新規インストールが発生すると、AppsFlyerはタッチポイントの詳細(メディアソース、キャンペーン名、キャンペーンID)をGA4に送信します。同時にFirebase SDKの app_instance_id を送信し、そのユーザーのタッチポイントがGA4に記録されるようにします。
  • アプリ内イベントが発生すると、GA4はそのイベントを最も直近のタッチポイントに紐付けます。

Google Analytics(GA4)の連携設定

以下の手順に従って、Google Analytics (GA4) との連携を設定してください。

1. Partner MarketplaceでGoogle Analytics(GA4)を選択します。

前提条件: 連携を設定する前に、 パートナーへ連絡し、アカウントを開設してください。

To set up a new integration:

  1. 有効化するには: AppsFlyer管理画面 左メニュー 連携 > Partner Marketplaceへ移動します。編集するには:AppsFlyer管理画面 左メニュー コラボレーション > 連携済みパートナーを選択します。
  2. Select the relevant app.
  3. Google Analytics (GA4) を検索して選択します。
  4. 連携設定をクリックしてください。 
    Note: The toggle must stay on (active) as long as you work with Google Analytics (GA4). Learn more
  5. Complete the configuration using the relevant tabs, as described below.

Google Analyticsの設定画面には連携タブのみ存在します。

連携済みパートナーの設定画面の詳細については、 こちらをクリックしてください。

2. AppsFlyerでGA4連携を設定

以下の設定を行います:

  1. 連携タブにて連携したいアプリを選択し、 パートナーを有効にするをオンにしてください。

    注記:トグルは、パートナーと作業している間、オン(有効)のままにしておく必要があります。

    パートナーのライセンス認証の詳細については、こちらを参照してください。

  2. Firebase App IDにFirebaseアプリの識別子を入力します。 Firebase App IDを見つける方法:Firebaseのドキュメントを参照してください。
  3. API Secretには、Google Analyticsへのポストバックを認証するためのAPI Secretを入力します。 APIシークレットはGoogleアナリティクスの管理画面から生成されます。 APIシークレットの閲覧、編集、作成を行うには、Googleドキュメントの指示に従ってください。ウェブデータストリームを選択するよう指示された場合は、代わりにAndroidまたはiOSデータストリームを選択してください。
  4. Advertising ID(IDFA)の代わりにCustomer user ID(CUID)を送信するには、Customer User IDトグルをオンにします。
  5. デフォルトのポストバックセクションの送信オプションで、オーガニックを含むすべてのメディアソースを選択します。

注記:

インストールポストバックには、タッチポイントの詳細(メディアソース、キャンペーン名、キャンペーンID)のみが含まれます。

3. Set default postbacks

AppsFlyer can send automatic postbacks to GA4 following user installs, including both installs and re-engagements (including re-attributions). Re-engagements occur when a user who already has the app installed opens it after clicking a campaign link. Learn more about default postbacks.

4. アプリ内イベントのポストバック設定

連携タブで、AppsFlyerのアプリ内イベントをポストバック経由で送信されるGoogle Analytics(GA4)イベントにマッピングします。

注

  • モバイルアプリのS2Sアプリ内イベントのポストバックは現在サポートされていません。
  • GA4はFirebase SDKとAppsFlyerの両方から送信されるイベントを重複排除しません。そのため、アプリ内イベントのポストバックは、Firebase SDK経由でGA4に送信されていないイベントに対してのみ設定することをお勧めします。
  1. アプリ内イベントポストバックを有効にします。
  2. イベントを追加をクリックして、SDK または サーバー間イベントをリストに追加してください。以下の表にて、設定する必要がある各項目について説明しています:

    パラメーター名 説明
    AppsFlyerイベント

    これは、アプリに連携されたSDKまたはサーバー間イベントからAppsFlyerが受信したイベントの名前です。

    ヒント:お探しのイベントが見つかりませんか?

    • Make sure to activate the event on a device with a non-organic installation, and recheck.
    • AppsFlyerイベントを入力し、カスタムを作成をクリックしてください。

    カスタムイベントのマッピングについてご参照ください。

    パートナー側のイベント名

    パートナー側で定義されている各イベントの固有の名前またはID。オプションは以下の通りです:

    • テキストフィールド: 対応するイベントIDをパートナーから取得します。
    • ドロップダウンボックス: 最適な事前定義されたAppsFlyerイベントを選択します。
    • そのまま:イベント名のマッピングなしで、イベントをそのまま送信します。
    for users from

    最適なイベントの送信オプションを選択します。

    • オーガニックを含む全メディアソース:任意のパートナーに紐づくイベント及びオーガニックイベントのポストバックを送信します。
    含む
    • データなし(デフォルト): イベント値なしでイベント自体のみを送信します。
    • イベント値も収益も送信: 収益値を含む全てのイベントパラメーターを送信します(イベント内にある場合)。
    • 収益は送信せず、イベント値のみ送信: 収益値以外のすべてのパラメーターを送信します。
  3. [任意] イベントの条件を設定するには、条件を追加アイコン(condition-2.png )をクリックします。
  4. 連携の保存をクリックします。
  5. ポストバックマッピングされたイベントが送信されます。
5. 開発者にポストバックのイベントマッピングを送信します。

アプリ内イベントのマッピングを設定したら、マッピングされた各イベントが以下の列の行に対応するテーブルを開発者に送信します:

  • AppsFlyerイベント:AppsFlyer SDKで計測しているイベントの名前。
  • Googleイベントにマッピング:Google Analytics側のイベントの名前。

Important!

Google Analyticsのカスタムイベントの名前として、Googleが定義済みのイベント名を使用しないでください。

  • AppsFlyerイベントパラメータ(必須): Google Analyticsに送信されるイベントポストバックに含める必要がある、定義済みのAppsFlyerイベントパラメータ。

Important!

イベントの定義には、定義済みのすべてのAppsFlyerイベントパラメータを表に記載されている通りに含める必要があります。 これが行われない場合、Google Analyticsはポストバックを拒否します。

イベントマッピング表

次の表には、すべてのGoogle Analyticsイベントと、その事前定義されたAppsFlyerパラメータが含まれています。デベロッパーに、マッピングしたイベントだけを含むテーブルを送信します。

AppsFlyer推奨名(オプション) Google広告のイベント名 定義済みのAFイベントパラメータ(必須)
af_add_payment_info add_payment_info af_currency, af_revenue, af_price, af_content_id, af_content
add_shipping_info af_currency, af_revenue, af_price, af_content_id, af_content
af_add_to_cart add_to_cart af_currency, af_revenue, af_price, af_content_id, af_content
af_add_to_wishlist add_to_wishlist af_currency, af_revenue, af_price, af_content_id, af_content
af_initiated_checkout begin_checkout af_currency, af_revenue, af_price, af_content_id, af_content
campaign_details campaign id, campaign name
af_spent_credits earn_virtual_currency af_revenue
generate_lead 非オーガニックインストールとして計測された端末上で、そのアプリ内イベントが発生しているかを確認し、再度チェックしてください。
join_group
af_level_achieved level_up
af_login login
post_score af_user_score
af_purchase purchase af_currency, af_revenue, af_price, af_content_id, af_content, af_receipt_id
refund af_currency, af_revenue, af_price, af_content_id, af_content, af_receipt_id
remove_from_cart af_currency, af_revenue, af_price, af_content_id, af_content
screen_view
af_search search
select_content
select_item af_price, af_content_id, af_content
select_promotion af_price, af_content_id, af_content
share
sign_up
spend_virtual_currency af_revenue
tutorial_begin
af_tutorial_completion tutorial_complete
af_achievement_unlocked Unlock_achievement af_achievement_id
view_cart af_currency, af_revenue, af_price, af_content_id, af_content
view_item af_currency, af_revenue, af_price, af_content_id, af_content
view_item_list af_price, af_content_id, af_content
view_promotion af_currency, af_revenue, af_price, af_content_id, af_content
view_search_results
af_ad_view ad_impression af_currency, af_revenue

定義済みのGoogleイベント名

次のイベント名は定義済みなので、カスタムイベント名として使用することはできません。

  • ad_activeview
  • ad_click
  • ad_exposure
  • ad_query
  • ad_reward
  • adunit_exposure
  • app_clear_data
  • app_exception
  • app_install
  • app_remove
  • app_store_refund
  • app_update
  • app_upgrade
  • dynamic_link_app_open
  • dynamic_link_app_update
  • dynamic_link_first_open
  • error
  • firebase_campaign
  • firebase_in_app_message_action
  • firebase_in_app_message_dismiss
  • firebase_in_app_message_impression
  • first_open
  • first_visit
  • in_app_purchase
  • notification_dismiss
  • notification_foreground
  • notification_open
  • notification_receive
  • notification_send
  • os_update
  • session_start
  • user_engagement
6. AppsFlyer SDKでアプリインスタンスIDを取得

ga_session_id はFirebaseアプリのセッションを一意に識別します。この値はFirebase SDKから取得し、setAdditionalData APIを使用してGA4に送信する必要があります。

開発者によるコードの実装:

  1. Firebase からapp_instance_id フィールドを収集します。
  2. インストール、セッション、アプリ内イベントにアプリのインスタンスIDを含めるために、アプリ初回起動の前に setAddiotionalData をコールします。

Important!

setAdditionalData (Android / Unity / React Native) and customData (iOS) accept a mapping of key-value pairs. Sends both app_instance_id and ga_session_id together in the same mapping, so both values are included. If you send them in separate setAdditionalData calls, the later one will overwrite the earlier one.

Android native

Kotlin

FirebaseAnalytics.getInstance(this).appInstanceId.addOnCompleteListener { task ->
   if (task.isSuccessful) {
       AppsFlyerLib.getInstance().setAdditionalData("app_instance_id", task.result)
    }
}

Java

FirebaseAnalytics.getInstance(this).getAppInstanceId().addOnCompleteListener(task -> {
       if (task.isSuccessful()) {
           AppsFlyerLib.getInstance().setAdditionalData("app_instance_id", task.getResult());
       }
  });

APIリファレンス: setAdditionalData

Android Native iOS Native Unity

Androidネイティブ iOSネイティブ Unity React Native

let appInstanceId = Analytics.appInstanceID()
    AppsFlyerLib.shared().customData = ["app_instance_id": appInstanceId]

Objective C

(void) fetchAnalyticsInstanceId {
           NSString *instanceID = [FIRAnalytics appInstanceID];
           [[AppsFlyerLib shared] setAdditionalData:@{@"app_instance_id": instanceID}];
}

APIリファレンス: customData

Unity
using Firebase.Analytics;
    public class AnalyticsManager : MonoBehaviour
    {
        private async void Start()
        {
           AppsFlyer.initSDK(devKey, appID, this);
           string appInstanceId = await FirebaseAnalytics.GetAnalyticsInstanceIdAsync();
           Dictionary <string, string> customData = new Dictionary<string, string>();
           customData.Add("app_instance_id", appInstanceId);
           AppsFlyer.setAdditionalData(appInstanceId);
           AppsFlyer.startSDK();
        }
}

APIリファレンス: setAdditionalData

React native

APIリファレンス: setAdditionalData

7. AppsFlyer SDKでGA4セッションIDを取得

アプリインスタンスID は、Firebaseアプリの特定のインストールを一意に識別します。この値は、AppsFlyer SDKがFirebase SDKから取得する必要があります。

開発者によるコードの実装:

  1. Firebase からga_session_id フィールドを収集します。
  2. 最初の起動前に setAdditionalData を呼び出してセッションIDを含めます。
  3. APIを呼び出すときは、キー ga_session_id を使用してください。

Important!

setAdditionalData (Android / Unity / React Native) and customData (iOS) accept a mapping of key-value pairs. If your app sends both app_instance_id and ga_session_id (see step 5), send them together in the same mapping so both values are included. If you send them in separate setAdditionalData calls, the later one will overwrite the earlier one.

Android native

Kotlin

FirebaseAnalytics.getInstance(this).sessionId.addOnCompleteListener { task ->
    if (task.isSuccessful) {
        AppsFlyerLib.getInstance().setAdditionalData("ga_session_id", task.result)
    }
}

Java

FirebaseAnalytics.getInstance(this).getSessionId().addOnCompleteListener(task -> {
    if (task.isSuccessful()) {
        AppsFlyerLib.getInstance().setAdditionalData("ga_session_id", task.getResult());
    }
});

APIリファレンス: setAdditionalData

iOS ネイティブ

Swift

if #available(iOS 14.0, *) {
    Analytics.sessionID { sessionID, error in
        if let sessionID = sessionID {
            AppsFlyerLib.shared().customData = ["ga_session_id": sessionID]
        }
    }
}

Objective-C

- (void)fetchAnalyticsSessionId {
    if (@available(iOS 14.0, *)) {
        [FIRAnalytics sessionIDWithCompletion:^(NSString * _Nullable sessionID, NSError * _Nullable error) {
            if (sessionID) {
                [[AppsFlyerLib shared] setAdditionalData:@{@"ga_session_id": sessionID}];
            }
        }];
    }
}

APIリファレンス: customData

Unity
using Firebase.Analytics;
using System.Threading.Tasks;
using AppsFlyerSDK;
using UnityEngine;
using System.Collections.Generic;

public class AnalyticsManager : MonoBehaviour
{
    private async void Start()
    {
        AppsFlyer.initSDK("yourDevKey", "yourAppID", this);

        // Get session ID
        string sessionId = await FirebaseAnalytics.GetSessionIdAsync();

        Dictionary<string, string> customData = new Dictionary<string, string>();
        customData.Add("ga_session_id", sessionId);
        AppsFlyer.setAdditionalData(customData);

        AppsFlyer.startSDK();
    }
}

APIリファレンス: setAdditionalData

8. GA4連携を確認

GA4に送信するポストバックのイベントが Googleアナリティクスに登録され、読み取られていることを確認します。広告主がデータを表示するには、次の2つの方法があります:

  • GA4 Explorationsを使用すると、関連するすべてのパラメーターを使用して、未加工のイベントデータを調べることができます。前提条件:Big Queryのエクスポートは、あなたのプロパティで設定する必要があります。
  • イベントレポートは、広告主がポストバックイベントを表示できるようにします。レポートは、複数のレポートコレクションの下にあります。
    例えば、イベントレポートは、ライフサイクルまたはゲームレポートコレクションのエンゲージメント > イベントにあります。 
    イベントレポートの詳細については、 Googleのドキュメントをご覧ください。

    GA4 Events report
  • トラフィック獲得レポートは、ウェブサイトやアプリの訪問者がどこから来ているのかを理解するのに役立ちます。

    ライフサイクルコレクションで獲得 > トラフィック獲得を選択します。

    トラフィック獲得レポートの詳細については、Googleのドキュメントをご覧ください。

    GA4 Traffic acquisition report