This guide describes how to use screen tracking with analytics.js
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.
Web View Filter
Create a Custom Filter to Include only web
data by setting Application? to no.