Google analytics 谷歌分析[[GANTracker sharedTracker]stopTracker];

Google analytics 谷歌分析[[GANTracker sharedTracker]stopTracker];,google-analytics,google-analytics-api,Google Analytics,Google Analytics Api,现在,我在我的Ipad应用程序中使用Google Analytic来跟踪页面视图和事件,我在下面为所有viewController和按钮单击事件实现了代码,但当我的视图消失时,我的应用程序停止/崩溃。我已经将stopTracker代码放入了stopTracker[[GANTracker sharedTracker]stopTracker] [[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-12345678-1"

现在,我在我的Ipad应用程序中使用Google Analytic来跟踪页面视图和事件,我在下面为所有viewController和按钮单击事件实现了代码,但当我的视图消失时,我的应用程序停止/崩溃。我已经将stopTracker代码放入了stopTracker
[[GANTracker sharedTracker]stopTracker]

[[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];

尝试将对stopTracker的调用移动到AppDelegate的dealloc方法。将其作为该方法中的第一行

你应该只给stopTracker打一次电话,而且应该在我上面提到的地方。您还应该将共享跟踪器的初始化从ViewController中移出,并移入appDelegate的appDidFinishLaunching方法,同样,这种情况只会发生一次

只有一个共享跟踪器在应用程序启动时初始化,并在应用程序终止时最终“停止”