Hide

Screens - iOS SDK

This document provides an overview of screens and how to measure screen views using the Google Analytics SDK for iOS v3.

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 Tracker Field Type Required Description
Screen Name kGAIScreenName NSString Yes The name of an application screen.

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

  • Screens report
  • Engagement Flow

Manual Screen Measurement

To manually send a screen view, set the screen field values on the tracker, then send the hit:

// May return nil if a tracker has not already been initialized with a
// property ID.
id tracker = [[GAI sharedInstance] defaultTracker];

// This screen name value will remain set on the tracker and sent with
// hits until it is set to a new value or to nil.
[tracker set:kGAIScreenName
       value:@"Home Screen"];

// Previous V3 SDK versions
// [tracker send:[[GAIDictionaryBuilder createAppView] build]];

// New SDK versions
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];

Automatic Screen Measurement

Automatically measure views as screens using the GAITrackedViewController class. Have each of your view controllers extend GAITrackedViewController and add a property called screenName. This property will be used to set the screen name field.

//
// MyViewController.h
// An example of using automatic screen tracking in a ViewController.
//
#import "GAITrackedViewController.h"

// Extend the provided GAITrackedViewController for automatic screen
// measurement.
@interface AboutViewController : GAITrackedViewController

@end


//
// MyViewController.m
//
#import "MyViewController.h"
#import "AppDelegate.h"

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Set screen name.
    self.screenName = @"Home Screen";
}

// Rest of the ViewController implementation.
@end