After following the overview found here:
https://developers.google.com/analytics/devguides/collection/ios/v2/
I am seeing an Unused variable "tracker"
warning on the last line of the code added to:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Here's the code from Google's overview page:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Optional: automatically track uncaught exceptions with Google Analytics.
[GAI sharedInstance].trackUncaughtExceptions = YES;
// Optional: set Google Analytics dispatch interval to e.g. 20 seconds.
[GAI sharedInstance].dispatchInterval = 20;
// Optional: set debug to YES for extra debugging information.
[GAI sharedInstance].debug = YES;
// Create tracker instance.
id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-YOUR-TRACKING-ID"];
}
tracker
truly sees absolutely no use past this point and the overview document doesn't really say what to do with it. Any suggestions?
For install tracking on iOS, Google Analytics relies on Apple's resettable Identifier for Advertising (IDFA) to match app sessions to campaigns. To accomplish this, Google Analytics relies on Ad Networks to provide and send the IDFA and other campaign information to Google Analytics when an app user clicks on an ad.
Google Analytics automatically collects certain data and offers optional features that determine which additional types of data are collected and how they are used. An app instance id is automatically assigned to each instance of an app, for purposes of computing user metrics throughout Analytics.
If you don't need a reference to your tracker (and it looks like you don't) you can remove the warning by changing the last line of code from
id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-YOUR-TRACKING-ID"];
to
[[GAI sharedInstance] trackerWithTrackingId:@"UA-YOUR-TRACKING-ID"];
A use case for keeping a reference to the tracker in this block of code could be if you wanted to create an event for when a user starts the application, without having to call [GAI sharedInstance]
to get that reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With