UrbanAirship-iOS-GA-Tracker 1.0.2

UrbanAirship-iOS-GA-Tracker 1.0.2

TestsTested
LangLanguage Obj-CObjective C
License Apache 2
ReleasedLast Release Sep 2016

Maintained by David Crow.



 
Depends on:
GoogleAnalytics~> 3.17
UrbanAirship-iOS-SDK~> 8.0.0
 

  • By
  • Urban Airship

Installation

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.

Usage

Overview

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.

Examples

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;
};

Author

Urban Airship, [email protected]

License

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