このドキュメントでは、Android 向け Google アナリティクス SDK v3 を使って、キャンペーンとトラフィック ソースを測定する方法の概要を説明します。
概要
Google アナリティクスでキャンペーンを測定すると、キャンペーンとトラフィックの参照元をアプリでのユーザー行動に結び付けること(アトリビューション)ができます。Android 向け Google アナリティクス SDK に備わっているキャンペーンとトラフィックの参照元アトリビューションでは、次のオプションを使用できます。
- Google Play キャンペーンのアトリビューション - Google Play ストアにユーザーを送り込んでアプリのダウンロードに貢献したキャンペーン、ウェブサイト、アプリを把握できます。
- 一般的なキャンペーンとトラフィックの参照元のアトリビューション - インストールされたアプリの起動に貢献したキャンペーンや参照 URL を把握できます。
次のセクションでは、各種のキャンペーンをアプリで測定するタイミングと方法を説明します。
キャンペーンのパラメータ
キャンペーンのパラメータは、アプリにユーザーを送り込んだトラフィックの参照元とキャンペーンに関する情報を渡すために使用します。
下の表には、Google Play キャンペーンや一般的なキャンペーンの測定で使用可能なキャンペーン パラメータがまとめられています。
パラメータ | 説明 | 例 |
---|---|---|
utm_campaign |
キャンペーン名: キーワード分析で、特定の商品プロモーション キャンペーンや戦略的キャンペーンを特定するために使用します。 | utm_campaign=spring_sale |
utm_source |
キャンペーンの参照元: 検索エンジンやニュースレターなどの参照元を特定するために使用します。 | utm_source=google |
utm_medium |
キャンペーンのメディア: メールやクリック単価(CPC)などのメディアを特定するために使用します。 | utm_medium=cpc |
utm_term |
キャンペーンのキーワード: 広告にキーワードを設定している有料検索で使用します。 | utm_term=running+shoes |
utm_content |
キャンペーンのコンテンツ: A/B テストやコンテンツ ターゲット広告で、同じ URL を参照する広告やリンクを区別するために使用します。 |
utm_content=logolink
utm_content=textlink
|
gclid |
Google 広告の自動タグ設定パラメータ: 広告の測定に使用します。この値は動的に生成され、変更することはできません。 |
一般的なキャンペーンとトラフィックの参照元のアトリビューション
インストールされたアプリは、広告キャンペーン、ウェブサイト、他のアプリからの参照によって起動される場合があります。そうしたケースでは、トラッカーのキャンペーン フィールドを直接設定することで、その参照を引き起こしたトラフィックの参照元やマーケティング キャンペーンを、後続のセッションのユーザー行動に貢献した要素として結び付けることができます。
たとえば、次の実装では、アプリを起動したインテントに Google アナリティクスのキャンペーン パラメータをチェックしています。
package com.example.app; import com.google.analytics.tracking.android.Fields; import com.google.analytics.tracking.android.GoogleAnalytics; import com.google.analytics.tracking.android.MapBuilder; import com.google.analytics.tracking.android.Tracker; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import java.util.Map; /* * An example of how to implement general campaign attribution in Android. * * If the intent that launched the Activity has a URI, parse it for campaign * parameters and send the referring data to Google Analytics. */ public class MainActivity extends Activity { private static final String GA_PROPERTY_ID = "UA-XXXX-Y"; private static final String SCREEN_LABEL = "Home Screen"; // This examples assumes the use of Google Analytics campaign // "utm" parameters, like "utm_source". private static final String CAMPAIGN_SOURCE_PARAM = "utm_source"; Tracker mTracker; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mTracker = GoogleAnalytics.getInstance(this).getTracker(GA_PROPERTY_ID); } @Override public void onStart() { super.onStart(); // Set screen name on tracker so that all subsequent hits will use this // value. mTracker.set(Fields.SCREEN_NAME, SCREEN_LABEL); // Get the intent that started this Activity. Intent intent = this.getIntent(); Uri uri = intent.getData(); // Send a screenview using any available campaign or referrer data. MapBuilder.createAppView().setAll(getReferrerMapFromUri(uri)); } /* * Given a URI, returns a map of campaign data that can be sent with * any GA hit. * * @param uri A hierarchical URI that may or may not have campaign data * stored in query parameters. * * @return A map that may contain campaign or referrer * that may be sent with any Google Analytics hit. */ Map<String,String> getReferrerMapFromUri(Uri uri) { MapBuilder paramMap = new MapBuilder(); // If no URI, return an empty Map. if (uri == null) { return paramMap.build(); } // Source is the only required campaign field. No need to continue if not // present. if (uri.getQueryParameter(CAMPAIGN_SOURCE_PARAM) != null) { // MapBuilder.setCampaignParamsFromUrl parses Google Analytics campaign // ("UTM") parameters from a string URL into a Map that can be set on // the Tracker. paramMap.setCampaignParamsFromUrl(uri.toString()); // If no source parameter, set authority to source and medium to // "referral". } else if (uri.getAuthority() != null) { paramMap.set(Fields.CAMPAIGN_MEDIUM, "referral"); paramMap.set(Fields.CAMPAIGN_SOURCE, uri.getAuthority()); } return paramMap.build(); } }
Google アナリティクスのキャンペーン パラメータ以外の形式でキャンペーン情報を取得している場合は、次のように Map
で設定し、手動で送信することもできます。
// May return null if EasyTracker has not yet been initialized with a property ID. EasyTracker easyTracker = EasyTracker.getInstance(this); easyTracker.set(Fields.SCREEN_NAME, "Home Screen"); // In this example, campaign information is set using a Map, rather than // a url string with Google Analytics campaign parameters. // Note that Fields.CAMPAIGN_KEYWORD is not necessary for this campaign. HashMap<String, String> campaignData = new HashMap<String, String>(); campaignData.put(Fields.CAMPAIGN_SOURCE, "email"); campaignData.put(Fields.CAMPAIGN_MEDIUM, "email marketing"); campaignData.put(Fields.CAMPAIGN_NAME, "summer_campaign"); campaignData.put(Fields.CAMPAIGN_CONTENT, "email_variation_1"); MapBuilder paramMap = MapBuilder.createAppView(); // Campaign data sent with this hit. // Note that the campaign data is set on the Map, not the tracker. easyTracker.send(paramMap .setAll(campaignData).build() );
Google Play キャンペーン アトリビューション
Google Play キャンペーンの測定機能を実装すると、Google Play ストアにユーザーを送り込んでアプリのダウンロードに貢献したキャンペーンとトラフィックの参照元を把握できます。Google Play キャンペーンの測定機能の実装を、すべての開発者の方におすすめします。
Google Play キャンペーンのアトリビューションを実装する
Google Play ストアでアプリがダウンロードされると、そのアプリがインストールされる際に Play ストアアプリから対象アプリに INTENT_REFERRER
(インテントの参照 URL)がブロードキャストされます。このインテントには、アプリの Google Play ストア ページ(存在する場合)へのアクセスに使用するリンクの referrer
パラメータの値が含まれます(存在する場合)。
アプリのダウンロードをキャンペーンに関連付けるには、Google Play ストアを参照するすべてのリンクに referrer
パラメータを追加し、BroadcastReceiver
をアプリに追加して、インテントに含まれるキャンペーン情報を Google アナリティクス トラッカーで受信および設定する必要があります。
ほとんどのデベロッパーは、SDK に付属の BroadcastReceiver
を使用することをおすすめします。付属のレシーバーを使用して Google Play ストア キャンペーンの測定を実装するには:
1. Google アナリティクスのレシーバーを AndroidManifest.xml
ファイルに追加します。マニフェストに Google アナリティクス レシーバーを追加するには、次のマークアップをコピーして貼り付けます。
<!-- Used for Google Play Store Campaign Measurement-->; <service android:name="com.google.analytics.tracking.android.CampaignTrackingService" /> <receiver android:name="com.google.analytics.tracking.android.CampaignTrackingReceiver" android:exported="true"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver>
2. Google Play キャンペーン パラメータを Google Play の URL に追加する
次に、Google Play ストアに直接リンクするすべての URL に referrer
パラメータを追加し、そのパラメータの値を、ソースを表す Google アナリティクス キャンペーン パラメータの文字列に設定します。次に例を示します。
https://play.google.com/store/apps/details?id=com.example.app &referrer=utm_source%3Dgoogle %26utm_medium%3Dcpc %26utm_term%3Dpodcast%252Bapps %26utm_content%3DdisplayAd1 %26utm_campaign%3Dpodcast%252Bgeneralkeywords
キャンペーン パラメータの文字列を作成するには、Google Play URL 生成ツールを使用するか、キャンペーン パラメータのリファレンス セクションで作成方法をご確認ください。
Google Play URL 生成ツール
下のツールを使用すると、Google Play キャンペーンの測定に必要な URL を生成できます。