Switching Google Analytics IDs based on authentication state? - google-analytics

Per this law.stackexchange question it's possible to use google analytics without getting consent and still comply with the GDPR.
I was thinking about creating two GA properties for a single domain name. One that switches off all the features that the GDPR requires for non consent and another that tracks users that have consented and have an account setup where they can make opt out changes, manage cookies etc.
Is it possible to track the same GA property / browser client using two different GA ids that correspond to the different configuration settings?
In other words when the user is logged in, the user gets tracked by the consented GA id, but when the user is not logged in and anonymous the user gets tracked by the GDRP compliant non consent GA id?

Yes. You just need to determine the technical identifier of a logged-in user (probably a cookie or js variable), then use that identifier to pivot tracking logic. If you have analytics.js or gtag.js hardcoded on your site, then you'll want to change your main embed code to have conditional values for the tracking id and anonymizeIp.
If you're using GTM you can use lookup tables with the logged-in identifier as the input. Use these lookup tables as the value for GA Tracking IDs or other tracker fields. If you're not using the GA Settings variable (which you should!), just make sure you set these config value in every GA tag.
Alternatively, if your primary GA Property can be otherwise compliant, it might be an option to track both consenting and non-consenting users in a single property, and pivot only the anonymize ip setting (analytics.js/gtag/gtm), not the GA tracking ID. It's possible to pivot advertising features tracking-side too.

Related

Google analytics track user behavior. Or possible?

I am searching for a way to track user behavior on my website. I want to know if it is possible to get a table with data looking something like this:
+------+---------------+-----------------+------+---------+
| time | ip or user_id | user_session_id | link | actions |
+------+---------------+-----------------+------+---------+
(Link - where user came from)
I want to track different user actions by sessions. Is this possible using Google Analytics or I should search other tools? My site is currently set up to track events but on my Analytics account I get only the number of events that occurred. I want to track what a specific user does on my site.
tl;dr: if you must do this use Mixpanel or similar software.
Time based dimensions are already available (date, hour, minutes and datetime). "link" would be referrer. Actions in Google Analytics are basically pageviews, events and transactions, so you have that, too.
IP and user id are a big no-gos. Storing anything that that identifies a person is a violation of Googles Terms of Service and depending on your location might be a violation of national laws.And if by user_id you mean the Google Analytics feature of the same name, Google says you may set it for logged in users and have to unset it for user that log out, so by extension that means storing it in Ga would probably be a violation of their TOS.
The GA session id is not exposed via the interface. You may read it from the cookie and store it in a custom dimension (I'm not sure if this is allowed within the TOS, on the other hand GA premium customers get this via a BigQuery export in any case, so it should be allowed).
If you simply want to tell different users apart you might simply generate a string in the UUID format and store that in a custom dimension. If you want to actually identify users (by name, adress etc), well, you are not allowed to and Google will terminate your account if they find out.
Not to mention that it completely eludes why so many people want to track individual users. You must not use GA information to target individuals, and simply looking at individual user paths will not help you (I wrote an article about that, although I do not expect that this will convince you).
Google Analytics is for technical and legal reasons not a good tool for tracking individual users, if you need to do this use a software that is made for this purpose. Mixpanel is often mentioned in that context but I'm sure there are many other solutions.

How to find adwords GCLID id in google analytics and link it to conversions manually?

I'm using a 3rd party tracking software (tracking202) to track conversions (as I can use the google conversion tag directly on my site, for some reason). Now, I've complete tracking data including keywords, placement and IPs of the converted users. Now, since Auto Tagging is enabled in my adwords account, google used glid id on my URLs since the beginning. I want to upload conversion data to adwords through the offline conversions import feature. And for that, I've 2 queries:
Where do I find the gclid ID in google analytics?
How do I link the converted IPs with GCLIDs ? (Since I have the converted IPs list in tracking202, if there's a way to filter IPs in google analytics and set the GCLID as the secondary dimension.. I would be able to collect the converted GCLIDs. But I'm not sure if its posisble in google anlaytics.
Please suggest what I can do in this case. Thanks a lot.
Google Analytics does not make the glcid accessible via the interface. If you want to get at the gclid you would have to store them yourself in a session scoped custom dimension (obviously this will not work for data already collected).
You need to create the custom dimension in the property settings (under "Custom Definitions") and then add a bit to your tracking code (poorly written PHP code for demonstration purposes only):
ga('create', 'UA-XXXX-Y', 'auto');
<?php if(isset($_GET['gclid'])) { ?>
// Set value for custom dimension at index 1.
ga('set', 'dimension1', $_GET['gclid']);
<?php } ?>
// Send the custom dimension value with a pageview hit.
ga('send', 'pageview');
i.e. "if there is a query string variable called glcid assign it's value to the custom dimension with the numeric index 1".
Technically the same works for the client IP address (which is likewise not displayed in the GA interface or exposed via the API). However you must not (as stipulated by the Google TOS) store information that allow to identify a user in Analytics (it might depend on your legislature if IP addresses are personally identifiable information. I don't know Googles stance on this, but it would be illegal in the Europe, at least without explicit consent of the user).
You may however store an anonymous identifier that allows to pull information from GA and connect it to information stored in other systems, so if you store e.g. the strongly hashed IP both in GA and in your other tracking system then you can use this as a key field to merge the records outside of GA.

Google Analytics user_id appended to links

Google Analytics now has UserID tracking to better track individual users across devices. Is it possible to add a tracking variable (like utm_campaign) specifying user_ID so that GA will associate those links with the user?
I'm looking for a solution that'll work even when the user isn't logged in (mainly for email link tracking).
No. Of course you can append the user id yourself and set it in your tracking code. But that would not uniquely identify a user (links get bookmarked or passed around e.g. when the email is forwareded to somebody) and someone else might end up with that id. The idea of the user id is that the CMS or CRM takes responsibilty for uniquely identifying users so we don't have to rely on the somewhat fragile client side mechanisms.
If you use it for email tracking it should IMO be enough if the user id is set in the first call of the tracking code if you have session unification enabled, so you'd just need to tag the link in the mail and read the id from there, without needing to persists the user id via the links. While I haven't tested this extensively the documentation seems clear on the point:
Session unification is a User ID setting that allows hits collected
before the User ID is assigned to be associated with the ID, so long
as those hits happen within the same session in which a specific ID
value is assigned for the first time.
Please note that the user id feature does not expose data for individual users via the interface, insofar the idea that it "better track[s] individual users" is not quite right (it will recognize users across devices but will still aggregate the data). If you want individual user you need to store the user id (or some other unique id) as custom dimension.

Query Google Analytics by User ID

Is there a way to query results using the Core Reporting API (v3) and filtering those results by the User ID assuming that it is being sent to Google Analytics properly?
I've googled this question a lot and read a whole bunch of articles but I did not find one place that does that. Moreover, the fact that I cannot see the User ID anywhere in the reporting interface makes me doubt that this is even possible. I'm guessing I will have to dome something similar to what is recommended here in order to do it?
UPDATE
Apparently, the purpose of my question is not very clear as highlighted by Eike's comment below. What I want to do is generate a report for a specific user with a specific Id using the client API and then combine those results with information I have about this user in my system's database to do something as per my business requirements.
The best place to turn to for such questions is the Dimensions and Metrics Reference. If the dimension you're looking for is not there then you cannot query it or use it in a filter.
The list is really well maintained, so it's not very likely there are as-of-yet undocumented dimensions you could use.
User id is not there.
Well there is a way now.
The docs says the following steps
Set up User-ID in your account
Agree to the User-ID Policy
Read the User-ID Policy. Under I agree to the User-ID Policy, set the switch to ON. Agreeing to the policy enables the feature in your account.
Click Next Step.
2. Set up User-ID in your tracking code
After you enable User-ID by agreeing to the policy, you must implement User-ID in your tracking code.
To employ User-ID, you must be able to generate your own unique IDs, assign IDs to new users and consistently reassign the same IDs to returning users, and include these IDs in the data you send to Analytics.
In this step, you can see the line of code that you have to add to your Analytics tracking code:
ga('set', 'userId', {{USER_ID}}); // Set the user ID using signed-in
user_id.
3. Create a User-ID reporting view
User-ID data can appear only in a dedicated User-ID view.
Click Create.
Enter a Reporting View Name.
You might want to include the term "User ID" in the name to help you remember that this is a special User-ID view.
Select a Reporting Time Zone.
Under Show User-ID Reports, set the switch to ON.
Click Create.
Related resources
https://support.google.com/analytics/answer/3123666?hl=en

Is it possible to use Google Analytics to track single user account?

I've got a website that needs user logged in before they can use, I want to track the behavior of each single user. Is it possible to do this? Any advice? Thanks very much!
Yes this is possible.
The simplest way might be to define a Custom Variable scoped to the visitor, and bind it to the value equal to the (obfuscated) user's ID (the one you assigned them when they registered):
pageTracker._setCustomVar(1, "Registered TempID", "345X34RT", 1)
The four arguments that you pass into a Custom Variable are: slot number (any integer 1 through 5, which won't change in this case; 'TempID' which is a variable name i chose for this variable; 'TempID', the value for that variable that maps to (but must not not personally identify or it will violate Google's Privacy Policy) a registered user; the final argument '1' is the scope, which i is '1' in this case because this variable is scoped to the visitor).
This new variable is sent to the GA server via a call to _trackPageview() so make sure you the custom variable is set before trackPageview() is called.
There are a several excellent resources, including step-by-step tutorials on GA Custom Variables, including a blog post by ROI Analytics, which is think is one of the best.
Once you've done to view this Custom Variable in the Google Analytics Web Client, go to the left-hand panel and click on the Visitor heading; the last item under this heading (and just before the next major heading which is Traffic Sources) you will see the Custom Variables subheading.
This is where you can view the data for the custom variables you set. For instance, the panel will look something like this:
It is technically possible, but prohibited by the terms of service that you agreed to when you installed Google Analytics (you read, them, right?).
From: http://www.google.com/analytics/tos.html
7. PRIVACY . You will not (and will not allow any third party to) use the Service to track or collect personally identifiable information of Internet users, nor will You (or will You allow any third party to) associate any data gathered from Your website(s) (or such third parties' website(s)) with any personally identifying information from any source as part of Your use (or such third parties' use) of the Service. You will have and abide by an appropriate privacy policy and will comply with all applicable laws relating to the collection of information from visitors to Your websites. You must post a privacy policy and that policy must provide notice of your use of a cookie that collects anonymous traffic data.
Seems pretty clear.
It's possible via User-ID javascript : User-ID j enables the analysis of groups of sessions, across devices, using a unique and persistent ID
ga('create', 'UA-XXXX-Y', 'auto');
ga('set', '&uid', {{ USER_ID }});
ga('send', 'pageview');
{{ USER_ID }} is a unique, persistent, and non-personally identifiable string ID that represents a user or signed-in account across devices.
https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id
The cookies that google analytics use, will track the same user, so long as they use the same PC and dont clear their cookies. Thats how GA can tell if a customer is a new user or a returning user. However, it is limited for the reasons I gave above.

Resources