English 中文(简体)
谷歌分析-一个页面上有多个跟踪器(传统和异步)
原标题:google analytics - multiple trackers on one page (traditional and asynchronous)

我正在写一个小部件,它将嵌入其他人的网站。我正在使用谷歌分析来跟踪所有访问嵌入网站上我的脚本实例的人我了解新的异步跟踪代码解决了这个问题,这样就不会干扰那些拥有谷歌分析账户的网站。

然而,如果我的分析跟踪代码使用新的异步跟踪器,而嵌入网站使用传统的跟踪代码,该怎么办?这两块代码之间会有干扰吗?

我的跟踪器代码:

<script>
...
_gaq.push(
  [ myTracker._setAccount ,  UA-XXXXX-2 ], // naming the tracker  myTracker  to be different from any default tracker already defined
  [ myTracker._trackPageview ]
);
...
</script>

嵌入网站的代码:

<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-xxxxxx-1");
pageTracker._trackPageview();
} catch(err) {}</script>

pageTracker和myTracker是否可以共存并将分析信息注册到各自的独立帐户?

问题回答

就官方建议而言,这不是一个受支持的场景:

还有一些陷阱:

当你说嵌入到人们的网站中时,如果你的意思是你的小部件位于iframe中,那么你不需要担心。

如果代码在页面中变得松散,那么您应该尝试使用与默认变量名不同的变量名,这样就不会发生冲突。这意味着更改var _gaq=。。。转换为其他内容,然后在整个代码中对其进行重命名。

我不完全清楚你的设置,但如果它被插入到许多域中,你需要设置多个GA帐户,并为每个用户使用不同的帐号。

如果这是针对您有权访问的客户端,那么您可以考虑简单地向报告中添加一个额外的用户,以便您可以从一个中心帐户查看所有帐户:





相关问题
Javascript drop down menu widget

I have a menu consisting of an <ul> in a Web CMS. I want several menu items to have sub-items that are displayed in a dropdown list. These sub-items are <ul>s as well. This is basically ...

placing widget in listbox/dropdown in gwt

i am using gwt to build my web site. i would like to create a dropdown/listbox that contains no just text but also images, meaning that in the drop down there will be a what ever widget that ill ...

Share & Embed Widget design samples?

I am searching for some sample interface or design for creating a "Share & Embed Widget or Link" interface in my website. I found scribd.com s interface interesting http://www.scribd.com/doc/...

Marketshare of cross-platform widget libraries?

For a variety of reasons, we re in the market for a cross-platform widget library. We re in the somewhat rare situation of not being tied to a particular programming language at this stage, so we get ...

Dojo Tabs as Custom Widgets

I ve created a number of widgets that are loaded as tab panes in a tabcontainer. Everything seems to work well, except I m getting different results when using my custom widgets vs. creating ...

google chat web client

I am looking for a google chat client that I can embed in my website so visitors can chat with me directly. I haven t found any widgets like the google voice widget in which a visitor is connected ...

Hiding a QWidget on a QToolbar?

I have directly added some QWidgets to a QToolbar but simply going widget->setVisible(false) did not work. Can someone please give me an example of how to show and hide a widget that is on a QToolbar? ...

热门标签