How do I setup a logged-in vs. non logged-in custom variable in Google Analytics?
-
I found an example of the snippet to use:
__gaq.push(['.setCustomVar,
1, // first slot
'user-type', // custom variable name
'visitor', // custom variable value
2 // custom variable scope - session-level
]);Once the visitor logs into your website, we change this code, accordingly:
__gaq.push(['.setCustomVar,
1, // first slot
'user-type', // custom variable name
'regular-user', // custom variable value
2 // custom variable scope - session-level
]);How does the code know to change from 'visitor' to 'regular user' once a user logs in?
Is the snippet only placed on the login page?
-
AtoQ1: Most likely the only way to set/keep that variable would be session variables or cookies.
AtoQ2&3: It would be better if developer handles this part of setting/reading/sending variables. The way to ask is just ask. Show developer this post and the documentation from google on this subject.
-
I was using Universal Google Analytics, but looking at an old example, so thanks for the heads up on that.
What would this global variable look like?
Would this be something I could detect using developer tools?
How would I ask my developer for this piece of information?
-
Hello, my friend. first of all, it seems that you are looking/using old version of google analytics. so, I recommend using new Universal Google Analytics. Here is the documentation on custom variables (and that's what you're talking about) - https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets?hl=en
Now, what you're talking about is custom variables, which you can send to your Google Analytics to track specific events. It means that you have to push (_gaq.push) custom values to custom variables whenever you decide it's supposed to happen. So, code doesn't know how to change it, you have to tell it. For example, change some kinda global variable in php or js or whatever you're using when user logs in, and then using conditional statement push correct custom variable.
Hope this make sense.
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Google Analytics not Working on all pages despite many attempts
Hey gang, So this problem has been going on for months. None of our landing pages track, but all of our blog pages do. I've tried GA plugins, (we are on wordpress) and just now even put the code in the theme header script. Still to no avail. I just checked right now, and the blog pages have the global GA code, but now I noticed not even the home page has the code! Could it be something to do with my theme? I tried to pay a guy on upwork to fix but he couldn't fix it either. Thank you for you help!
Reporting & Analytics | | Meier0 -
Whats (Other) traffic in Google Analytics?
When I look through all our clients, a few are receiving the majority of their traffic from (other). [ Acquisition > Channels > (Other) ]. The only option in (other) is "website" or "offline", whatever that may be. And even weirder, the avg session duration is 0:00. Any idea what this may be?
Reporting & Analytics | | W2GITeam0 -
How does Google Maps/G+ traffic show up in Analytics?
Hi Moz Community, I've been trying to figure out how traffic from Google Maps (and G+) shows up in Google Analytics and am struggling to find a good answer online. If someone finds a business through Google Maps and then clicks on the website in the Maps listing, does that show up as a referral from Google Maps? Our site shows virtually zero traffic from Google Maps even though we have a number of listing. Two related questions: if someone clicks through to a G+ page from a Maps result and then visits our website from the G+ page, does that show up in Analytics as a referral from G+? Is traffic from Google Maps or G+ ALSO counted as organic traffic? (Would it be possible to accidentally double-count a visit as both organic and a referral from Maps/G+? Thanks everybody!
Reporting & Analytics | | JohnGroves0 -
Can you track two Google Analytics Accounts on one site?
If you have a site that had an old analytics account and then implemented a new one is it possible to run tracking code that records to both accounts without causing your site or data issues? We are doing this so we don't loose data at any point - ideally it wouldn't have been split between the two but making one redundant isn't an option. Ideally we would have merged the data from both accounts and had one - however the research we have done points to this not being a possibility - unless one of you guys knows different? It would be great if anyone has experience on any this.. Thanks
Reporting & Analytics | | ChrisAllbones0 -
Where do I find Google Analytics link tracking for outbound links?
We implemented this script in source, where would I find the outbound link tracking; in Events?
Reporting & Analytics | | KnutDSvendsen0 -
AW Stats vs Google Analytics
Hey Moz Community, I am looking to get opinions on the best practice for analytics/traffic analysis. From experience I know that AW Stats reads high and Google Analytics reads low for traffic for reason in this article http://www.smartz.com/blog/2009/01/23/analytic-confusion-%E2%80%93-awstats-vs-google-analytics/ It drives me a little nuts how far off both are for some pages. I have one article that shows 100 views (GA) and AW stats shows 5 times that number of views. Any suggestions or systems you recommend? Thanks
Reporting & Analytics | | johnshearer0 -
Disclaimer about using Google Analytic?
When using GA on my Website do I need to have a disclaimer that 'We are using Google Analtyic to Track information'?
Reporting & Analytics | | daracreative0 -
Seeing / and no / in Google Analytics
When I look at my Google Analytics code, I see that the same content will show up twice, once with a / at the end of the URL, and once without. My site is at http://www.skypeenglishclasses.com. Does anyone know why this would happen? Is it duplicate content?
Reporting & Analytics | | Paulguy0