0

我不确定我的标题,如果你有更好的,请编辑我

好的,我的网站中有 2 个 Google Analytics(分析)代码。

<script type="text/javascript">
              var _gaq = _gaq || [];
              _gaq.push(['_setAccount', 'UA-XXX-A']);
              _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-XXX-B']);
              _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>

我推动我的目标就像..

_gaq.push(['_trackEvent','Form','Submitted','Test']);

如何仅对UA-XXX-A进行此目标跟踪?

4

1 回答 1

1

使用多个配置文件的最佳做法是命名辅助跟踪器 - 请参阅Google 文档以获取_gaq.push(). _trackEvent页面中任何不使用名称的分析调用(如您的调用)都将使用第一个(默认)跟踪器。

此外,您将加载分析代码两次。加载一次将加快您的页面速度并为您提供更多可重复的数据收集。

尝试

<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXX-A']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['t2._setAccount', 'UA-XXX-B']);
  _gaq.push(['t2._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>
于 2013-11-22T15:12:53.273 回答