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
-
Important updates on Google Analytics Data Retention and the General Data Protection Regulation (GDPR)
Hi Everyone, I'm sure many of you received the email from Google over the past few days with the subject line: [Action Required] Important updates on Google Analytics Data Retention and the General Data Protection Regulation (GDPR). I hope I'm not alone in not knowing what exactly this whole notification was in regards to. I realize it's for Data but are we no longer able to pull stats from the past? If anyone has a "dumbed down" explanation for what this update entails, I would be very interested - I don't want to miss out on any important updates and info, but I'm just not grasping this content. Below is the full email in its entirety for those who are interested as well: Dear Google Analytics Administrator,
Reporting & Analytics | | MainstreamMktg
Over the past year we've shared how we are preparing to meet the requirements of the GDPR, the new data protection law coming into force on May 25, 2018. Today we are sharing more about important product changes that may impact your Google Analytics data, and other updates in preparation for the GDPR. This e-mail requires your attention and action even if your users are not based in the European Economic Area (EEA).
Product Updates
Today we introduced granular data retention controls that allow you to manage how long your user and event data is held on our servers. Starting May 25, 2018, user and event data will be retained according to these settings; Google Analytics will automatically delete user and event data that is older than the retention period you select. Note that these settings will not affect reports based on aggregated data.
Action: Please review these data retention settings and modify as needed.
Before May 25, we will also introduce a new user deletion tool that allows you to manage the deletion of all data associated with an individual user (e.g. site visitor) from your Google Analytics and/or Analytics 360 properties. This new automated tool will work based on any of the common identifiers sent to Analytics Client ID (i.e. standard Google Analytics first party cookie), User ID (if enabled), or App Instance ID (if using Google Analytics for Firebase). Details will be available on our Developers site shortly.
As always, we remain committed to providing ways to safeguard your data. Google Analytics and Analytics 360 will continue to offer a number of other features and policies around data collection, use, and retention to assist you in safeguarding your data. For example, features for customizable cookie settings, privacy controls, data sharing settings, data deletion on account termination, and IP anonymization may prove useful as you evaluate the impact of the GDPR for your company’s unique situation and Analytics implementation.
Contract And User Consent Related Updates
Contract changes
Google has been rolling out updates to our contractual terms for many products since last August, reflecting Google’s status as either data processor or data controller under the new law (see full classification of our Ads products). The new GDPR terms will supplement your current contract with Google and will come into force on May 25, 2018.
In both Google Analytics and Analytics 360, Google operates as a processor of personal data that is handled in the service.
• For Google Analytics clients based outside the EEA and all Analytics 360 customers, updated data processing terms are available for your review/acceptance in your accounts (Admin ➝ Account Settings).
• For Google Analytics clients based in the EEA, updated data processing terms have already been included in your terms.
• If you don’t contract with Google for your use of our measurement products, you should seek advice from the parties with whom you contract.
Updated EU User Consent Policy
Per our advertising features policy, both Google Analytics and Analytics 360 customers using advertising features must comply with Google’s EU User Consent Policy. Google's EU User Consent Policy is being updated to reflect new legal requirements of the GDPR. It sets out your responsibilities for making disclosures to, and obtaining consent from, end users of your sites and apps in the EEA.
Action: Even if you are not based in the EEA, please consider together with your legal department or advisors, whether your business will be in scope of the GDPR when using Google Analytics and Analytics 360 and review/accept the updated data processing terms as well as define your path for compliance with the EU User Consent Policy.
Find Out More
You can refer to privacy.google.com/businesses to learn more about Google’s data privacy policies and approach, as well as view our data processing terms.
We will continue to share further information on our plans in the coming weeks and will update relevant developer and help center documentation where necessary.
Thanks,
The Google Analytics Team6 -
Pandora in Google Analytics
Hi Mozers, in Google Analytics our ads are registering a 10 second page duration and a 90% bounce rate, which is pretty atrocious. My questions are: Organic page duration is 3:15 minutes, and Social + Referral are similar. Yet Pandora is bringing the average time on site way down, to less than a minute. Will those paid ad metrics be factored to the User Behavior and therefore negative affect our overall rankings? In other words does Google now see our page duration as less than a minute? The Pandora rep says that Google Analytics and Pandora have "systemic issues" such that GA is very inaccurate with Pandora metrics. I find that difficult to believe. Any insights here? Thanks all! Jane
Reporting & Analytics | | CalamityJane770 -
How can I overwrite previously imported cost data in Google Analytics?
I choose the overwrite option but it keeps adding the costs to the existing costs. When i select that radio button and click done, that option does not appear on the summary screen. That section next to Import Behavior is blank.
Reporting & Analytics | | JGB5550 -
Does referral exclusions remove the ecommerce value from Google Analytics?
Quick question on Referral exclusions. We have a client that just rebuilt their Magento website, referral data from Paypal was never an issue, the site properly attributed to source. New web devs finished the site and all purchases through Google Analytics from PayPal Is now showing as referral traffic. Doing research on the issue the suggestion was to create a referral exclusion in GA from PayPal. My question on that, will the ecommerce value default to the previous referral or will it delete the e-commerce value completely from what is gathered?
Reporting & Analytics | | BCutrer0 -
Dip in traffic from Pune for our sites in Google Analytics
Hi, We have noticed dip in traffic from Pune after 6th May'14 in our Google Analytics account for few of our sites. Did anyone noticed the same for your site. Kindly let me know if you have any idea. Thank and Regards
Reporting & Analytics | | vivekrathore0 -
Strange Traffic Spike In Google Analytics
Over the last two days I have seen a huge spike in the pageviews to my site www.learnbonds.com. Up to this point my average page views per visit has been less than 2. For the last couple of days it has jumped to 5 but the average time on the site has not increased. Upon further investigation under the browser and OS page of google analytics I found that traffic coming from internet explorer and IE with Chrome Frame is reporting 10+ pageviews per visit. Below is a screenshot. Any insight into what might be causing this and how to fix it that the community can provide would be appreciated. Thanks
Reporting & Analytics | | davidwaring
DaveZUaQWJd.png?1?21800 -
Google Analytics Showing Inflated Product Revenue
Hi- For the month of Feb on two of our sites we are seeing inflated product revenues. I have not seen this before and I am not having any luck searching for answers. Here is the issue: Product B sells for $159.95 For the month of Feb we sold 3 thus revenue should be ~$479.85 GA is showing Product B's revenue at $3,360.00 I read online that sometimes folks will bookmark the receipt page and that can cause this and we would need to put a catch in place for this but I am guessing this is not the case as it is happening on two sites. Please let me know if you have any questions.
Reporting & Analytics | | K2_Sports0 -
Why is Webmaster Tools not Linking Correctly Google Analytics?
I have a global site with .com as the US site and then /country for all other markets i.e. .com/uk .com/de etc. Each site has it's own WMT profile. Each site has it's own GA profile. Since Google added Search Engine Optimization to the GA interface, I can't track these sites separately under this new feature. It seems to me that it can only be associated with a single WMT profile at a time or rather that WMT can only be associated with a single GA profile at a time. The numbers for the UK and US site are identical, but when I try and link the UK WMT account with GA it removes it from the US profile and vice versa.
Reporting & Analytics | | Red_Mud_Rookie0