问题
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
回答1:
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.

来源:https://stackoverflow.com/questions/23274021/how-to-see-google-analytics-dimension-variables-on-dashboard