Google Analytics [[GANTracker sharedTracker] stopTracker];

I am currently using Google Analytic in my iPad application to track pageviews and events that I have executed under the code for all of my viewController and button click events, but when my view has disappeared, my application stops / crashes. I put the stopTracker code [[GANTracker sharedTracker] stopTracker];in viewWillDisappear.

[[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-12345678-1"
                                       dispatchPeriod:kGANDispatchPeriodSec
                                             delegate:nil];

NSError *error;
if (![[GANTracker sharedTracker] setCustomVariableAtIndex:1
                                                     name:@"iPad3"
                                                    value:@"iv1"
                                                withError:&error]) {
    // Handle error here
}

if (![[GANTracker sharedTracker] trackEvent:@"my_category"
                                     action:@"my_action"
                                      label:@"my_label"
                                      value:-1
                                  withError:&error]) {
    // Handle error here
}

if (![[GANTracker sharedTracker] trackPageview:@"/app_entry_point_prashant"
                                     withError:&error]) {
    // Handle error here
}
[[GANTracker sharedTracker] stopTracker];
+5
source share
1 answer

Try transferring the stopTracker call to the dealloc method of your AppDelegate. Make this the first line inside this method.

stopTracker , , . appDidlegate appDidFinishLaunching, .

, "", .

0

All Articles