Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Google Analytics monitora le transizioni tra le schermate e allega informazioni
sulla schermata corrente agli eventi, consentendoti di monitorare metriche come il coinvolgimento
o il comportamento degli utenti per schermata. Gran parte di questa raccolta dei dati avviene
automaticamente, ma puoi anche registrare manualmente le visualizzazioni di schermata. Il monitoraggio manuale
delle schermate è utile se la tua app non utilizza un UIViewController, un View o un Activity separato per ogni schermata che vuoi monitorare, ad esempio in un gioco.
Monitorare automaticamente le schermate
Analytics monitora automaticamente alcune informazioni sulle schermate della tua
applicazione, ad esempio il nome della classe di UIViewController o Activity attualmente
in primo piano. Quando si verifica una transizione sullo schermo, Analytics registra un evento screen_view che identifica la nuova schermata. Gli eventi che si verificano in queste
schermate vengono taggati automaticamente con il parametro firebase_screen_class (ad esempio, menuViewController o MenuActivity) e un firebase_screen_id generato. Se la tua app utilizza un UIViewController o
Activity distinto per ogni schermata, Analytics può monitorare automaticamente ogni transizione
delle schermate e generare un report sul coinvolgimento degli utenti suddiviso per schermata. Se
la tua app non lo fa, puoi comunque ottenere questi report registrando manualmente gli eventi
screen_view.
Disattivare il monitoraggio delle visualizzazioni schermo
La generazione automatica di report sulle visualizzazioni di schermata può essere disattivata su iOS impostando
FirebaseAutomaticScreenReportingEnabled su NO (booleano) nel file Info.plist.
Su Android, annida la seguente impostazione all'interno del tag <application> del file
AndroidManifest.xml:
Puoi registrare manualmente gli eventi screen_view indipendentemente dal fatto che il monitoraggio automatico sia
attivato. Puoi registrare questi eventi nei metodi onAppear o viewDidAppear
per le piattaforme Apple e onResume per Android. Quando screen_class non è impostato,
Analytics imposta un valore predefinito in base a UIViewController o Activity
che è attiva quando viene effettuata la chiamata.
Se hai disattivato lo swizzling nella tua app, tutti i nomi delle schermate devono essere impostati manualmente.
Per gli utenti di SwiftUI, utilizza l'AnalyticsSDK di estensione Swift.
Swift
Nota:questo prodotto Firebase non è disponibile sulla piattaforma di destinazione macOS.
[null,null,["Ultimo aggiornamento 2025-08-21 UTC."],[],[],null,["Google Analytics tracks screen transitions and attaches information\nabout the current screen to events, enabling you to track metrics such as user\nengagement or user behavior per screen. Much of this data collection happens\nautomatically, but you can also manually log screenviews. Manually tracking\nscreens is useful if your app does not use a separate `UIViewController`,\n`View`, or `Activity` for each screen you may wish to track, such as in a game.\n\nAutomatically track screens\n\nAnalytics automatically tracks some information about screens in your\napplication, such as the class name of the `UIViewController` or `Activity` that\nis currently in focus. When a screen transition occurs, Analytics logs a\n`screen_view` event that identifies the new screen. Events that occur on these\nscreens are automatically tagged with the parameter `firebase_screen_class` (for\nexample, `menuViewController` or `MenuActivity`) and a generated\n`firebase_screen_id`. If your app uses a distinct `UIViewController` or\n`Activity` for each screen, Analytics can automatically track every screen\ntransition and generate a report of user engagement broken down by screen. If\nyour app doesn't, you can still get these reports by manually logging\n`screen_view` events.\n| **Note:** On Apple platforms, Firebase depends on method swizzling to automatically log screen views. SwiftUI apps must manually set screen names for views that should be logged via the `FirebaseAnalyticsSwift` module, or log screen views manually (see below).\n\nDisable screenview tracking\n\nAutomatic screenview reporting can be turned off on iOS by setting\n`FirebaseAutomaticScreenReportingEnabled` to `NO` (Boolean) in the Info.plist.\n\nAnd on Android, nest the following setting within the `\u003capplication\u003e` tag of the\n`AndroidManifest.xml` file: \n\n \u003cmeta-data android:name=\"google_analytics_automatic_screen_reporting_enabled\" android:value=\"false\" /\u003e\n\nManually track screens\n\nYou can manually log `screen_view` events whether or not automatic tracking is\nenabled. You can log these events in the `onAppear` or `viewDidAppear` methods\nfor Apple platforms and `onResume` for Android. When `screen_class` is not set,\nAnalytics sets a default value based on the UIViewController or Activity\nthat is in focus when the call is made.\n\nIf you've disabled swizzling in your app, all screen names must be set manually.\nFor SwiftUI users, use the Analytics\n[Swift extension SDK](//github.com/firebase/firebase-ios-sdk/tree/master/FirebaseAnalyticsSwift#firebase-analytics-swift-sdk). \n\nSwift\n\n\n**Note:** This Firebase product is not available on the macOS target. \n\n```swift\nAnalytics.logEvent(AnalyticsEventScreenView,\n parameters: [AnalyticsParameterScreenName: screenName,\n AnalyticsParameterScreenClass: screenClass])https://github.com/firebase/quickstart-ios/blob/6e483be884a13ffe8d6258f1a626662fa9e7d837/analytics/LegacyAnalyticsQuickstart/AnalyticsExampleSwift/ViewController.swift#L44-L46\n```\n\nObjective-C\n\n\n**Note:** This Firebase product is not available on the macOS target. \n\n```objective-c\n[FIRAnalytics logEventWithName:kFIREventScreenView\n parameters:@{kFIRParameterScreenClass: screenClass,\n kFIRParameterScreenName: screenName}];https://github.com/firebase/quickstart-ios/blob/6e483be884a13ffe8d6258f1a626662fa9e7d837/analytics/LegacyAnalyticsQuickstart/AnalyticsExample/ViewController.m#L49-L51\n```\n\nKotlin \n\n```kotlin\nfirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SCREEN_VIEW) {\n param(FirebaseAnalytics.Param.SCREEN_NAME, screenName)\n param(FirebaseAnalytics.Param.SCREEN_CLASS, \"MainActivity\")\n}https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/analytics/app/src/main/java/com/google/firebase/example/analytics/kotlin/MainActivity.kt#L249-L252\n```\n\nJava \n\n```java\nBundle bundle = new Bundle();\nbundle.putString(FirebaseAnalytics.Param.SCREEN_NAME, screenName);\nbundle.putString(FirebaseAnalytics.Param.SCREEN_CLASS, \"MainActivity\");\nmFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SCREEN_VIEW, bundle);https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/analytics/app/src/main/java/com/google/firebase/example/analytics/MainActivity.java#L314-L317\n```\n\nWeb \n\n```javascript\nimport { getAnalytics, logEvent } from \"firebase/analytics\";\n\nconst analytics = getAnalytics();\nlogEvent(analytics, 'screen_view', {\n firebase_screen: screenName, \n firebase_screen_class: screenClass\n});https://github.com/firebase/snippets-web/blob/467eaa165dcbd9b3ab15711e76fa52237ba37f8b/snippets/analytics-next/index/analytics_record_screen_view.js#L8-L14\n```\n\nWeb \n\n```javascript\nfirebase.analytics().logEvent('screen_view', {\n firebase_screen: screenName, \n firebase_screen_class: screenClass\n});https://github.com/firebase/snippets-web/blob/467eaa165dcbd9b3ab15711e76fa52237ba37f8b/analytics/index.js#L47-L50\n```\n\nDart \n\n await FirebaseAnalytics.instance.logEvent(\n name: 'screen_view',\n parameters: {\n 'firebase_screen': screenName,\n 'firebase_screen_class': screenClass,\n },\n );"]]