Latest 1.0.2
Homepage https://github.com/urbanairship/ios-ga-tracker
License Apache 2.0
Platforms ios 8.0, requires ARC
Dependencies GoogleAnalytics, UrbanAirship-iOS-SDK
Authors

Version
License
Platform

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.

Latest podspec

{
    "name": "UrbanAirship-iOS-GA-Tracker",
    "documentation_url": "https://github.com/urbanairship/ios-ga-tracker",
    "version": "1.0.2",
    "license": "Apache 2.0",
    "summary": "A simple way to integrate Urban Airship and Google Analytics.",
    "homepage": "https://github.com/urbanairship/ios-ga-tracker",
    "authors": {
        "Urban Airship": "[email protected]"
    },
    "source": {
        "git": "https://github.com/urbanairship/ios-ga-tracker.git",
        "tag": "1.0.2"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "8.0"
    },
    "dependencies": {
        "GoogleAnalytics": [
            "~> 3.17"
        ],
        "UrbanAirship-iOS-SDK": [
            "~> 8.0.0"
        ]
    },
    "source_files": [
        "Pod/Classes/*"
    ]
}

Pin It on Pinterest

Share This