Track Screenviews

Google Analytics for Firebase tracks screen transitions and attaches information
about the current screen to events, enabling you to track metrics such as user
engagement or user behavior per screen. Much of this data collection happens
automatically, but you can also manually track screen names. Manually tracking
screens is useful if your app does not use a separate UIViewController or
Activity for each screen you may wish to track, such as in a game.

Automatically track screens

Analytics automatically tracks some information about screens in your
application, such as the class name of the UIViewController or Activity that
is currently in focus. When a screen transition occurs, Analytics logs a
screen_view event that identifies the new screen. Events that occur on these
screens are automatically tagged with the parameter firebase_screen_class (for
example, menuViewController or MenuActivity) and a generated
firebase_screen_id. If your app uses a distinct UIViewController or
Activity for each screen, Analytics can automatically track every screen
transition and generate a report of user engagement broken down by screen. If
your app doesn't, you can still get these reports by manually setting the screen
name with the API.

Manually track screens

You can manually set the screen name and optionally override the class name
when screen transitions occur. After setting the screen name, events that
occur on these screens are additionally tagged with the parameter
firebase_screen. For example, you could name a screen "Main Menu" or
"Friends List". The following example shows how to manually
set the screen name.

Swift

Analytics.setScreenName(screenName, screenClass: screenClass)

The screen name and screen class stay the same until the UIViewController
changes or you make a new call to
setScreenName().

Objective-C

[FIRAnalytics setScreenName:screenName screenClass:screenClass];

The screen name and screen class stay the same until the ViewController
changes or you make a new call to
setScreenName:screenClass:.