开发者

Can one pagetracker object send data to multiple Google Analytics account?

Google's sample code shows multiple accounts can track a page using different tracker object

_gaq.push(
  ['_setAccount', 'UA-XXXXX-1'],
  ['_trackPageview'],
  ['b._setAccount', 'UA-XXXXX-2'],
  ['b._trackPageview']
);

But would it be ok if we just use the same tracker object like below since the API call is being queued and executed on first-in-first-out basis?

var _gaA开发者_StackOverflow社区ccounts = ['UA-XXXXX-1', 'UA-XXXXX-2'];
  for(var i=0; i<_gaAccounts.length ; i++)
{
  _gaq.push(['_setAccount', _gaAccounts[i]],
             ['_trackPageview']);
}


As per @jen's comment, it's far more efficient to do a single push to Google than to do 4 individual pushes. Remember that these are calls to a remote server, so best to keep them to a minimum.

In theory, your code should work and that's backed up by Brian Katz's post here. In practice, however, I think there's a danger of you overwriting your cookies and screwing up your analytics. Multiple trackers continually cause problems if not configured correctly - so why add an extra unsupported step?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜