开发者

google analytics - multiple trackers on one page (traditional and asynchronous)

I'm writing a widget that will be embedded in other people's websites. I'm using Google Analyt开发者_开发百科ics to track all the people that visit all instances of my script on the embedding websites. I understand that the new asynchronous tracking code resolves this problem so that there's no interference with those websites' own Google Analytics accounts.

However, what if my analytics tracking code uses the new asynchronous tracker, and the embedding website is using the legacy (traditional) tracking code? Would there be any interference between these two blocks of code?

My tracker code:

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

Embedding website's code:

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

Can pageTracker and myTracker co-exist and register analytics information to their own separate accounts?


As far as official advice goes this is not a supported scenario:

  • http://www.google.com/support/forum/p/Google+Analytics/thread?tid=3490dc16fec867c5&hl=en

And there are pitfalls:

  • http://www.lunametrics.com/blog/2009/02/26/pitfalls-tracking-multiple-accounts-ga/

When you say embedded in peoples websites if you mean that your widget lives inside an iframe then you dont need to worry.

If the code is going to be loose in the page then you should try to use a different variable name to the default one so it doesn't clash. This means change the var _gaq = ... to something else and then renaming it throughout your code.

  • http://www.google.com/support/forum/p/Google+Analytics/thread?tid=5c7a6e5751bf5789&hl=en

I'm not entirely clear on your setup but if it is being inserted into many domains you are going to need to set up multiple GA accounts and use different account numbers per user.

If this is for clients that you have access to then you might consider simply adding an extra user to the report so that you can view all the accounts from one central account:

  • http://www.google.com/support/analytics/bin/answer.py?hl=en_US&answer=55500&utm_id=ad
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜