Quickly and easily integration with Google Analytics API for iOS.
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.
CocoaPods is the recommended way to add NZGoogleAnalytics to your project.
- Add a pod entry for NZGoogleAnalytics to your Podfile:
pod 'NZGoogleAnalytics', '~> 0.0.1'
- Install the pod(s) by running:
pod install
Alternatively you can directly add source files to your project.
- Download the latest code version or add the repository as a git submodule to your git-tracked project.
- 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. - Install Google Analytics SDK for iOS and your frameworks dependencies
- Install NZBundle
-
Default values for debug/release mode:
trackUncaughtExceptions
: NOdispatchInterval
: 5 secondslogLevel
: kGAILogLevelNone
-
Default values for distribution mode:
trackUncaughtExceptions
: YESdispatchInterval
: 20 secondslogLevel
: kGAILogLevelNone
-
NZGoogleAnalytics use NZBundle for change build version name:
- Debug and Relase:
X.X.Xa alpha
- Distribution:
X.X.Xa
- Debug and Relase:
- You will need to define
NZ_GA_TRACKINGID
at your project prefix header*-Prefix.pch
:
// define your Google Analytics Tracking ID
#define NZ_GA_TRACKINGID "UA-000000-01"
-
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 nameview_name
: Your track view name
- Add
- 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"];
}
This code is distributed under the terms and conditions of the MIT license.
A brief summary of each NZGoogleAnalytics release can be found on the wiki.