このドキュメントは、モバイル開発者の方を対象に、アナリティクスを使用してユーザーの操作を測定し、アプリの利用状況について把握する方法を説明しています。
はじめに
モバイルアプリ向け Google アナリティクスは、ユーザーの操作を測定するプラットフォームを提供し、お客様のアプリに対するユーザーの利用状況を詳細に把握して最適化する支援をします。
Google アナリティクスのデフォルトでは、アプリについて次の情報が自動的に提供されます。
- ユーザーとセッションの数
- セッション継続時間
- オペレーティング システム
- 携帯端末のモデル
- 地域
このガイドでは、ユーザーとユーザーの行動をより深く理解するために Google アナリティクスの追加機能を実装する方法を説明します。
始める前に
このガイドでの作業を始める前に、以下の関連資料を読んで、モバイルアプリ向け Google アナリティクスの設定方法についてかくにんすることをおすすめします。
- ターゲットとするプラットフォームの SDK をインストールします。
- モバイルアプリ解析の設定に関するベスト プラクティス
概要
ドラゴン キャッチャー
このガイドでは、サンプルアプリを使用して、追加の Google アナリティクス機能を実装する方法を見ていきます。このアプリは「ドラゴン キャッチャー(Dragon Catcher)」という名前の、次の特徴を持つゲームです。
- 1 つのレベルは、プレーヤー、ドラゴン、フェンスで囲まれたエリア、泉、木から構成されます。
- プレーヤーの目的は、ドラゴンをフェンスの内側に追い込んで捕まえることです。
- プレーヤーは、レベル内の別のエリアや、泉や魔法の木が生えている場所などを訪れることができます。
- プレーヤーは、すべてのドラゴンを捕まえると次のレベルに進みます。
- プレーヤーは、第 1 レベルの「荒れ地(Barren Fields)」からゲームを開始します。
Google アナリティクスを使用すれば、ドラゴン キャッチャーでのユーザーの行動について、次のようなデータを取得することができます。
- ユーザーはどのような操作を行っていますか?(イベント)
- ユーザーがアプリに支払っている金額はいくらですか?(e コマース)
- アプリの目標が達成されているかどうかを確認する(目標)
- 特定のトレイトを持つユーザーは、どのような動作をしますか? (カスタム ディメンションとカスタム指標)
- ユーザーがタスクを完了するまでにどれくらいの時間がかかりますか?(カスタム速度)
この後のセクションでは、ドラゴン キャッチャーに Google アナリティクス機能を実装することにより、上記についてのデータを取得する方法を解説します。
ユーザーがどんなアクションを実行しているか(イベント)
アプリ内でトラッキングしたい重要なアクションがあれば、このアクションを説明するために
Google アナリティクスのイベントを使用することができます。イベントは、category
、action
、label
、value
の 4 つのパラメータで構成されます。Google アナリティクスのイベントの仕組みについて詳しくは、イベント トラッキングの仕組みをご覧ください。
たとえば、ユーザーがドラゴンを救出したり、レベル内の特定のエリアを訪れたりするアクションはドラゴン キャッチャーでは重要なため、イベントを使用して測定します。次のコード スニペットは、Google アナリティクスでこれらのアクションを測定する方法を示しています。
Android SDK v4
// To determine how many dragons are being rescued, send an event when the // player rescues a dragon. tracker.send(new HitBuilders.EventBuilder() .setCategory("Barren Fields") .setAction("Rescue") .setLabel("Dragon") .setValue(1) .build()); // To determine if players are visiting the magic tree, send an event when the // player is in the vicinity of the magic tree. tracker.send(new HitBuilders.EventBuilder() .setCategory("Barren Fields") .setAction("Visited") .setLabel("Magic Tree") .setValue(1) .build()); // To determine if players are visiting the well, send an event when the player // is in the vicinity of the well. tracker.send(new HitBuilders.EventBuilder() .setCategory("Barren Fields") .setAction("Visited") .setLabel("Well") .setValue(1) .build());
iOS SDK v3
// To determine how many dragons are being rescued, send an event when the // player rescues a dragon. [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Barren Fields" action:@"Rescue" label:@"Dragon" value:@1] build]]; // To determine if players are visiting the magic tree, send an event when the // player is in the vicinity of the magic tree. [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Barren Fields" action:@"Visited" label:@"Magic Tree" value:@1] build]]; // To determine if players are visiting the well, send an event when the player // is in the vicinity of the well. [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Barren Fields" action:@"Visited" label:@"Well" value:@1] build]];
Unity v3 向け Google アナリティクス プラグイン
// To determine how many dragons are being rescued, send an event when the // player rescues a dragon. googleAnalytics.LogEvent("Barren Fields", "Rescue", "Dragon", 1); // To determine if players are visiting the magic tree, send an event when the // player is in the vicinity of the magic tree. googleAnalytics.LogEvent("Barren Fields", "Visited", "Magic Tree", 1); // To determine if players are visiting the well, send an event when the player // is in the vicinity of the well. googleAnalytics.LogEvent("Barren Fields", "Visited", "Well", 1);
プレーヤーの「成績」を測定する
Google アナリティクスのイベントを使用して、プレーヤーの「成績」を測定することができます。たとえば、5 頭のドラゴンを救出するというアクションに対する成績を測定するには、プレーヤーが救出したドラゴンの数を記録し、プレーヤーがその基準値に達したら、イベントを Google アナリティクスに送信します。
Android SDK v4
if (numDragonsRescued > 5) { if (!user.hasAchievement(RESCUED_ACHIEVEMENT) { tracker.send(new HitBuilders.EventBuilder() .setCategory("Achievement") .setAction("Unlocked") .setLabel("5 Dragons Rescued") .setValue(1) .build()); } else { tracker.send(new HitBuilders.EventBuilder() .setCategory("Achievement") .setAction("Earned") .setLabel("5 Dragons Rescued") .setValue(1) .build()); } }
iOS SDK v3
if (numDragonsRescued > 5) { if (![user hasAchievement:RESCUED_ACHIEVEMENT]) { [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Achievement" action:@"Unlocked" label:@"5 Dragons Rescued" value:@1] build]]; } else { [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Achievement" action:@"Earned" label:@"5 Dragons Rescued" value:@1] build]]; } }
Unity v3 向け Google アナリティクス プラグイン
if (numDragonsRescued > 5) { if (!user.HasAchievement(RESCUED_ACHIEVEMENT) { googleAnalytics.LogEvent("Achievement", "Unlocked", "5 Dragons Rescued", 1); } else { googleAnalytics.LogEvent("Achievement", "Earned", "5 Dragons Rescued", 1); } }
イベントに関するデベロッパー ガイド
イベントのレポート
イベントデータは以下でご確認いただけます。
- 管理画面の [行動] >> [イベント] >> [上位のイベント]
- カスタム レポート
- Core Reporting API
ユーザーがアプリにどのくらいの金額を費やしているか(拡張 e コマース)
ユーザーによるアプリ内購入を測定したい場合は、e コマース トラッキングを使用して購入をトラッキングし、関連する商品の販売状況とユーザー行動を把握することができます。e コマース トラッキングは、特定の商品または仮想通貨の購入を測定する際に使用できます。
この例では、ドラゴン キャッチャーから、商品の購入を測定するために、 トランザクション データがイベントとともに Google アナリティクスに送信され ます。
Android SDK v4
Product product = new Product() .setName("Dragon Food") .setPrice(40.00); ProductAction productAction = new ProductAction(ProductAction.ACTION_PURCHASE) .setTransactionId("T12345"); // Add the transaction data to the event. HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder() .setCategory("In-Game Store") .setAction("Purchase") .addProduct(product) .setProductAction(productAction); // Send the transaction data with the event. tracker.send(builder.build());
iOS SDK v3
GAIEcommerceProduct *product = [[GAIEcommerceProduct alloc] init]; [product setName:@"Dragon Food"]; [product setPrice:@40.00]; GAIEcommerceProductAction *productAction = [[GAIEcommerceProductAction alloc] init]; [productAction setAction:kGAIPAPurchase]; [productAction setTransactionId:@"T12345"]; GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createEventWithCategory:@"In-Game Store" action:@"Purchase" label:nil value:nil]; // Add the transaction data to the event. [builder setProductAction:productAction]; [builder addProduct:product]; // Send the transaction data with the event. [tracker send:[builder build]];
Unity v3 向け Google アナリティクス プラグイン
// Note: Using Android SDK v3 and standard Ecommerce tracking. googleAnalytics.LogItem("T12345", "Dragon Food", "Food_SKU", "Items", 40.00, 1); googleAnalytics.LogTransaction("T12345", "In-Game Store", 40.00, 0.00, 0.00);
ユーザーが仮想通貨を購入した場合、トランザクション データを Google アナリティクスに送信するときに現金換算で測定することをおすすめします。ユーザーが商品を購入するために仮想通貨を使用したら、イベントを使用してこれを測定します。例:
Android SDK v4
/** * When the user purchases the virtual currency (Gems) measure the transaction * using enhanced ecommerce. */ Product product = new Product() .setName("2500 Gems") .setPrice(5.99); ProductAction productAction = new ProductAction(ProductAction.ACTION_PURCHASE) .setTransactionId("T67890"); // Add the transaction to the screenview. HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder() .addProduct(product) .setProductAction(productAction); // Send the transaction with the screenview. tracker.setScreenName("In-Game Store"); tracker.send(builder.build()); /** * When the user purchases an item using the virtual currency (Gems) send an * event to measure this in Google Analytics. */ HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder() .setCategory("In-Game Store") .setAction("Purchase") .setLabel("Sword") .setValue(35); tracker.send(builder.build());
iOS SDK v3
/** * When the user purchases the virtual currency (Gems) measure the transaction * using enhanced ecommerce. */ GAIEcommerceProduct *product = [[GAIEcommerceProduct alloc] init]; [product setName:@"2500 Gems"]; [product setPrice:@5.99]; GAIEcommerceProductAction *productAction = [[GAIEcommerceProductAction alloc] init]; [productAction setAction:kGAIPAPurchase]; [productAction setTransactionId:@"T67890"]; GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createScreenView]; // Add the transaction data to the screenview. [builder setProductAction:productAction]; [builder addProduct:product]; // Send the transaction with the screenview. [tracker set:kGAIScreenName value:@"In-Game Store"] [tracker send:[builder build]]; /** * When the user purchases an item using the virtual currency (Gems) send an * event to measure this in Google Analytics. */ GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createEventWithCategory:@"In-Game Store" action:@"Purchase" label:@"Sword" value:@35]; [tracker send:[builder build]];
Unity v3 向け Google アナリティクス プラグイン
// Note: Using Android SDK v3 and standard Ecommerce tracking. /** * When the user purchases the virtual currency (Gems) measure the transaction * using enhanced ecommerce. */ googleAnalytics.LogItem("T12345", "2500 Gems", "GEM2500_SKU", "Items", 5.99, 1); googleAnalytics.LogTransaction("T12345", "In-Game Store", 5.99, 0.00, 0.00); /** * When the user purchases an item using the virtual currency (Gems) send an * event to measure this in Google Analytics. */ googleAnalytics.LogEvent("In-Game Store", "Purchase", "Sword", 35);
拡張 e コマースのデベロッパー ガイド
拡張 e コマースのレポート
e コマース データは以下でご確認いただけます。
ユーザーによってアプリの目的は達成されたか(目標)
アプリ内でユーザーに達成してほしい目的があれば、 Google アナリティクスの目標を使用し、それらの 目的を定義して測定できます。たとえば、ユーザーが一定のゲームレベルに到達することやアイテムを購入することを目標に 設定できます。目標の仕組みについて、詳しくはヘルプセンターの目標についてを ご覧ください。
ドラゴン キャッチャー ゲームでは、購入のたびに Google アナリティクスにイベントが送信される場合に、アプリ内購入が行われたタイミングを測定するように目標を設定できます。管理画面の [アナリティクス設定] セクションで次のパラメータを使用すれば、 追加のコードを記述することなく目標を設定できます。
- 目標タイプ(等しい): イベント
- カテゴリ(等しい): ゲーム内ショップ
- アクション(等しい): 購入
- コンバージョンの目標値としてイベント値を使用: はい
目標レポート
目標のデータは以下でご確認いただけます。
- 管理画面の [コンバージョン] >> [目標] >> [概要]
- カスタム レポート
- Core Reporting API
特定のトレイトを持つユーザーはどのように動作しますか? (カスタム ディメンションと指標)
特定の属性や特徴、メタデータを持つユーザーをトラッキングする場合は、カスタム ディメンションを使用してこのタイプのデータを Google アナリティクスに送信して分析します。カスタム ディメンションの仕組みについては、カスタム ディメンションとカスタム指標 - 機能のリファレンスをご覧ください。
たとえば、Dragon Catcher で第 1 レベル、第 2 レベルなどに属するユーザーの割合を調べるには、ユーザーの現在のレベルでカスタム ディメンションを設定し、Google アナリティクスに送信します。 ステップは次のとおりです。
User
スコープのカスタム ディメンションを作成します。User
スコープを使用するのは、この値がそのユーザー セッション全体で持続する必要があるためです。カスタム ディメンションの設定と編集(ヘルプセンター)をご覧ください。- ユーザーのレベルが変わったときに、カスタム ディメンションの値を更新します。
次のスニペットは、ユーザーレベルのカスタム ディメンション インデックスが 1
で、ユーザーのレベルが Barren Fields
に変更され、Google アナリティクスでユーザーの状態を更新する方法を示しています。
Android SDK v4
// Set the user level custom dimension when sending a hit to Google Analytics // such as a screenview or event. tracker.setScreen("BarrenFields"); tracker.send(new HitBuilders.ScreenViewBuilder() .setCustomDimension(1, "Barren Fields") .build() );
iOS SDK v3
// Set the user level custom dimension when sending a hit to Google Analytics // such as a screenview or event. [tracker set:kGAIScreenName value:@"BarrenFields"]; [tracker send:[[[GAIDictionaryBuilder createScreenView] set:@"Barren Fields" forKey:[GAIFields customDimensionForIndex:1]] build]];
Unity v3 向け Google アナリティクス プラグイン
// Set the user level custom dimension when sending a hit to Google Analytics // such as a screenview or event. googleAnalytics.LogScreen(new AppViewHitBuilder() .SetScreenName("BarrenFields").SetCustomDimension(1, "Barren Fields"));
カスタム ディメンションとカスタム指標に関する デベロッパー ガイド
- カスタム ディメンションとカスタム指標 - Android SDK
- カスタム ディメンションとカスタム指標 - iOS SDK
- カスタム ディメンションとカスタム指標 - Unity 向け Google アナリティクス プラグイン
カスタム ディメンションとカスタム指標のレポート
カスタム ディメンションは、以下にセグメントとして含めて適用できます。
- 管理画面の最も標準的なレポート
- カスタム レポート
- Core Reporting API
カスタム ディメンションをセグメントとして適用することによって、ゲームの中で特定のレベル にいるユーザーを分析することができます。
ユーザーがタスクを完了するまでにどれくらいの時間がかかりますか?(カスタム速度)
アプリ内で、タスクを完了するのにかかった時間を計測する場合は、Google アナリティクスでカスタム速度を使用して時間に基づく計測を行うことができます。ユーザー タイミングはイベントに似ていますが、時間ベースで、category
、value
、name (variable)
、label
を含めることができます。カスタム速度の仕組みについては、サイトの速度についてをご覧ください。
たとえば、ドラゴン キャッチャーで、ユーザーが最初のドラゴンを助け出すのにどれだけかかるかを計測する場合、次のようなコードになります。
Android SDK v4
// Build and send a timing hit. tracker.send(new HitBuilders.TimingBuilder() .setCategory("Barren Fields") .setValue(45000) // 45 seconds. .setVariable("First Rescue") .setLabel("Dragon") .build());
iOS SDK v3
[tracker send:[[GAIDictionaryBuilder createTimingWithCategory:@"Barren Fields" interval:@45000 // 45 seconds. name:@"First Rescue" label:@"Dragon"] build]];
Unity v3 向け Google アナリティクス プラグイン
// Build and send a timing hit. googleAnalytics.LogTiming("Barren Fields",45000,"First Rescue","Dragon");
カスタム速度に関するデベロッパー ガイド
カスタム速度のレポート
カスタム速度のデータは以下でご確認いただけます。
- 管理画面の [行動] >> [アプリの速度]
- カスタム レポート
- Core Reporting API
関連資料
- アナリティクス アカデミー - モバイルアプリ解析の基本などを説明する無料のオンライン コースで、アナリティクス スキルをレベルアップすることができます。
- Collection API / SDK - Google アナリティクスにデータを送信するさまざまな方法を学びます。