问题描述
我正在经历一个奇怪的问题;可能是我做错了什么。我需要查看在我的网站上登录的所有用户名(及其分析)的列表。我创建了一个dimension1变量,并在Google Analytics上以Session类型列出了User Name。
以下是我在代码中所做的:
PS 这段代码在 analyticstracking.php 中,位于页面末尾(之后body标签)
var user =<?php echo $ _SESSION ['username'];?> ;
if(user){
// alert(user);
(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-1','thesite.com');
var dimensionValue = user;
// ga('set','dimension1',dimensionValue);
ga('set',{
'dimension1':dimensionValue,
'metric1':1
});
ga('send','pageview');
}
这就是我在Google Analytics中所做的:
但没有任何事情发生。
任何想法如果我做错了什么?
谢谢
是的,要创建一个自定义报表:
- 登录GA并转到顶部的< Customization ,然后点击 +新建自定义报告。
- 选择您想要查看自定义报告的指标,例如会话,浏览量等。
- 选择您想要查看的维度。在您的情况下,这将是用户名。
- 点击保存。
您现在应该可以看到您的数据。
我再次强烈建议您使用User Id而不是User Name。 p>
I am going through a strange problem; may be I am doing something wrong.
I need to see list of all Usernames (and their analytics) which logged in on my site. I created a dimension1 variable and listed as "User Name" with a "Session" type on Google Analytics.
Here is what I did in my code:-
P.S. This code is in analyticstracking.php which is at the end of the page (after the "body" tag)
var user = "<?php echo $_SESSION['username']; ?>"; if (user) { //alert(user); (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-1', 'thesite.com'); var dimensionValue = user; //ga('set', 'dimension1', dimensionValue); ga('set', { 'dimension1': dimensionValue, 'metric1': 1 }); ga('send', 'pageview'); }
This is what I did in Google Analytics:-
Now I am hoping that after doing all this, I'd see the list of all recorded Usernames and when I click on them, It'd show me all the respective analytics.
But nothing is happening.
Any idea if I am doing something wrong?
Thanks
Yep, to create a custom report:
- log into GA and go to "Customization" at the top, and then click "+ New Custom Report".
- Select the metrics you want to see for the custom report e.g. sessions, pageviews, etc.
- Select the dimension you want to see. In your case, that will be User Name.
- Click save.
You should now see your data.
Again, I would strongly urge you to use User Id rather than User Name.
这篇关于如何在Dashboard上查看Google Analytics维度变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!