Skip to content

Instantly share code, notes, and snippets.

@izotx izotx/Google Analytics
Last active Dec 21, 2015

What would you like to do?
Google Analytics How hard is to write it in a right way?
//That's a correct version of onLoad method it takes a NSNUmber as a time parameter, not NSTimeInterval.
With prior Google's implementation I couldn't even build the project without warnings or errors.
- (void)onLoad:(NSNumber *)loadTime name:(NSString *)name andLabel:(NSString *)label{
// May return nil if a tracker has not already been initialized with a
// property ID.
id tracker = [[GAI sharedInstance] defaultTracker];
[tracker send:[[GAIDictionaryBuilder createTimingWithCategory:@"resources" // Timing category (required)
interval:loadTime // Timing interval (required)
name:name // Timing name
label:label]build]];// Timing label
//To get rid of annoying warning remove the id<GAITracker> tracker and just leave the call to shared instance
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
_appStart = [NSDate date];
//Initialize tracker
[GAI sharedInstance].trackUncaughtExceptions = YES;
// Optional: set Logger to VERBOSE for debug information.
// [[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose];
// Initialize tracker.
[[GAI sharedInstance] trackerWithTrackingId:@"UA-43467716-1"];
// rest of implementation
return YES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.