我刚刚实施了谷歌分析,并在我的一个iOS设备上运行该应用程序。但是,实时报告仍显示所有内容0 。我已经设置了谷歌分析如下。如果有任何建议,我们会感激不尽。
AppDelegate.swift didFinishLaunchingWithOptions方法: -
guard let gai = GAI.sharedInstance() else {
assert(false, "Google Analytics not confiugured correctly.")
}
gai.tracker(withTrackingId: "UA-10317xxxx-1")
// Optional: automatically report uncaught exceptions.
gai.trackUncaughtExceptions = true
LoginVC.swift viewWillAppear方法: -
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
setupTracker()
}
LoginVC.swift setupTracker()方法: -
private func setupTracker() {
let name = "Login VC"
guard let tracker = GAI.sharedInstance().defaultTracker else { return }
tracker.set(kGAIScreenName, value: name)
guard let builder = GAIDictionaryBuilder.createScreenView() else { return }
tracker.send(builder.build() as [NSObject : AnyObject])
}
答案 0 :(得分:1)
需要在app delegate中设置let a = 1, b = 2;
function* foo() {
a++;
yield;
b = b * a;
a = (yield b) + 3;
}
function* bar() {
b--;
yield;
a = (yield 8) + b;
b = a * (yield 2);
}
function step(gen) {
let it = gen();
let last;
return function () {
last = it.next(last).value;
};
}
let s1 = step(foo);
let s2 = step(bar);
s2(); //b=1 last=undefined
s2(); //last=8
s1(); //a=2 last=undefined
s2(); //a=9 last=2
s1(); //b=9 last=9
s1(); //a=12
s2(); //b=24
console.log(a, b);
的默认跟踪器,如下所示。
GAI
另外,为了了解后台发生的情况,我们总是可以通过将GAI记录器级别设置为GAI.sharedInstance().defaultTracker = gai.tracker(withTrackingId: "<<Trakcing Key goes here>>")
来检查日志
实时计数和几乎所有GA功能对我来说都不是真正的时间。我们可能需要花一些时间来查看GA仪表板中的匹配。通常10-15分钟