简体   繁体   English

在同一页面上使用两个 Google Analytics 跟踪器

[英]Using two Google Analytics trackers on the same page

I need to be able to use more than one Google Analytics on a page.我需要能够在一个页面上使用多个 Google Analytics。 How can I do that with the async code?我怎么能用异步代码做到这一点?

Getting the tracker used to work a bit like that (not sure about the exact code):让跟踪器有点像那样工作(不确定确切的代码):

var tracker2 = _gat.getTracker("tracker2");
tracker2.trackPageView();

However with the new async API, it's not possible to retrieve a value, so how can it be done?但是,使用新的异步 API 时,无法检索值,那么该怎么办呢?

Have a look at: http://code.google.com/intl/de/apis/analytics/docs/tracking/asyncUsageGuide.html#MultipleCommands看看: http://code.google.com/intl/de/apis/analytics/docs/tracking/asyncUsageGuide.html#MultipleCommands

Edit:编辑:

var _gaq = _gaq || [];
_gaq.push(
  ['a._setAccount', 'UA-XXXXX-X'],
  ['a._trackPageview'],
  ['b._setAccount', 'UA-XXXXX-X'],
  ['b._trackPageview']
);

This creates two Trackers called a and b这将创建两个名为ab的 Tracker

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM