App / Screen Measurement

When building web apps, use screen_view events to measure specific screen views in Google Analytics. This provides similar functionality to Firebase screen_view events on native Android or iOS apps, or pageview events on standard web pages.

Implementation

To send a screen view to Google Analytics, use the event command as follows:

gtag('event', 'screen_view', {<screen_view_parameters>});

where <screen_view_parameters> is one or more parameter-value pairs. Two parameters are required: screen_name and app_name. Separate each pair by a comma. For example, this command sends a screen_view event for an app named 'myAppName' with a screen_name of 'Home'.

gtag('event', 'screen_view', {
  'app_name': 'myAppName',
  'screen_name' : 'Home'
});

Screen view parameters

Field name Data type Required Description
screen_name string Yes The name of the screen.
app_name string Yes The name of the application.
app_id string No The ID of the application.
app_version string No The application version.
app_installer_id string No The ID of the application installer.

Learn about the difference between web and app views in Google Analytics.

Examples

Because the app_name parameter must be sent with all app events, it's often best to add the parameter as part of a config command.

gtag('config', 'GA_MEASUREMENT_ID', { 'app_name': 'myAppName' });

// The app_name field is now set for the property, so
// screen_view events don't need to include it.
gtag('event', 'screen_view', { 'screen_name': 'Home'});

Using filters for app-only or web-only views

If you send web and app data to the same property (GA_MEASUREMENT_ID), Google Analytics will display both sets of data in views for that property. This allows for combined app and web views.

If you want to send app and web data for the same property, but want to view app and web data separately, you can create Filters. For example, you can have a combined view (default), a web view, and an app view.

App view filter

Create a Custom Filter to Include only app data by setting Application? to yes.

The Google Analytics create filter form. The filter name field is set to 'App View', 'Custom Filter' type is selected, 'Include' is selected, Filter Field dropdown is set to 'Application?', Filter Pattern is set to 'yes', and Case Sensitive is set to 'No'.
Figure 1: Filter settings for an App View.

Web view filter

Create a Custom Filter to Include only web data by setting Application? to no.

The Google Analytics create filter form. The filter name field is set to 'Web View', 'Custom Filter' type is selected, 'Include' is selected, Filter Field dropdown is set to 'Application?', Filter Pattern is set to 'no', and Case Sensitive is set to 'No'.
Figure 2: Filter settings for a Web View.