简体   繁体   English

Google Analytics(分析)自定义维度不起作用

[英]Google Analytics Custom dimension doesnt work

I'm having some troubles with the custom dimension that i set in my file's header. 我在文件标头中设置的自定义维度遇到了一些麻烦。 The analytics is linked to my site because i get on the analytics the real time count. 该分析功能已链接到我的网站,因为我可以实时获取分析数据。

That been said, as you can see in the code there is a JS variable iduser it contains the value of a div that has the current ID of the user connected. 话虽如此,如您在代码中看到的那样,有一个JS变量iduser,它包含一个div的值,该div的值已连接用户的当前ID。

I created the dimension based on Hit so i make some interactions in my page but i don't get the value of userid in my custom reports 我基于“ 点击”创建了维度,因此我在页面中进行了一些互动,但在自定义报告中没有获得userid的值

I was wondering if some of you can help and tell me where my set up is wrong ? 我想知道你们中的一些人是否可以提供帮助,并告诉我我的设置哪里有问题?

NOTE: The name of the dimension in my GA is : iduser 注意:我的GA中的维度名称为: iduser

Thank you so much in advance 提前谢谢你

  (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'); iduser = $('#userid').text(); ga('create', 'UA-xxxxxxxxxxx', 'auto'); ga('set','userid', iduser); ga('send', 'pageview'); 

The syntax is wrong . 语法错误 You want to specify the dimension/metric ID (0-20) and not its name (which makes sense since names can change, dimension/metric IDs never do): 您要指定维度/指标ID(0-20),而不要指定其名称(这是有意义的,因为名称可以更改,而维度/指标ID则永远不会这样做):

https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets#id=%22sending_data%22 https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets#id=%22sending_data%22

For instance for the 1st custom dimension: 例如第一个自定义维度:

ga('set', 'dimension1', 'something');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM