הוספה של Google Analytics for Firebase לאפליקציה ללא התקנה
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
אזהרה: התכונה 'Google Play ללא התקנה' לא תהיה זמינה יותר. החל מדצמבר 2025, לא תהיה אפשרות לפרסם אפליקציות ללא התקנה דרך Google Play, וכל ממשקי Instant API של Google Play Services יפסיקו לפעול. המשתמשים לא יקבלו יותר אפליקציות מיידיות מ-Play באמצעות מנגנון כלשהו.
אנחנו מבצעים את השינוי הזה על סמך משוב שקיבלנו ממפתחים וההשקעות המתמשכות שלנו בשיפור הסביבה העסקית מאז השקת Google Play ללא התקנה.
כדי להמשיך לבצע אופטימיזציה לצמיחת מספר המשתמשים, אנחנו ממליצים למפתחים להפנות את המשתמשים לגרסה הרגילה של האפליקציה או המשחק באמצעות קישורי עומק, כדי להפנות אותם למסלולים או לתכונות ספציפיים כשזה רלוונטי.
חשוב לכל מפתח לעקוב אחרי ההצלחה של אפליקציה, בין אם היא אפליקציה ללא התקנה או אפליקציה שמותקנת. כמה ספריות לניתוח נתונים תואמות ל-Google Play Instant, כולל Fabric Answers, Localytics ו-Mixpanel.
אם פתרון הניתוח הנוכחי שלכם לא מופיע ברשימה או אם הוא לא פועל עם Google Play Instant, כדאי להשתמש ב-Google Analytics for Firebase כפתרון טלמטריה. בדף הזה מוסבר איך להגדיר את Google Analytics for Firebase בפרויקט של אפליקציה מיידית.
הוספת Google Analytics for Firebase לפרויקט של אפליקציה מיידית
אחרי שמוסיפים את Google Analytics for Firebase לפרויקט של האפליקציה המיידית, אפשר להשתמש בממשקי ה-API של Google Analytics for Firebase כמו בפרויקט של אפליקציה שאפשר להתקין.
ההבדל בין נתונים של אפליקציות מותקנות לבין נתונים של אפליקציות ללא התקנה
מכיוון שגם האפליקציה המותקנת וגם האפליקציה ללא התקנה חולקות את אותו שם חבילה, כדאי להבדיל בין האירועים והנתונים שנאספים מכל אחת מהן. כדי להבחין בין אפליקציות מיידיות לאפליקציות מותקנות ב-Analytics, צריך להגדיר app_type מאפיין משתמש עם הערך instant לאפליקציה המיידית והערך installed לאפליקציה המותקנת.
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);}}
אחרי שמגדירים את מאפיין המשתמש app_type, אפשר לבחור אירוע בכרטיסייה אירועים במסוף Analytics ואז לסנן את האירוע לפי הערך app_type. ההקרנה של הנתונים שמתקבלת נותנת לכם את מספר הפעמים שהאירוע שצוין התרחש באפליקציה ללא התקנה או באפליקציה שהותקנה.
מידע נוסף על תיעוד אירועים וצפייה בהם ב-Google Analytics for Firebase זמין במאמר תיעוד אירועים.
פירוש אירועים ב-Analytics
מערכת Analytics מאפשרת לעקוב אחרי מגוון מדדים שחשובים לאפליקציה מיידית. בטבלה הבאה מפורטים מדדים רלוונטיים לאפליקציה המיידית, כולל שם האירוע או המאפיין התואם ב-Analytics.
שם
הערך ב-Analytics
הגדרה
ביקורים אצל מומחים רפואיים
session_start
הסשן התחיל. המעקב אחרי האירוע הזה מתבצע באופן אוטומטי.
מידע נוסף על הקבועים של אירועים שאפשר לאסוף ב-Analytics זמין במאמר בנושא FirebaseAnalytics.Event.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","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)."]]