警告: Google Play Instant はご利用いただけなくなります。2025 年 12 月より、Google Play を通じて Instant Apps を公開できなくなり、すべての Google Play 開発者サービス Instant API が機能しなくなります。ユーザーには、あらゆるメカニズムを使用して Google Play からインスタント アプリが提供されなくなります。
この変更は、デベロッパーからのフィードバックと、Google Play インスタントの導入以来、エコシステムの改善に継続的に投資してきたことに基づいて行われます。
アプリの成功を追跡することは、Instant 版かインストール版かにかかわらず、各デベロッパーにとって重要なことです。Fabric Answers、Localytics、Mixpanel などの分析ライブラリは Google Play Instant と互換性があります。
使用中の分析ソリューションがこの中にない場合、あるいは Google Play Instant に対応していないと判明した場合は、テレメトリー ソリューションとして Firebase 向け Google アナリティクスを使用することを検討してください。このページでは、Instant App プロジェクトで Firebase 向け Google アナリティクスをセットアップする方法について説明します。
Firebase 向け Google アナリティクスを Instant App プロジェクトに追加する
valSTATUS_INSTALLED="installed"valSTATUS_INSTANT="instant"valANALYTICS_USER_PROP="app_type"privatelateinitvarfirebaseAnalytics:FirebaseAnalyticsprotectedfunonCreate(savedInstanceState:Bundle?){...firebaseAnalytics=FirebaseAnalytics.getInstance(this)// Determine the current app context, either installed or instant, then// set the corresponding user property for Google Analytics.if(InstantApps.getPackageManagerCompat(this).isInstantApp()){firebaseAnalytics.setUserProperty(ANALYTICS_USER_PROP,STATUS_INSTANT)}else{firebaseAnalytics.setUserProperty(ANALYTICS_USER_PROP,STATUS_INSTALLED)}}
Java
finalStringSTATUS_INSTALLED="installed";finalStringSTATUS_INSTANT="instant";finalStringANALYTICS_USER_PROP="app_type";privateFirebaseAnalyticsfirebaseAnalytics;@OverrideprotectedvoidonCreate(BundlesavedInstanceState){...firebaseAnalytics=FirebaseAnalytics.getInstance(this);// Determine the current app context, either installed or instant, then// set the corresponding user property for Google Analytics.if(InstantApps.getPackageManagerCompat(this).isInstantApp()){firebaseAnalytics.setUserProperty(ANALYTICS_USER_PROP,STATUS_INSTANT);}else{firebaseAnalytics.setUserProperty(ANALYTICS_USER_PROP,STATUS_INSTALLED);}}
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# Add Google Analytics for Firebase to your instant app\n\n**Warning:** Google Play Instant will no longer be available. Starting December 2025,\nInstant Apps cannot be published through Google Play, and all\n[Google Play services Instant APIs](https://developers.google.com/android/reference/com/google/android/gms/instantapps/package-summary)\nwill no longer work. Users will no longer be served Instant Apps by Play using any\nmechanism.\n\nWe're making this change based on developer feedback and our continuous investments\nto improve the ecosystem since the introduction of Google Play Instant.\n\nTo continue optimizing for user growth, we encourage developers to refer users to\ntheir regular app or game, using [deeplinks](https://support.google.com/googleplay/android-developer/answer/12463044)\nto redirect them to specific journeys or features when relevant.\n\nTracking the success of an app, instant or installed, is important to each\ndeveloper. Several analytics libraries are compatible with\nGoogle Play Instant, including\n[Fabric Answers](https://fabric.io/kits/android/answers),\n[Localytics](https://docs.localytics.com/dev/android.html#android),\nand [Mixpanel](https://mixpanel.com/help/reference/android).\n\nIf your current analytics solution isn't listed or if you find that it doesn't\nwork with Google Play Instant, consider using Google Analytics for Firebase as\nyour telemetry solution. This page describes how to set up Google Analytics for Firebase\nin an instant app project.\n\nAdding Google Analytics for Firebase to an instant app project\n--------------------------------------------------------------\n\n1. Add the Firebase SDK to your app by following the instructions described in the [Getting started guide for Google Analytics for Firebase](https://firebase.google.com/docs/analytics/android/start/).\n2. Use the latest version of the google-services plugin.\n3. Place the `google-services.json` file in each module.\n4. Add the following line to each module's `build.gradle` file:\n\n \u003cbr /\u003e\n\n ### Groovy\n\n ```groovy\n // android { ... }\n // dependencies { ... }\n plugins {\n id 'com.google.gms.google-services'\n }\n ```\n\n ### Kotlin\n\n ```kotlin\n // android { ... }\n // dependencies { ... }\n plugins {\n id(\"com.google.gms.google-services\")\n }\n ```\n\n \u003cbr /\u003e\n\nOnce you have added Google Analytics for Firebase to your instant app project, you can\nuse the Google Analytics for Firebase APIs as you might in an installable app project.\n\nFor more information about how to use the Google Analytics for Firebase APIs, see\nthe\n[getting started documentation for Google Analytics for Firebase](https://firebase.google.com/docs/analytics/android/start/).\n\nDifferentiating between installed and instant app data\n------------------------------------------------------\n\nBecause both your installed and your instant app share a package name, you\nmay want to differentiate the events and data collected from each. To\ndifferentiate your instant and installed apps in Analytics, set\na `app_type` user property, with the value \"instant\" for the instant app and\n\"installed\" for the installed app.\n| **Note:** Both the instant app and the installed app need to implement the `app_type` user property. Further, you must publish the installed app that contains `app_type` before the instant app. Otherwise, Analytics logs installed app events to the instant app when users install the app.\n\nThe following code snippet shows an activity that gets an\nAnalytics instance and then sets a user property. Notice that\nthe code uses\n[`PackageManagerCompat.isInstantApp()`](https://developers.google.com/android/reference/com/google/android/gms/instantapps/PackageManagerCompat.html#isInstantApp())\nin the [onCreate(android.os.Bundle)](/reference/android/app/Activity#onCreate(android.os.Bundle))\nmethod to determine the app's context. \n\n### Kotlin\n\n```kotlin\nval STATUS_INSTALLED = \"installed\"\nval STATUS_INSTANT = \"instant\"\nval ANALYTICS_USER_PROP = \"app_type\"\n\nprivate lateinit var firebaseAnalytics: FirebaseAnalytics\n\nprotected fun onCreate(savedInstanceState: Bundle?) {\n ...\n\n firebaseAnalytics = FirebaseAnalytics.getInstance(this)\n\n // Determine the current app context, either installed or instant, then\n // set the corresponding user property for Google Analytics.\n if (InstantApps.getPackageManagerCompat(this).isInstantApp()) {\n firebaseAnalytics.setUserProperty(ANALYTICS_USER_PROP, STATUS_INSTANT)\n } else {\n firebaseAnalytics.setUserProperty(ANALYTICS_USER_PROP, STATUS_INSTALLED)\n }\n}\n```\n\n### Java\n\n```java\nfinal String STATUS_INSTALLED = \"installed\";\nfinal String STATUS_INSTANT = \"instant\";\nfinal String ANALYTICS_USER_PROP = \"app_type\";\n\nprivate FirebaseAnalytics firebaseAnalytics;\n\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n ...\n\n firebaseAnalytics = FirebaseAnalytics.getInstance(this);\n\n // Determine the current app context, either installed or instant, then\n // set the corresponding user property for Google Analytics.\n if (InstantApps.getPackageManagerCompat(this).isInstantApp()) {\n firebaseAnalytics.setUserProperty(ANALYTICS_USER_PROP, STATUS_INSTANT);\n } else {\n firebaseAnalytics.setUserProperty(ANALYTICS_USER_PROP, STATUS_INSTALLED);\n }\n\n}\n```\n\nOnce you set the `app_type` user property, you can select an event in the\nAnalytics console's **Events** tab and then filter the event by the\n`app_type` value. The resulting data projection gives you a count for the\nspecified event in your instant or installed app.\n\nFor more information about how to log and view events in Google Analytics for Firebase,\nsee [Log Events](https://firebase.google.com/docs/analytics/android/events).\n\nInterpreting Analytics events\n-----------------------------\n\nAnalytics allows you to track a variety of metrics valuable\nto an instant app. The following table describes relevant metrics for your\ninstant app, including the corresponding event name or property in\nAnalytics.\n\n| Name | Analytics value | Definition |\n|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Visits | `session_start` | Session started. This event is automatically tracked. |\n| Physical purchases | [`Firebase.Event.ECOMMERCE_PURCHASE`](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#ECOMMERCE_PURCHASE) | Physical purchases. You must explicitly track this event in your code. |\n| Digital purchases | `in_app_purchase` | Digital in-app purchases. This event is automatically tracked. |\n| Time in app | `user_engagement` | Amount of time that the app spends in the foreground. This event is automatically tracked. |\n| Instant app context | `app_type` | Events raised from the app running in the instant or installed context. You must explicitly track this event in your code. See [Differentiating between installed and instant app data](#analytics-implement) above. |\n| Return visitors | `session_start.count` and `app_type` | Audience of users who visit twice or more. You must explicitly track the `app_type` event; `session_start` is tracked for you. See [Differentiating between installed and instant app data](#analytics-implement) above. |\n\nFor more information about the constants for events that you can collect in\nAnalytics, see\n[FirebaseAnalytics.Event](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html)."]]