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

标签 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>

提前感谢 jack

最佳答案

是的,无需更新任何旧代码即可实现。您必须将其他帐户添加到主帐户:

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

  2. 显示三列帐户属性查看

  3. 根据访问权限从帐户属性(property)查看中选择用户管理

  4. 输入电子邮件地址并分配卷。

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

关于javascript - 谷歌分析,使用两个不同的帐户跟踪同一网站,如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22068255/

相关文章:

javascript - 为什么我的文本框的 onchange 事件会在模糊时触发 - 不是每个键入的字符都会触发?

javascript - Backbone.js:将更改后的模型 ID 保存到服务器的最佳方式

javascript - 使用类原型(prototype)键入 : Type declaration for JS module exporting instance of class,

javascript - 没有 javascript 的域上的 GA 跨域跟踪

javascript - 如何注册在 Google Analytic 中被点击的按钮?

google-analytics - (加速移动页面)AMP 分析

javascript - DIV 突然出现而不是 slideDown() 方法发生

javascript - 使用 passport.authenticate 后注册

google-analytics - 为什么像 Google Analytics 这样的 Web Analytics 使用维度和指标而不是 SQL 语句?

google-analytics - 通过 BigQuery 访问 Firebase 封闭漏斗中的结构和数组