2

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?

1 Answer 1

1

I found out what the problem was. All the coding was correct (although the 'Successfully deleted' log was strange).

I had to configure my App property in Google Analytics. I created a Data Display and had to set the property Standard Display Data to the Data Display I created.

(My GA is not in English so don't know the exact name for Data Display)

I followed this link for instructions, don't skip to the coding part, the Before you Begin is also very important!

4
  • Please can you elaborate on "I created a Data Display and had to set the property Standard Display Data to the Data Display I created."? Thanks
    – Adam Waite
    Commented Nov 12, 2014 at 11:26
  • If you follow the link in my answer you see you have to have an account, a property and app view. In the link is described how to make them.
    – Tom Spee
    Commented Nov 12, 2014 at 18:04
  • Argh I think I have all those described in those docs. Really stumped as to what I'm doing wrong! I've set this up tens of times in the past without a problem. Frustrating!
    – Adam Waite
    Commented Nov 13, 2014 at 11:24
  • 1
    Oh, it's decided to start working without me even touching it today! It must have been a problem at their end...
    – Adam Waite
    Commented Nov 13, 2014 at 11:26

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.