I wonder if anyone can help me, I'm trying to tune Google Analytics to my iOS project. I just need a very simple implementation to show the number of views loaded. I followed google docs ( https://developers.google.com/analytics/devguides/collection/ios/v3/ ) but nothing was updated in my dashboard
I have a property that does not tell users
My appdelegate is as follows
#import <UIKit/UIKit.h> #import "GAI.h" @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property(nonatomic, strong) id<GAITracker> tracker; @end
my.m contains - (BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions {
[GAI sharedInstance].trackUncaughtExceptions = YES; // Optional: set Google Analytics dispatch interval to eg 20 seconds. [GAI sharedInstance].dispatchInterval = 20; // Optional: set Logger to VERBOSE for debug information. [[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose]; // Initialize tracker. which i have set up at the top of my .mn self.tracker = [[GAI sharedInstance] trackerWithTrackingId:kTrackingId]; return YES; }
And the page on which I am trying to record the import metrics #import "GAI.h" #import "GAIDictionaryBuilder.h"
and contains the following method
-(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; id tracker = [[GAI sharedInstance] defaultTracker]; // This screen name value will remain set on the tracker and sent with // hits until it is set to a new value or to nil. [tracker set:@"&cd" value:@"Home Screen"]; // manual screen tracking [tracker send:[[GAIDictionaryBuilder createAppView] build]]; }
I do not see any errors, I get the console initial log
NFO: GoogleAnalytics 3.02 - [GAIReachCheckerFlagsChanged Reach:] (GAIReachCheckChecker.m: 159): Updating Reach Flags: 0X000002
But I get nothing in the dashboard
I also tried the Auto method specified at ( https://developers.google.com/analytics/devguides/collection/ios/v3/screens ), however this complained about the lack of a screen name
It drives me crazy! Any help would be appreciated!
UPDATE
Using the example included in the SDK, I was able to get the initial load for registering with google - note that this is different from google documentation:
Appdelegate
NSDictionary *appDefaults = @{kAllowTracking: @(YES)}; [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
I used automatic screen tracking for the initial view controller according to google docs, however this only works on the initial loaded view controller, subsequent views using the same method are not logged.
And now my problem is that the APPdelegate method only works in the “didFinishLaunchingWithOptions application”, which will only work if the application terminates each time by putting the same code in the “applicationWillEnterForeground”, it doesn’t work - so frustrating - also tried to
self.tracker = [[GAI sharedInstance] defaultTracker]; [self.tracker set:kGAISessionControl value:@"start"];
which apparently has no effect: