谷歌分析,跟踪两个不同帐户的同一网站,如何?

时间:2014-02-27 12:15:43

标签: javascript google-analytics

如标题所示,如何使用Google Analystics从两个不同的帐户跟踪网站?

我对这个主题做了一些研究,发现很多旧帖子说你应该在每一侧都包含不同的跟踪代码。但这不是最好的方法,对吗?

有可能做这样的事吗?

旧代码:

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

新代码:

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
_gaq.push(['_setAccount', 'UA-xxxxxxxx-2']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

先谢谢杰克

2 个答案:

答案 0 :(得分:1)

您可以使用以下代码在两个不同的GA帐户中跟踪同一页面:

var _gaq = _gaq || [];
  _gaq.push(
  ['_setAccount', 'UA-12345678-1'],   // First account
  ['_trackPageview'],
  ['b._setAccount', 'UA-87654321-1'], // Second account
  ['b._trackPageview']
);
(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

这一直对我们有用。

答案 1 :(得分:1)

是的,可以不更新任何旧代码。您必须将其他帐户添加到主帐户:

  1. 点击Google Analytic页面顶部的管理

  2. 要显示三列帐户财产查看

  3. 根据访问权限,从帐户 PROPERTY VIEW 中选择用户管理

  4. 输入电子邮件地址并指定roll。

  5. 检查您的辅助电子邮件地址网站跟踪是否与主电子邮件地址相同。