TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | May 2015 |
Maintained by Bruno Tortato Furtado.
Depends on: | |
GoogleAnalytics-iOS-SDK | >= 0 |
NZBundle | >= 0 |
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:
You will need LLVM 3.0 or later in order to build NZGoogleAnalytics.
NZGoogleAnalytics uses Google Analytics SDK for iOS and NZBundle.
Alternatively you can directly add source files to your project.
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.Default values for debug/release mode:
trackUncaughtExceptions
: NOdispatchInterval
: 5 secondslogLevel
: kGAILogLevelNoneDefault values for distribution mode:
trackUncaughtExceptions
: YESdispatchInterval
: 20 secondslogLevel
: kGAILogLevelNoneNZGoogleAnalytics use NZBundle for change build version name:
X.X.Xa alpha
X.X.Xa
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:
NZGoogleAnalytics-Tracker.plist
file to your project with the following configuration:
class_name
: Your view controller class nameview_name
: Your track view name#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];
}
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.