Google Analytics:使用 _gat._createTracker 对已创建的跟踪器对象调用 _setAccount
我对 Google Analytics 的示例代码有点困惑(谁不是?)。 在他们的示例代码中,他们写道:
_gaq.push(function() {
var pageTracker = _gat._createTracker("UA-XXXXX-X", "myTracker");
});
然后...
_gaq.push(["myTracker._setAccount", "UA-XXXXX-X"]); // #1
_gaq.push(function() {
var myTracker = _gat._getTrackerByName("myTracker");
myTracker._trackEvent(...);
});
我不明白为什么他们设置跟踪器的帐户(#1),因为跟踪器对象是由帐户创建的,我通过其名称获取跟踪器对象。
有人有过这样的经验吗这? 谢谢。
I'm a bit confused with the sample code at Google Analytics (who isn't?).
In their example code they write:
_gaq.push(function() {
var pageTracker = _gat._createTracker("UA-XXXXX-X", "myTracker");
});
And then later...
_gaq.push(["myTracker._setAccount", "UA-XXXXX-X"]); // #1
_gaq.push(function() {
var myTracker = _gat._getTrackerByName("myTracker");
myTracker._trackEvent(...);
});
I don't understand why they set the tracker's account (#1), because the tracker object is created by account, and I get the tracker object by its name.
Asynchronous Tracking Usage Guide, Pushing Functions
Does anybody have any experience with this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己解决了这个问题,通过发送不同的跟踪事件来查看 GA 接受的跟踪事件,并且所有这些事件都已收到。因此,在我的例子中(上面的代码),他的帐户是否在创建的跟踪器对象上设置并不重要。但仍然令人困惑的是,这是可能的,但谷歌却没有给出很好的解释!
I solved this my self by sending different tracking events to see which one that are accepted by GA, and all of them were received. So in conslusion, in my case (code above), it does not matter whether he account is set on the created tracker object or not. But still, its kind of confusing that it is possible, and yet there is no good explaination from Google!