Latest 0.0.8
Homepage https://github.com/NZN/NZGoogleAnalytics
License MIT
Platforms ios 5.0, requires ARC
Dependencies GoogleAnalytics-iOS-SDK, NZBundle
Authors

NZGoogleAnalytics License MIT

Quickly and easily integration with Google Analytics API for iOS.

Build Status
Cocoapods
Cocoapods
Analytics

Requirements

NZGoogleAnalytics works on iOS 5.0+ version and is compatible with ARC projects. It depends on the following Apple frameworks, which should already be included with most Xcode templates:

  • Foundation.framework

You will need LLVM 3.0 or later in order to build NZGoogleAnalytics.

NZGoogleAnalytics uses Google Analytics SDK for iOS and NZBundle.

Adding NZGoogleAnalytics to your project

Cocoapods

CocoaPods is the recommended way to add NZGoogleAnalytics to your project.

  • Add a pod entry for NZGoogleAnalytics to your Podfile:
pod 'NZGoogleAnalytics'
  • Install the pod(s) by running:
pod install

Source files

Alternatively you can directly add source files to your project.

  1. Download the latest code version or add the repository as a git submodule to your git-tracked project.
  2. Open your project in Xcode, then drag and drop all files at NZGoogleAnalytics folder onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project.
  3. Install Google Analytics SDK for iOS and your frameworks dependencies
  4. Install NZBundle

Info

  • Default values for debug/release mode:

    • trackUncaughtExceptions: NO
    • dispatchInterval: 5 seconds
    • logLevel: kGAILogLevelNone
  • Default values for distribution mode:

    • trackUncaughtExceptions: YES
    • dispatchInterval: 20 seconds
    • logLevel: kGAILogLevelNone
  • NZGoogleAnalytics use NZBundle for change build version name:
    • Debug and Relase: X.X.Xa alpha
    • Distribution: X.X.Xa

Usage

  • Configure your trackingID:
...
#import "NZGoogleAnalytics.h"

@implementation NZAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [NZGoogleAnalytics setTrackingId:@"UA-000000-01"];
    return YES;
}

@end
  • The NZGoogleAnalytics overrides the +(void)load; method of NSObject class, which is called every time the application starts.

  • You can change the default setting:
#import "NZGoogleAnalytics.h"
...
[NZGoogleAnalytics setTrackUncaughtExceptions:YES];
BOOL trackUncaughtExceptions = [NZGoogleAnalytics trackUncaughtExceptions];

[NZGoogleAnalytics setDispatchInterval:60];
NSTimeInterval dispatchInterval = [NZGoogleAnalytics dispatchInterval];

[NZGoogleAnalytics setLogLevel:kGAILogLevelError];
GAILogLevel logLevel = [NZGoogleAnalytics logLevel];
  • Easy track your View Controller:

    • Add NZGoogleAnalytics-Tracker.plist file to your project with the following configuration:
      • class_name: Your view controller class name
      • view_name: Your track view name

NZCircularImageView

  • Configure your View Controller class:
#import "NZGoogleAnalyticsTracker.h"
...

// screen name: /ios/first_view
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [NZGoogleAnalyticsTracker trackViewWithController:self];
}
#import "NZGoogleAnalyticsTracker.h"
...

// screen name: /ios/first_view/id_001
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [NZGoogleAnalyticsTracker trackViewWithController:self withIdentifier:@"id_001"];
}

- (IBOutlet)buttonClicked
{
    [NZGoogleAnalyticsTracker trackEventWithCategory:@"category1" action:@"action1" label:@"label1"];

    NSNumber *value = [NSNumber numberWithInt:2];
    [NZGoogleAnalyticsTracker trackEventWithCategory:@"category2" action:@"action2" label:@"label2" value:value];

    [NZGoogleAnalyticsTracker trackEventWithCategory:@"category3" action:@"action3" label:@"label3" value:value];

    [NZGoogleAnalyticsTracker trackEventWithCategory:@"category4" action:@"action4" label:@"label4" value:value nonInteraction:YES];
}

License

This code is distributed under the terms and conditions of the MIT license.

Change-log

A brief summary of each NZGoogleAnalytics release can be found on the wiki.

Latest podspec

{
    "name": "NZGoogleAnalytics",
    "version": "0.0.8",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "summary": "Quickly and easily integration with Google Analytics API for iOS.",
    "homepage": "https://github.com/NZN/NZGoogleAnalytics",
    "requires_arc": true,
    "platforms": {
        "ios": "5.0"
    },
    "authors": {
        "Bruno Tortato Furtado": "[email protected]"
    },
    "dependencies": {
        "GoogleAnalytics-iOS-SDK": [],
        "NZBundle": []
    },
    "source_files": "NZGoogleAnalytics/*.{h,m}",
    "source": {
        "git": "https://github.com/NZN/NZGoogleAnalytics.git",
        "tag": "0.0.8"
    }
}

Pin It on Pinterest

Share This