Google Analytics(分析)不会跟踪iOS上的视图? [英] Google Analytics won't track a view on iOS?

查看:109
本文介绍了Google Analytics(分析)不会跟踪iOS上的视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将最新的Google AnalyticsSDK添加到我的iOS应用程序(2.0版beta 4)。
我在指南中说过,并将此代码添加到应用程序委托中:

I've added the newest Google Analytics SDK to my iOS application (version 2.0 beta 4). I did the same as the guide says and added this code to app delegate:

// Optional: automatically send uncaught exceptions to Google Analytics.
[GAI sharedInstance].trackUncaughtExceptions = YES;
// Optional: set Google Analytics dispatch interval to e.g. 20 seconds.
[GAI sharedInstance].dispatchInterval = 20;
// Optional: set debug to YES for extra debugging information.
[GAI sharedInstance].debug = YES;
// Create tracker instance.
self.tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-TRACKINGID-2"];//UA-33873963-13 - My testing google analytics trackingId

[self.tracker setSessionStart:YES];
[self.tracker setSessionTimeout:60];

现在,我在每个视图中添加了这个:

Now, on each view I've added this:

self.trackedViewName = @"Main Menu Screen";

一切正常,但由于某些原因,20个屏幕中有3个不会自行发送给Google,我不知道为什么。我在网上搜索过,但没有人遇到过这个问题。我想,如果有人熟悉这个问题,它是在堆栈溢出。

Everything works fine, but for some reason 3 out of the 20 screens is not sending themselves to Google and I don't have a clue why. I've searched all over the net, but no one has came across this issue. I figured that if someone familiar with this issue, it's on stack-overflow.

请帮助我。
Thanks!

Please help me. Thanks!

推荐答案

这个问题已经用最简单的方法解决了。

The problem has been fixed with the simplest way.

我写的代码是 AppDelegate 。跟踪器使用跟踪ID初始化一次后,您只需在每个使用它的视图中调用它。 (我不太确定,但无论如何它对我有用。)

The code that I wrote up, is for the AppDelegate. After the tracker has been initialized once with tracking ID, you just need to call it in each view that you are using it. (I'm not sure about that but anyway it worked for me.)

因此,在 AppDelegate

So, in the AppDelegate:

// Optional: automatically send uncaught exceptions to Google Analytics.
[GAI sharedInstance].trackUncaughtExceptions = YES;
// Optional: set Google Analytics dispatch interval to e.g. 20 seconds.
[GAI sharedInstance].dispatchInterval = 20;
// Optional: set debug to YES for extra debugging information.
[GAI sharedInstance].debug = YES;
// Create tracker instance.
self.tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-TRACKINGID-2"];//UA-33873963-13 - My testing google analytics trackingId

[self.tracker setSessionStart:YES];
[self.tracker setSessionTimeout:60];

视图控制器内部 viewDidLoad

Inside the view controllers viewDidLoad:

[GAI sharedInstance] defaultTracker];
[self.tracker sendView:@"Some name"];

完成此操作后,效果非常好。

After doing this, it worked perfectly.

这篇关于Google Analytics(分析)不会跟踪iOS上的视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆