Screen Tracking - Android SDK v2 (Legacy)

This document provides an oveview of screens and how to measure screen views using the Google Analytics SDK for Android v2.

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 are 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.

Screen view data is used primarily in the following Google Analytics reports:

  • Screens report
  • Engagement Flow
  • Goal Flow

Implementation

The following sections will desribe how to implement screen measurement using either an EasyTracker or an advanced implementation. If you are using EasyTracker, you'll have the option to implement automatic screen measurement.

Automatic Screen Measurement (EasyTracker)

If you are using EasyTracker, you can use automatic screen measurement to easily measure each of your app's Activities as screens.

To enable automatic Activity measurement:

  1. Add EasyTracker methods to all of your Activities
  2. Set the ga_autoActivityTracking parameter in your analytics.xml file.
  3. Give each of your Activities a screen name in your analytics.xml file.

Here's an example snippet from an analytics.xml 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 your reporting -->
<string name="com.example.app.BaseActivity">Home</string>
<string name="com.example.app.PrefsActivity">Preferences</string>

Manual Screen Measurement

You can also manually send a screen view by calling sendView(). Even if you're already using EasyTracker's automatic screen measurement, you can manually send screen views to measure user engagement with Fragments or other content that might not be an Activity.

sendView() is usually called in the onStart() callback of an Activity or Fragment as win the following example:

/**
 * Within an Activity or Fragment
 */
@Override
public void onStart() {
  super.onStart();
  ... // Your other onStart() code.
  myTracker.sendView("Home Screen"); // Where myTracker is an instance of Tracker.
}