I'm trying to integrate Google Analytics with my iOS application. I followed the tutorial from Ray Wenderlich from his website.
I added all the files from the GA SDK and added the libraries CoreData, SystemConfiguration, libz.dylib, libGoogleAnalyticsServices.a and AdSupport. I added this code in my AppDelegate didFinishLaunchingWithOptions:
[GAI sharedInstance].trackUncaughtExceptions = YES;
[GAI sharedInstance].dispatchInterval = 20;
[[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose];
[[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXXXXX-2"];
My ViewController.h is like this:
#import "GAITrackedViewController.h"
@interface GroupsViewController : GAITrackedViewController <UITableViewDataSource, UITableViewDelegate>
And in ViewController.m I added this code in the ViewDidAppear and added #import "GAI.h":
self.screenName = @"Test View";
When I run the app on my device I get a response like this:
2014-11-08 11:24:45.096 MyApp[12057:3781223] 06g80YZdV4
2014-11-08 11:24:45.104 MyApp[12057:3781244] VERBOSE: GoogleAnalytics 3.10 -[GAIBatchingDispatcher persist:] (GAIBatchingDispatcher.m:497): Saved hit: {
parameters = {
"&_crc" = 0;
"&_u" = ".o";
"&_v" = "mi3.1.0";
"&a" = 1319486949;
"&aid" = "com.myname.MyApp";
"&an" = "MyApp";
"&av" = "1.0";
"&cd" = "Test View";
"&cid" = "35ffca8c-66fb-4b50-b23c-bd74f9fe1351";
"&ds" = app;
"&sr" = 320x568;
"&t" = appview;
"&tid" = "UA-XXXXXXX-2";
"&ul" = nl;
"&v" = 1;
"&z" = 4204001371526698847;
gaiVersion = "3.10";
};
timestamp = "2014-11-08 10:24:45 +0000";
}
2014-11-08 11:24:45.778 MyApp[12057:3781223] Found: 3 groups
2014-11-08 11:24:50.822 MyApp[12057:3781244] VERBOSE: GoogleAnalytics 3.10 -[GAIRequestBuilder requestPostUrl:payload:compression:] (GAIRequestBuilder.m:167): building URLRequest for https://ssl.google-analytics.com/batch
2014-11-08 11:24:50.824 MyApp[12057:3781244] VERBOSE: GoogleAnalytics 3.10 -[GAIBatchingDispatcher dispatchWithCompletionHandler:] (GAIBatchingDispatcher.m:612): Sending hit(s) POST: https://ssl.google-analytics.com/batch
2014-11-08 11:24:51.007 MyApp[12057:3781223] INFO: GoogleAnalytics 3.10 -[GAIBatchingDispatcher didSendHits:response:data:error:] (GAIBatchingDispatcher.m:208): Hit(s) dispatched: HTTP status 200
2014-11-08 11:24:51.009 MyApp[12057:3781244] INFO: GoogleAnalytics 3.10 -[GAIBatchingDispatcher deleteHits:] (GAIBatchingDispatcher.m:509): hit(s) Successfully deleted
2014-11-08 11:24:51.013 MyApp[12057:3781244] INFO: GoogleAnalytics 3.10 -[GAIBatchingDispatcher didSendHits:] (GAIBatchingDispatcher.m:219): 2 hit(s) sent
I noticed that most of the output seems correct. But I noticed a difference between the 'GAIBatchingDispatcher deleteHits' in my output and the one from the tutorial. Mine says: Successfully deleted but the tutorials output says Successfully dispatched.
How can I fix this so my Apps ViewController will be tracked with Google Analytics?