このドキュメントは、モバイル デベロッパーを対象に、アナリティクスを使用してユーザーの接点を測定し、アプリの利用状況について把握する方法を説明しています。
はじめに
ユーザーの操作を測定できるモバイルアプリ向け Google アナリティクスは、お客様のアプリに対するユーザーの利用状況を詳細に把握して最適化することに役立ちます。
Google アナリティクスのデフォルトの実装では、アプリに関する次の情報が自動的に提供されます。
- ユーザーとセッションの数
- セッション継続時間
- オペレーティング システム
- 端末の機種
- 地域
このガイドでは、ユーザーとユーザーの行動をより深く理解するために Google アナリティクス の追加機能を実装する方法を説明します。
準備
このガイドに従ってモバイルアプリ向け Google アナリティクスを設定する前に、以下の 関連資料をご覧ください。
- 対象プラットフォームの SDK をインストールする方法:
- モバイルアプリ アナリティクスの 実践的な設定手法
概要
ドラゴン キャッチャー
このガイドでは、サンプルアプリを使用して、追加の Google アナリティクス機能を実装する方法を見ていきます。このアプリは 「ドラゴン キャッチャー(Dragon Catcher)」という名前の、次の特徴を持つゲームです。
- 1 つのレベルは、プレーヤー、ドラゴン、フェンスで囲まれたエリア、泉、木で 構成されます。
- プレーヤーの目標は、ドラゴンをフェンスの内側に追い込んで捕まえる ことです。
- プレーヤーは、レベル内の別のエリアや、泉や魔法の木がある場所などを訪れる ことができます。
- プレーヤーは、すべてのドラゴンを捕まえると次のレベルに 進みます。
- プレーヤーは、第 1 レベルの「荒れ地(Barren Fields)」からゲームを 開始します。
Google アナリティクスを使用すれば、ドラゴン キャッチャーでのユーザーの行動について、 次のようなデータを取得することができます。
- ユーザーがどんなアクションを実行しているか(イベント)
- ユーザーがアプリにどのくらいの金額を費やしているか(e コマース)
- ユーザーによってアプリの目的は達成されたか(目標)
- 特定の特徴を持つユーザーがどのような行動をとるか(カスタム ディメンション / 指標)
- ユーザーがタスクを完了するまでにどれくらいの時間がかかるか(カスタム速度)
この後のセクションでは、ドラゴン キャッチャーに Google アナリティクス機能を実装することにより、上記についてのデータを取得する方法を解説します。
ユーザーがどんなアクションを実行しているか(イベント)
アプリ内でトラッキングしたい重要なアクションがあれば、このアクションを説明するために
Google アナリティクスのイベントを使用することができます。イベントは、
category
、action
、label
、value
という 4 つのパラメータで
構成されます。
たとえば、ユーザーがドラゴンを救出したり、 レベル内の特定のエリアを訪れたりするアクションはドラゴン キャッチャーでは重要な ため、イベントを使用して測定します。次のコード スニペットは、Google アナリティクスで これらのアクションを測定する方法を示しています。
Android SDK
// 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
// 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 向け 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
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
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 向け 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
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
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 向け 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
/** * 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
/** * 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 *viewBuilder = [GAIDictionaryBuilder createScreenView]; // Add the transaction data to the screenview. [viewBuilder setProductAction:productAction]; [viewBuilder addProduct:product]; // Send the transaction with the screenview. [tracker set:kGAIScreenName value:@"In-Game Store"]; [tracker send:[viewBuilder build]]; /** * When the user purchases an item using the virtual currency (Gems) send an * event to measure this in Google Analytics. */ GAIDictionaryBuilder *eventBuilder = [GAIDictionaryBuilder createEventWithCategory:@"In-Game Store" action:@"Purchase" label:@"Sword" value:@35]; [tracker send:[eventBuilder build]];
Unity 向け 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 コマース トラッキング - Android SDK
- 拡張 e コマース トラッキング - iOS SDK
- 拡張 e コマース トラッキング - Unity 向け Google アナリティクス プラグイン
拡張 e コマースのレポート
e コマース データは以下でご確認いただけます。
ユーザーによってアプリの目的は達成されたか(目標)
アプリ内でユーザーに達成してほしい目的があれば、 Google アナリティクスの目標を使用し、それらの 目的を定義して測定できます。たとえば、ユーザーが一定のゲームレベルに到達することやアイテムを購入することを目標に 設定できます。目標の仕組みについて、詳しくはヘルプセンターの目標についてを ご覧ください。
ドラゴン キャッチャーでは、購入のたびにイベントが Google アナリティクスに送信されている場合に、アプリ内購入がいつ行われたかを目標に設定し、測定することができます。管理画面の [アナリティクス設定] セクションで次のパラメータを使用すれば、 追加のコードを記述することなく目標を設定できます。
- 目標タイプ(等しい): イベント
- カテゴリ(等しい): ゲーム内ショップ
- アクション(等しい): 購入
- コンバージョンの目標値としてイベント値を使用: はい
目標レポート
目標のデータは以下でご確認いただけます。
- 管理画面の [コンバージョン] >> [目標] >> [概要]
- カスタム レポート
- Core Reporting API
特定の特徴を持つユーザーがどのような行動をとるか(カスタム ディメンション / 指標)
特定の属性や特徴、メタデータを持つユーザーをトラッキングする場合は、カスタム ディメンションを使用してこのタイプのデータを Google アナリティクスに送信して分析します。カスタム ディメンションの仕組みについては、カスタム ディメンションとカスタム指標 - 機能のリファレンスをご覧ください。
たとえば、ドラゴン キャッチャーで各レベルにいるユーザーの割合を調べるには、ユーザーの現在のレベルをカスタム ディメンションとして設定し、Google アナリティクスに送信することができます。手順は次のとおりです。
- 範囲を
User
に設定したカスタム ディメンションを作成します。User
の範囲を使用するのは、この値をそのユーザーのセッションすべてで維持するためです。ヘルプセンターのカスタム ディメンションの設定や編集についてのページをご覧ください。 - ユーザーのレベルが変わったときに、カスタム ディメンションの値を更新します。
次のスニペットでは、Google アナリティクスでユーザーの状況を更新する方法を
示しています。ここでは、ユーザーレベルのカスタム ディメンション インデックス
が 1
で、ユーザーのレベルが Barren Fields
に変更されています。
Android SDK
// Set the user level custom dimension when sending a hit to Google Analytics // such as a screenview or event. tracker.setScreenName("BarrenFields"); tracker.send(new HitBuilders.ScreenViewBuilder() .setCustomDimension(1, "Barren Fields") .build() );
iOS SDK
// 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 向け 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
// 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
[tracker send:[[GAIDictionaryBuilder createTimingWithCategory:@"Barren Fields" interval:@45000 // 45 seconds. name:@"First Rescue" label:@"Dragon"] build]];
Unity 向け Google アナリティクス プラグイン
// Build and send a timing hit. googleAnalytics.LogTiming("Barren Fields",45000,"First Rescue","Dragon");
カスタム速度に関するデベロッパー ガイド
カスタム速度のレポート
カスタム速度のデータは以下でご確認いただけます。
- 管理画面の [行動] > [アプリの速度]
- カスタム レポート
- Core Reporting API
関連資料
- アナリティクス アカデミー - モバイルアプリ解析の基本などが説明される無料のオンライン コースで、アナリティクス スキルをレベルアップさせることができます。
- Collection API / SDK - Google アナリティクスにデータを送信するさまざまな方法を学びます。