Greetings,
I’ve been wrestling with Google analytics for iPhone for a bit and I’m noticing the 10 second dispatchPeriod is being ignored. All the events I’m tracking are coming through just fine on the google analytics site however I believe the only the time the data is uploaded is when the app is restarted. I was hoping the dispatch schedule would take care of any queued up events.
I start my tracker like so:
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"App Delegate: applicationDidFinishLaunching");
[[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-xxxxxxx-x"
dispatchPeriod:10
delegate:self];
NSError *error;
if (![[GANTracker sharedTracker] trackEvent:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]
action:@"launch"
label:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]
value:-1
withError:&error]) {
NSLog(@"GANTracker - %@", [error localizedDescription]);
}
[window addSubview:self.navigationController.view];
[window makeKeyAndVisible];
return YES;
}
-(void)trackerDispatchDidComplete:(GANTracker *)tracker eventsDispatched:(NSUInteger)eventsDispatched eventsFailedDispatch:(NSUInteger)eventsFailedDispatch
{
//The delegate method only gets called once at launch
NSLog(@"Google Analytics: Events Dispatched = %i | Events Failed Dispatched = %i", eve
ntsDispatched, eventsFailedDispatch);
}
and I track events like so:
if (![[GANTracker sharedTracker] trackEvent:@"preview"
action:@"preview"
label:@"preview"
value:-1
withError:&error]) {
NSLog(@"GANTracker - %@", [error localizedDescription]);
}
Figured it out. Was an issue with calling the trackEvent method from a detached tread.