名称空间帐户不起作用在Universal Analytics下 [英] Name Spaced Accounts Not working Under Universal Analytics

查看:99
本文介绍了名称空间帐户不起作用在Universal Analytics下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想迁移到通用analytics.js,但是当我尝试在analytics.js代码段中实现多个帐户时,默认帐户效果很好,并以实时显示,但后续帐户从未显示Real时间和流量下降到0.



目前我使用ga.js跟踪单个代码段中的多个帐户。这里是我使用的格式:

 < script type =text / javascript> 
var _gaq = _gaq || [];
_gaq.push(
['_setAccount','UA-XXXXXXXX-2X'],
['_setDomainName','example.com'],
['_addIgnoredRef' ,'example.com'],
['_trackPageview'],
['b._setAccount','UA-YYYYYYYY-2Y'],
['b._setDomainName',' example.com'],
['b._addIgnoredRef','example.com'],
['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 =文档.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga,s);
})();
< / script>

以下是我一直在尝试使用analytics.js工作的代码片段。

 < 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' , '// www.google-analytics.com/analytics.js','ga');

ga('create','UA-XXXXXXXX-2X','example.com');
ga('send','pageview');
ga('create','UA-YYYYYYYY-2Y',{'name':'rollup'});
ga('rollup.send','pageview');

< / script>

汇总名称空间不会实时在汇总帐户中注册。 UA-XXXXXXXX-2X代码在实时中很好地注册。



我运行了Google Analytics(分析)调试程序,它似乎创建了这两个帐户,并且发送时没有错误,只显示适合的信息:

 运行命令:ga(create,UA-YYYYYYYY-2Y,[object Object])
创建新的跟踪器:汇总
运行命令: ga(rollup.send,pageview)

任何人都可以针对我的问题提供一些指导analytics.js snippet?

解决方案

以下是Google通用分析代码,可合并两个配置文件,甚至发送人口统计数据。

只需将UA-XXXXXX-Y替换为UA-XXXXXX-X,然后将其替换为您的Google Analytics跟踪ID即可。
,并用网站域取代EXAMPLE.com并全部开始。

仅供参考 - OldSite - 您可以将其替换为任何您喜欢的 - 它只是用于GA发送捕获的数据的单独配置文件。所以你可以使用SecondProfile,IloveCodes或其他。

这个脚本另外发送人口统计数据和其他数据 - 这有多酷?



享受!



感谢所有帮助我解决问题的人。

 < 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' , '// www.google-analytics.com/analytics.js','ga');

ga('create','UA-XXXXXX-Y','EXAMPLE.com');
ga('create','UA-XXXXX-X',{'name':'Oldsite'});
ga('send','displayfeatures');
ga('Oldsite.send','displayfeatures');
ga('send','pageview');
ga('Oldsite.send','pageview');
< / script>


I would like to migrate to universal analytics.js, however when I try to implement multiple accounts in the analytics.js snippet, the default account works great and shows up in Real Time, however the subsequent account never shows up on Real Time and traffic drops off to 0.

Currently I'm using ga.js to track multiple accounts in the single snippet. Here is the format I am using for that:

    <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(
            ['_setAccount', 'UA-XXXXXXXX-2X'],
            ['_setDomainName', 'example.com'],
            ['_addIgnoredRef', 'example.com'],
            ['_trackPageview'],
            ['b._setAccount', 'UA-YYYYYYYY-2Y'],
            ['b._setDomainName', 'example.com'],
            ['b._addIgnoredRef', 'example.com'],
            ['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);
    })();
    </script>

Below is the snippet I have been trying to make work with analytics.js

    <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','//www.google-analytics.com/analytics.js','ga');

      ga('create', 'UA-XXXXXXXX-2X', 'example.com');
      ga('send', 'pageview');
      ga('create', 'UA-YYYYYYYY-2Y', {'name': 'rollup'});
      ga('rollup.send', 'pageview');

    </script>

The "rollup" name space never registers on the rollup account in real time. The UA-XXXXXXXX-2X code registers just fine in Real Time.

I have run Google Analytics Debugger and it appears to be creating both accounts and sending just fine with no errors only info that looks appropriate:

Running command: ga(create, UA-YYYYYYYY-2Y, [object Object])
Creating new tracker: rollup
Running command: ga(rollup.send, pageview)

Could anyone offer some guidance on what might be the problem with my analytics.js snippet?

解决方案

Here is the Google Universal Analytics Code that merges two Profiles and even sends demographic data.

Just replace - UA-XXXXXX-Y with UA-XXXXXX-X with your GA tracking IDs. and replace EXAMPLE.com with the website domain and all set to go.

FYI - OldSite - you can replace it with whatever you like - its just used separate profile for the GA to send captured data. so you can use SecondProfile, IloveCodes or whatever.

This script additionally sends demographics and other data - how cool is that?

Enjoy!

And Yes thanks to all the guys out there who helped me reaching out to this answer.

<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','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXXX-Y', 'EXAMPLE.com');
  ga('create', 'UA-XXXXX-X', {'name':'Oldsite'});
  ga('send', 'displayfeatures');
  ga('Oldsite.send', 'displayfeatures');
  ga('send', 'pageview');
  ga('Oldsite.send', 'pageview');
</script>

这篇关于名称空间帐户不起作用在Universal Analytics下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆