Skip to content
A simple way to integrate Urban Airship and Google Analytics.
Branch: master
Clone or download
crow Merge pull request #1 from urbanairship/MB-1961
MB-1961 Update GA tracker to UA 8.0.0 and GA 3.17
Latest commit 5f3aa01 Sep 15, 2016


Version License Platform


UrbanAirship-iOS-GA-Tracker is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "UrbanAirship-iOS-GA-Tracker"

To run the example project, clone the repo, and run pod install from the Example directory first.



The Urban Airship Google Analytics tracker consumes Google Analytics events via a UATracker instance then uses this data to generate Custom Events. The UATracker is configured by default to upload the generated Custom Events to Urban Airship, then forward the original event data to Google Analytics. The UATracker generates custom events with a pre-defined subset of Google analytics fields that can be customized by with a customization block, or defined completely with a creation block.


Configuring the UATracker:

// Set the googleAnalyticsEnabled flag to NO to prevent forwarding events to Google Analytics
tracker.googleAnalyticsEnabled = NO;

// Set the urbanAirshipEnabled flag to NO to prevent forwarding custom events to Urban Airship
tracker.urbanAirshipEnabled = NO;

Creating a screen tracking event:

// Initialize a Google Analytics tracker
NSObject<GAITracker> *googleAnalyticsTracker = [[GAI sharedInstance] trackerWithTrackingId:@"GA_tracker"];

// Initialize a Urban Airship tracker
UATracker *tracker = [UATracker trackerWithGATracker:googleAnalyticsTracker]; 

// Enable GA tracker (enabled by default)
tracker.googleAnalyticsEnabled = YES;

// Enable UA tracker (enabled by default)
tracker.urbanAirshipEnabled = YES;

// Add screen tracking event
[tracker set:kGAIScreenName value:@"Home Screen"];

// Send screen tracking event
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];

Adding Custom Event properties with the customization block:

// Add event customization block to add properties to the generated customEvent
tracker.eventCustomizationBlock = ^void(UACustomEvent *customEvent, NSDictionary *parameters) {
    [customEvent setStringProperty:@"propertyValue" forKey:@"propertyKey"];

Creating a custom event using an event creation block:

tracker.eventCreationBlock = ^UACustomEvent *(NSDictionary *parameters,  NSObject<GAITracker> *tracker) {

    UACustomEvent *customEvent = [UACustomEvent eventWithName:@"eventName"];

    [customEvent setStringProperty:@"propertyValue" forKey:@"propertyKey"];

    return customEvent;


Urban Airship,


UrbanAirship-iOS-GA-Tracker is available under Apache License, Version 2.0. See the LICENSE file for more info.

You can’t perform that action at this time.