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
-
Does Google need Analytics installed to create metrics?
Hi Mozers, Does Google know time on site, number of page visits, bounce rate, etc. even if Google Analytics is NOT installed? Does it measure all that stuff anyway, and if you install the GA code on your site, that is so that YOU can see those metrics? OR can Google only see those metrics if you install GA on your site? Thanks! Jane
Reporting & Analytics | | CalamityJane771 -
How to configure multilingual site in google analytic? Currently showing in Referral Traffic why?
Hello All, Currently my Multilingual site is showing in referral traffic is it because I have not added hreflang tag on site? If yes and if I add the hreflang tag on all sites when where it will show in google analytic traffic from international sites? And what type of configuration required in analytic? Thanks!
Reporting & Analytics | | pragnesh96390 -
Which one should I use...Google Analytics or AFS Analytics
Hi There, I am about to implement analytics for a customer site and I am wondering if I should use Google Analytics or https://www.afsanalytics.com ? I am leaning towards Google since it's pretty mainstream but I would love some feedback on the AFS ! Thanks everyone! Gary
Reporting & Analytics | | gdavey0 -
Can you arrange Google Analytics source/medium traffic by percentage change?
I'm doing a year to year traffic audit for a client. I would like to analyze Google Analytics source/medium traffic by percent change. Is there a way to do this? Do I have to create a custom variable? 9BH70RO
Reporting & Analytics | | VanguardCommunications0 -
Is it possible to use Google Tag Manager to pass a user’s text input into a form field to Google analytics?
Hey Everyone, I finally figured out how to use auto event tracking with Google Tag Manager, but didn't get the data I wanted. I want to see what users are typing into the search field on my site (the URL structure of my site isn't set up properly to use GA's built-in site search tracking). So, I set up the form submit event tracking in Google Tag Manager and used the following as my event tracking parameters: Category: Search Action: Search Value When I test and look in Google Analytics I just see: "search" and "search value." I wanted to see the text that I searched on my site. Not just the Action and Category of the event.... Is what I'm trying to do even possible? Do I need to set up a different event tracking parameter? Thanks everyone!
Reporting & Analytics | | DaveGuyMan0 -
Moving data between Google Analytics Properties
Last summer we setup another Google Analytics property for us with Universal Analytics and have been running this alongside the old Google Analtyics property. is there a way of exporting all the old data from the old property into the new Universal Analytics property?
Reporting & Analytics | | ese0 -
Google Analytics & AdWords Conversion Tracking
I have Google Analytics implemented on my site and have goals/funnels set up to track the conversion process. I have just started an AdWords campaign but can't see/track conversions from it. Do I need to implement both Google Analytics AND AdWords scripits on the page?
Reporting & Analytics | | mj7750 -
Does Google Analytics parse visits from search apps?
Does anyone know if Google Analytics reports visits to your website differently from individual search apps like Google and Bing? Or do they just treat them the same as any other keyword visit from Google or Bing search engine? I suppose the end result is probably the same as in the Google app you're using Google so it would just be a different access point versus a new tool. I'm just curious if there is a way to see how many Mobile visits are coming from the apps vs the browser. For me personally I have the Google and Bing iOS apps installed but rarely use them, opting for the Safari search bar 99% of the time.
Reporting & Analytics | | nsauser0