This document provides an overview of screens and how to measure screen views using the Google Analytics SDK v4 for Android.
Overview
Screens in Google Analytics represent content users are viewing within your app. The equivalent concept in web analytics is a pageview. Measuring screen views allows you to see which content is being viewed most by your users, and how they are navigating between different pieces of content.
A screen view consists of a single string field that will be used as the screen name in your Google Analytics reports:
| Field Name | Type | Required | Description |
|---|---|---|---|
| Screen Name | String |
Yes | The name of an application screen. |
Screen view data is used primarily in the following standard Google Analytics reports:
- Screens report
- Engagement Flow
Implementation
To send a screen view, set the screen field values on the tracker, then send the hit:
// Get tracker.
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
// Set screen name.
t.setScreenName(screenName);
// Send a screen view.
t.send(new HitBuilders.ScreenViewBuilder().build());
See
Advanced Configuration for details on the getTracker method.
Automatic Screen Measurement
You can automatically measure screen views each time an app's
Activities is displayed to a user.
To enable automatic Activity measurement:
- Set the
ga_autoActivityTrackingparameter in your XML configuration file. - Give each of your
Activitiesa screen name in your XML configuration file.
Here's an example snippet from an XML configuration file once
automatic Activity measurement has been enabled:
<!-- Enable automatic Activity measurement -->
<bool name="ga_autoActivityTracking">true</bool>
<!-- The screen names that will appear in reports -->
<screenName name="com.example.ScreenviewActivity">
AnalyticsSampleApp ScreenViewSampleScreen
</screenName>
<screenName name="com.example.EcommerceActivity">
AnalyticsSampleApp EcommerceSampleScreen
</screenName>
To programatically enable automatic Activity measurement:
t.enableAutoActivityTracking(true);