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
-
Organic vs SEO in Analytics
In my analytics account, the Acquisition / All Traffic / Google organic searches shows me around 19,000 hits from 1st Jan to 1st Feb. But if I go to the Search Engine Optimization tab / Queries or Landing pages I can only count 1,800 clicks from 1st Jan to 1st Feb. Why such a huge discrepancy ? Am I getting 1800 clicks from the Google organic search, or 19,000 ?
Reporting & Analytics | | coadr930 -
Google Analytics Average Position
I'm looking at Google Analytics -> Acquisition -> Search Engine Optimization -> Queries reports. I'm looking at keywords and the average position. What Google reports and what I see in a Google incognito search is different (usually my search is much lower). For example, for one search term, Google reports 5.8 average position and every time I search it is 8. My local result is 4. Anyone know why this is? I'm wondering if Google is averaging the Local results into number?
Reporting & Analytics | | CalicoKitty20000 -
Some questions on how to set up a multi-visit advanced segment in Google Analytics
Hi I would like some assistance / clarification on how to set up a user segment so that it can track user behavior over multiple visits. Basically I have a campaign set up and want to see conversions - even if they hit the site and then convert later on another visit. I've read that you can do this (over up to 30 days). So I start off by filtering TRAFFIC SOURCE - easy enough. But then I have to add under "advanced" correct? But then when I set the next filter to the GOAL I want, I only get "by session" and "by hit" as options. The blog post I read made it sound like only "by user" would then really do multi visits. Is "by user" only an e-commerce tracking option? (which I don't have set up) Is there another way/path to get the info I need? Thank you!
Reporting & Analytics | | yandl0 -
Setting up goals - google analytics
Hi Im new user google analytics I would like to set up goal for website. I asked to basic questions: What are my bussiness objectives? Answer:make the visitor to click on a advertisment (affiliate links and affiliate banners) to be redirected to company website to finish purchase. How to set up goals? How can I track ads (affiliate banners and affiliate links) on my website?
Reporting & Analytics | | info_tipovanie-stavkovanie.com0 -
What's the final word on Image Search tracking in Google Analytics?
Sorry if this has been answered but I can't seem to get a straight answer to my questions by searching around. How is traffic referred by Google Images counted in Google Analytics? I know it used to be referral traffic from google.com/imgres. A lot of things I have read say that it should all be under google/organic now, but my site still gets referral traffic from google.com/imgres, so that can't be. However I also get traffic as google/organic that I am pretty sure is from image search, because we don't rank for the keyword normally, but we do for image search. What's the deal? How is traffic from an embedded image in a regular result page counted? How can I segment my image search traffic better? It would be great to see image search traffic as it's own medium. I found a script here -- http://jrom.net/google-images-in-google-analytics -- that looks promising, has anyone used it or can recommend another way? I haven't used the GA API very much so I want to make sure the script is kosher and won't screw up my numbers.
Reporting & Analytics | | tact0 -
Google Analytics: Deleted Profile
Has anyone ever successfully managed to have a deleted GA profile restored? One of our client's profiles was deleted accidentally. I know the official line is it can't be restored, but...
Reporting & Analytics | | David_ODonnell0 -
How to Track Google Local Places in Google Analytics?
I have read many articles on how to track google local places through google analytics. Each article I have read show a different way of setting up google analytics and using tags in google local places. Wondering if anyone as up to date information on this and what would be the best practice to track data from google local lisitngs in google analytics Thanks Arthur
Reporting & Analytics | | VivaArturo0 -
Transferring Google analytics accounts
Hi, Does anyone know if you can transfer an Google Analytics account. We are looking to take over a new clients existing website and the analytics account is registered to their current web designers. Is it possible to transfer it to the client so that their existing web company no longer has access and they keep all their historical data, or do we have to start from scratch. Thanks Fraser
Reporting & Analytics | | fraserhannah0