Skip to content

Instantly share code, notes, and snippets.

@izotx
Last active December 21, 2015 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save izotx/6332113 to your computer and use it in GitHub Desktop.
Save izotx/6332113 to your computer and use it in GitHub Desktop.
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