一个通用Google Analytics代码中有多个属性 [英] Multiple properties in one universal Google Analytics code

查看:104
本文介绍了一个通用Google Analytics代码中有多个属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的网站中嵌入基于全新Universal Analytics方法的GA代码。
我想要实现的是将数据从一个页面发送到多个属性。



因此,我检查了官方GA文档中关于新的通用GA代码特别是关于使用多个跟踪对象的部分。



https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#multipletrackers



但到目前为止没有成功。



我有一个标准网站www.website.de
和另一个用于移动网站de.website的域名。我的标准网站的GA代码如下所示:

 <$ c $ (函数(i,s,o,g,r,a,m){i ['GoogleAnalyticsObject'] = r; i [r] = i [r] || function(){
[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;一个。 src = g; m.parentNode.insertBefore(a,m)
})(window,document,'script','// www.google-analytics.com/analytics.js','ga');

ga('create','UA-12345678-1');
ga('create','UA-12345678-2',{'name':'newTracker'});
ga('send','pageview');
ga('newTracker.send','pageview');

在GA实时部分,我可以看到属性UA-12345678-1正在实时结果,但第二个属性根本没有得到结果。



有人知道原因吗?



澄清:在我的移动网站上,我想嵌入下面的代码:



我是否理解GA文档

 (功能(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)
}) (窗口,文件, '脚本', '// www.google-analytics.com/analytics.js','ga');

ga('create','UA-12345678-1');
ga('create','UA-12345678-3',{'name':'newTracker'});
ga('send','pageview');
ga('newTracker.send','pageview');

所以,我有三个属性:
UA-12345678-2为标准网站,
UA-12345678-3为移动网站
和UA-12345678-1作为两者的总和,使我有机会看到标准网站和移动网站的结果总结。至少这是我正在努力实现的目标。



欢迎任何想法。 / div>

你有什么工作。我自己去测试这个,果然,它没有奏效。接下来,我尝试删除这些对象之间的空格,就像我在过去看到的那样,这会导致代码不能显示在GA中。我不知道为什么,但通过从所有参数和对象中删除空格,我能够获得数据以实时报告显示。



我尝试将空格添加回参数和对象,但无法让数据再次显示出来。无论我做了什么,数据都在不断涌现。



我会试试这个:

 (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-12345678-1');
ga('create','UA-12345678-3',{'name':'newTracker'});
ga('send','pageview');
ga('newTracker.send','pageview');


I am trying to embed a GA code in my website that is based on the new Universal Analytics method. What I am trying to achieve is to send data to multiple properties from one page.

So I have checked the official GA documentation on the new universal GA code and specifically the section about "Working with multiple tracking objects".

https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#multipletrackers

But so far without success.

I have one domain for the standard website www.website.de and another one for the mobile website de.website.mobi.

My GA code for my standard website looks like this:

(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-12345678-1');
ga('create', 'UA-12345678-2', {'name': 'newTracker'});
ga('send', 'pageview');
ga('newTracker.send', 'pageview');

In the GA real time section I can see that the property UA-12345678-1 is getting real time results but the the second property isn't getting results at all.

Does anybody know the reason? Am I mistunderstanding the GA documenation.

To clarify: On my mobile website I would like to embed the following code:

(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-12345678-1');
ga('create', 'UA-12345678-3', {'name': 'newTracker'});
ga('send', 'pageview');
ga('newTracker.send', 'pageview');

So, I have three properties: UA-12345678-2 for the standard website, UA-12345678-3 for the mobile website and UA-12345678-1 as an aggregation of both giving me the opportunity to see the results of standard website and mobile website summed up. At least that is what I am trying to achieve.

Any ideas are welcome.

解决方案

What you have should work. I went and tested this myself, and sure enough, it didn't work. Next, I tried removing the spaces between the objects, as I've seen in the past that this has cause the code to not show up in GA. I'm not sure why, but by removing the spaces from all of the parameters and objects, I was able to get data to show up in real-time reports.

I tried adding the spaces back to the parameters and objects, but was unable to get the data to NOT show up again. Regardless of what I did, data kept coming through.

I would try this:

(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-12345678-1');
ga('create','UA-12345678-3',{'name':'newTracker'});
ga('send','pageview');
ga('newTracker.send','pageview');

这篇关于一个通用Google Analytics代码中有多个属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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