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
-
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 -
Best top 5 actionable insights from Google Analytics
Buongiorno from 14 degrees C cloudy wetherby UK 🙂 With a whole gamut of books out there are written around the topic of "Actionable Web analytics" where you have to wade through chapters of how to suck eggs and how to get analytics part of your business culture (whatever! most clients who look after their websites are entry level Marketing Execs who pay the digital agencies to do the thinking for them) I'd like to cut to the chase and list out say a top 5 of actionable insights a client would actually give the time of day for so heres my top five, whats yours? 1. Landing page bounce - showing them the £5k landing page designed with no conversion thinking is turning off customers
Reporting & Analytics | | Nightwing
2. Synching up PPC campaigns to analytics and showing them how much money they are waisting
3. Goal funnels - Showing them there 20 step shopping conversion funnel gets abandoned at step 3
4. Non brand keyword traffic (although a stack of this gets blocked by "not provided" Big groan...)
5. Event tracking on there 10 page carousel anner showing them no one clicks on banners 2 - 10 So under the strict label of "Actionable data only" from Google analytics whats your best insights you share with clients in the hope that they may actually give data reports the time of day! Grazie tanto,
David1 -
Google analytics - landing pages
Hello, I have a website and it contains landing pages. after tracking and analyzing the data in Google Analytics , I found out that the traffic for the whole site is affected by the visits to the landing page. I mean, the bounce rate is less than one minute. this is because users fill their details in the landing pages and leave my website. to improve my website, I need clear data about the traffic, bounce rate etc. in my website. I also need can you help me solve this problem I thought about create another account in Google Analytics and set it to my websites pages (not including the landing pages). and keep the current code for the landing pages. my question is regarding this: Is it legal to use 2 different GA code (each one of them belong to different account) in the same domain ? can you provide me with more information about Multi Account in Google Analytics, and how can I use it to divide the traffic in my website between the traffic and the data for the landing pages and for the website itself ?
Reporting & Analytics | | JonsonSwartz0 -
How to not track mobile redirects in Google Analytics
If a user is on a mobile device and comes to our home page, http://www.darden.virginia.edu/web/Home/ they are redirected to http://m.darden.virginia.edu/web/Home/. We want a way to remove all the redirects from our Google analytics reports. More specifically we do not want to include the the page view of http://www.darden.virginia.edu/web/Home/ in our page view count when the user is on a mobile device. How do we do that?
Reporting & Analytics | | Darden0 -
301 Tracking with Google Analytics hurts SEO?
Hey guys, I have an old-domain.com and a new-domain.com. old-domain.com has reputation and through a 301 redirect it's handling it over to new-domain.com. I want to know how many people still visit old-domain.com and track this with Google Analyitcs. I read the best solution for this would be a Google Campaign URL. My question: Does a URL like "http://www.new-domain.com /?utm_source=&utm_medium=redirect&utm_campaign=" hurt the effectiveness of the 301 redirect?
Reporting & Analytics | | optimiert-es0 -
Alternatives for google analytics multi account dashboard overview
Hi there, I like the new Google Analytics layout don't get me wrong but I really miss the old possibility to have a quick overview of all your accounts. Does anyone know an alternative for this? Please share your experiences and recommendations.
Reporting & Analytics | | Robbern0 -
SEOMoz crawls skewing Avg Visit Duration in Google Analytics
Hello, We are a UK based company. Our Google Analytics account is showing a rise in Avg Visit Duration for 'Direct traffic' since we started using SEOMoz. Are any other users experiencing this issue? We tracked it down to City Seattle, and when doing an Advanced filter by removing Seattle, the results are normal again. What does SEOMoz or other users recommend we do besides continuously using advanced filters? We have enquired about excluding Roger's IP address, but have been told that Roger uses the Amazon cloud, so the IP is not static. See attachment for screenshot of our Google Analytics account of Avg Visit Duration since we began with SEOMoz. Rich Talbot 718g3.gif
Reporting & Analytics | | STL1 -
How can I track search engine optimization data in Google analytics?
My website is linked to a Google Analytics web property. But, I am not able to track search engine optimization data in Google Analytics. So, How can I get it done?
Reporting & Analytics | | CommercePundit0