Google Analytics(分析)链接器插件/跨域跟踪

时间:2016-04-25 13:48:15

标签: google-analytics cross-domain

我想使用Google Analytics跟踪多个域的流量。最初我将每个域设置为一个单独的属性,每个属性都有自己的跟踪ID。最近我的代码出了问题,所以去修复它并找到了this info on Cross Domain Tracking,其中说我需要使用相同的跟踪ID为我的所有域设置一个属性。

我之前关注的是the instructions on this site Auto Linker插件。我认为我这样做的方式是正确的。我成功修复了跟踪代码,但我对如何设置属性和跟踪ID感到困惑。我是否应为每个域都有一个单独的ID,或者我的所有域中是否需要一个跟踪ID?

以下是我当前跟踪ID代码以跟踪多个域(当然,我有正确的跟踪ID,其中-XXXXXX-X是,我只是放入示例域来显示我正在做的事情):

    <!-- Google Analytics -->
    <script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXXX-X', 'auto', {'allowLinker': true});
  ga('require', 'linker');
  ga('linker:autoLink', ['source.com', 'destination-1.com', 'destination-2.com', 'destination-3.com', 'destination-4.com'] );
  ga('send', 'pageview');

</script>
<!-- End Google Analytics -->

0 个答案:

没有答案
相关问题