Hide

App / Screen Tracking - Web Tracking (analytics.js)

This guide describes how to use screen tracking with analytics.js

  1. Overview
  2. Implementation
    1. Setting App Values Across Multiple Screen Views
  3. Using Filters for App-only or Web-only Views

Overview

Screens in Google Analytics represent content users are viewing within an app. The equivalent concept for a website is pages. Measuring screen views allows you to see which content is being viewed most by your users, and how are they are navigating between different pieces of content.

There is 1 field that is recommended to send with each tracking beacon to identify a screen:

Value Type Required Description
Screen Name String No The name of the screen.

There are also 4 app tracking fields that, if applicable to your implementation, you may want to send for app tracking.

Value Type Required Description
Application Name String Yes The name of the application.
Application Id String No The Id of the application.
Application Version String No The application version.
Application Installer Id String No The Id of the application installer.

Implementation

To send a screenview, you pass the ga function a send command with the screenview hit type and include a configuration object to set the screen name field.

ga('send', 'screenview', {
  'screenName': 'Home'
});

You can also pass a configuration object to set additional app fields with the hit:

ga('send', 'screenview', {
  'appName': 'myAppName',
  'appId': 'myAppId',
  'appVersion': '1.0',
  'appInstallerId': 'myInstallerId',
  'screenName': 'my overridden screen name'
});

Read the Field Reference document for a complete list of all the fields that can be used in the configuration object.

Setting App Values Across Multiple Screen Views

In cases where your app shows multiple screens to the user without any page reloads, it's not convenient to have to set app fields for each screenview. Instead you can set fields across muitple send commands. For example, when the following code is executed the app fields will be sent for both send commands.

ga('create', 'UA-XXXX-Y', 'auto');
ga('set', {
  'appName': 'myAppName',
  'appId': 'myAppId',
  'appVersion': '1.0',
  'appInstallerId': 'myInstallerId'
});

ga('send', 'screenview', {'screenName': 'Home'});
ga('send', 'event', 'video', 'started');

Using Filters for App-only or Web-only Views

If you send web and app data for the same property (UA-XXXX-Y), Google Analytics will display both sets of data in views (profiles) 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 maintain a separate app and/or web view 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.