0

On click of a button, I send the user to an external URL (safari). I was to track this action, so I include a call to google analytics right before I call openUrl()

id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"action" action:@"button_press" label:@"link" value:nil] build]];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
    [[UIApplication sharedApplication] openURL:url];
}

This successfully gets me to the url in safari, but on coming back to the app, it is just frozen. I have tried wrapping it in dispatch_async main queue block, with no luck.

If I remove the google analytics tracker line, it works fine. Is this a bug in google analytics?

Jameo
  • 4,507
  • 8
  • 40
  • 66

1 Answers1

0

I found a temporary solution, although its not the best. Basically, if I dispatch the tracking code by a second, the hanging does not happen. I checked in my dashboard, and the call still gets tracked.

let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(1 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {
    var tracker = GAI.sharedInstance().defaultTracker
    tracker.send(GAIDictionaryBuilder.createEventWithCategory(category, action: event, label: label, value: nil).build() as [NSObject : AnyObject])
}

I hope google takes a look at this call, as this is not an optimal solution.

Jameo
  • 4,507
  • 8
  • 40
  • 66