Gordon Choi

Author of the Analytics Book

User Tools

Site Tools


Google Mobile App Analytics iOS SDK

Chapter 16

Let's implement the Google Analytics SDK onto your iOS app.


The iOS SDK implementation assumes your app's source code is written in Objective-C and you use CocoaPods to install and manage dependencies.

Open a terminal window and navigate to the location of the Xcode project for your application. Create a Podfile for your application if it doesn't exist.

pod init

Open the Podfile and add the following:

pod 'Google/Analytics'

Save the Podfile and run:

pod install

A .xcworkspace file will be created for your application.

Configuration file

Download the configuration file.


Drag the GoogleService-Info.plist file (i.e. configuration file) into the root of your Xcode project and add it to all targets.


Add this to the AppDelegate.m file:

#import <Google/Analytics.h>

To configure GGLContext, override the didFinishLaunchingWithOptions method:

NSError *configureError;
[[GGLContext sharedInstance] configureWithError:&configureError];
NSAssert(!configureError, @"Error configuring Google services: %@", configureError);

GAI *gai = [GAI sharedInstance];
gai.trackUncaughtExceptions = YES;  // report uncaught exceptions
gai.logger.logLevel = kGAILogLevelVerbose;  // remove before app release


Let's add the tracker to track screen views in your iOS View Controller.

In ViewController.m, add the <Google/Analytics.h> header. Use a viewWillAppear method or function override to insert screen tracking. Give the screen a name and execute tracking.

id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName value:name];
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];

Previous Chapters

Next Chapters

Gordon Choi's Analytics Book has been available since August 2016 and is proudly powered by Folks Analytics.

Thank you for reading! If you love my book, you're welcome to donate through Paypal.

google_mobile_app_analytics_ios_sdk.txt ยท Last modified: 2017/02/17 01:22 by Gordon Choi