several months ago I downloaded the latest version of the google analytics SDK for IOS to try out tracking analytics for my app. I followed all the instructions, downloaded the SDK, stubbed out the code, created google analytics account and appropriate property with its respective reporting view, plugged in the tracking code and it all worked great. (this was something I was working on that was not ready for production yet, so we did not make it live).
I put it down for a few months, then recently resurrected the code I had written, and for some reason google analytics no longer seems to be keeping track of screens that I am on, nor does it keep track of events that I track.
I have verbose logging turned on, and this is about all of the information I get from the console now. I used to get a lot of info every time I sent data about a screen view or event to google analytics.
Google analytics console output:
VERBOSE: GoogleAnalytics 3.11 +[GAITrackerModel initialize] (GAITrackerModel.m:88): idfa class missing, won't collect idfa
this error message doesn't matter I do not think because I am not displaying any ads in my app
INFO: GoogleAnalytics 3.11 -[GAIReachabilityChecker reachabilityFlagsChanged:] (GAIReachabilityChecker.m:159): Reachability flags update: 0X000002
I believe this status code indicates I am able to reach google analytics
INFO: GoogleAnalytics 3.11 -[GAIBatchingDispatcher hitsForDispatch] (GAIBatchingDispatcher.m:368): No pending hits.
not really sure what this means, but after this message gets displayed I get no more feedback from google analytics whenever I try to send screen data or event data to it
Here is my code in the app delegate class:
// setup google analytics
// Optional: automatically send uncaught exceptions to Google Analytics.
[GAI sharedInstance].trackUncaughtExceptions = YES;
// Optional: set Google Analytics dispatch interval to e.g. 20 seconds.
[GAI sharedInstance].dispatchInterval = 20;
[[GAI sharedInstance] setDryRun:NO];
// Optional: set Logger to VERBOSE for debug information.
[[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose];
// Initialize tracker. Replace with your tracking ID.
[[GAI sharedInstance] trackerWithTrackingId:@"mytrackingIDgoeshere"];
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
tracker.allowIDFACollection = NO;
NSString *version = [[NSBundle mainBundle] `objectForInfoDictionaryKey:@"CFBundleShortVersionString"];`
[tracker set:kGAIAppVersion value:version];
[tracker set:kGAISampleRate value:@"50.0"];
Here is the code I use to manually send screen and event data.
Some of it is stubbed out to be made generic to not reveal personal info about my app.
// MANUALLY STARTING A SESSION:
// start session
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
// You only need to set User ID on a tracker once. By setting it on the tracker, the ID will be
// sent with all subsequent hits.
[tracker set:@"&uid"
value:self.sessionID];
[tracker send:[[GAIDictionaryBuilder
createEventWithCategory:@"User ID"
action:@"User Starts Session"
label:deviceLabel
value:nil] build]];
GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createScreenView];
[builder set:@"start" forKey:kGAISessionControl];
[tracker set:kGAIScreenName value:vcName];
[tracker send:[builder build]];
// MANUALLY ENDING A SESSION:
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createScreenView];
[builder set:@"end" forKey:kGAISessionControl];
[tracker set:kGAIScreenName value:vcName];
[tracker send:[builder build]];
// MANUALLY SENDING SCREEN VIEW INFO TO GA
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName value:sceneName];
[tracker send:[[GAIDictionaryBuilder createScreenView]build]];
// EXAMPLE CODE OF MANUALLY SENDING EVENT DATA TO GA
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName value:sceneName];
[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"ui_action" action:@"table_row_selected" label:rowTitle value:nil]build]];
[tracker set:kGAIScreenName value:nil];
And that is it. This all used to work, and I keep pouring over the documentation over and over again and nothing seems to be wrong.
How do I troubleshoot this issue?
Thank you for your time.
Update: I created a new property with a different tracking code to track other types of information(basically I am using more than one tracker in my app now), and now for whatever reason the old tracker that I got working no longer works, despite whatever I try, but the other tracker that I use to log network info, i.e. web service calls etc does work. I am honestly thinking at this point this is a google thing. I don't comprehend why it was working and now it isn't. I did not change anything related to the original property or tracking info at all.