Is it possible to track basic analytics data without asking consent? - google-analytics

hope someone can help with this problem we are having.
We are using google analytics on several websites with the only purpose to have a visits counter of each one.
We do it using Google Analytics Reporting API and this is the only reason: we don't use it for marketing purposes or to analyze audiences or behaviour. We want to understand if this is compliant with GDPR since we don't ask cookie permissions to users on each website or if is there a way to just use Analytics as counter without showing any consent message to users.
Let me know
Thanks

There is no universal rule for all UE member states, however many guarantors (such as the Italian one) have stated that by reducing the identifying power of an analytical cookie, this cookie can be considered a technical cookie.
A technical cookie does not require acceptance but can always be provided
In order to reduce the identifying power of the Analytics cookie, it is possible to use the IP Anonymization (or IP masking) setting in Google Analytics hit which removes the last octet from the IP that sends (automatically) with the call to the Google servers. In this way, the user cannot be geolocated and the GA cookie is considered to be of a technical nature.
With Universal Analytics you need to add a setting to the tracking code while with Google Analytics 4 IP anonymization is the default.
If you use gtag, the code is something like this:
<!-- IP anonymization with gtag.js - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'GA_TRACKING_ID', { 'anonymize_ip': true });
</script>

Related

Google Consent Mode works with UA but not GA4

I am having trouble tracking without cookies using GA4.
I have both a UA and a GA4 property that I am tracking simuntaniusly using gtag:
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag("consent", "default", {
ad_storage: "denied",
analytics_storage: "denied",
wait_for_update: 1000
});
gtag('set', 'url_passthrough', true);
gtag('js', new Date());
gtag('config', 'UA_TRACKING_CODE');
gtag('config', 'GA4_TRACKING_CODE');
Both UA and GA4 complies with consent set to "denied" and are not setting any cookies.
In UA i can see the pageviews coming in even though no cookies are beging set. But nothing is tracked in GA4 unless i set the "analytics_storage" set to "granted".
Does anyone know how to track in GA4 with "analytics_storage" set to "denied"?
With the Consent Mode it doesn't even track Universal Analytics if analytics_storage is denied (you can see that the data is sent to the Google Analytics servers but none of those hits will be shown in the reports).
This subject is very confusing and frustrating for me as well.
In short - I believe GA4 won't let you track ANY information without user consent (not even aggregated, anonymous information).
Here's some documentation, that I don't think was available when this question was asked:
https://support.google.com/analytics/answer/9976101?hl=en
Spesificaly:
analytics_storage='denied'
...
Cookieless pings will be sent to Google Analytics for future measurement. Google Analytics 4 will use cookieless pings for modeling.
I tested it, and that's indeed the behaviour I see when analytics_storage and ad_storage are 'denied':
No cookies are set
GA sends a ping for every pageview (i have set-up a server-GTM, so the ping goes there - and from there to Google)
The pageview-ping does not show in:
real-time report
normal reports (not even after 24h - some posts I've seen said it takes 24h. but it doesn't. It's never visible in reports)
Not even in DebugView (a GA4 feature)
Sadly, I couldn't find statistics about consent-preferences - how many people accepted/rejected each storage option
I think GA4 went too far here -
I just want to track aggregated, anonymous data, when users reject cookies. That's not PII at all. I just want to know stuff like "how many people have visited this page in my site". That shouldn't be banned.
But seems like it is, and I've yet to understand why or how to get around it.
I know GA4 sends a parameter called gcs (Google Consent Status) with the ping. presumably, in my sGTM, I can send my ping without this parameter, or set it to G111 (= 'permissions granted'), and maybe that would make the pageview count in reports, but so far I wasn't able to override this parameter - not in GTM, nor in sGTM (Server-Side GTM).
If anyone knows a solution to this situation - I'm more than happy to hear.

Google Analytics - measurement protocol events not linking to other events

Problem: I need to see where users who download the app from the website, came from. We have google analytics(GA) and this part works well and we can see our traffic sources. However, I need to link users who install the app with those web visitors, so I can see from which channel, I get my "good users". The ones who ultimately install the app and set it up.
Solution Implemented: I have turned on the userID functionality and have session unification turned on. I am generating userIDs from the internal apis and publishing them to google analytics, the standard way. It is a PHP website and on session init, I make a call to the apis to get a new visitor id
$site_visitor_id = key_exists(static::USER_ID, $_SESSION) ? $_SESSION[static::USER_ID] : '';
$response = API::logWebVisitor(static::SITE_ID, $site_visitor_id, static::getClientIP());
if (!is_null($response)
&& key_exists('data', $response)
&& key_exists('visitor_id', $response['data'])) {
$_SESSION[static::USER_ID] = $response['data']['visitor_id'];
} else {
$_SESSION[static::USER_ID] = '';
}
which is pushed to google analytics.
ga('create', 'UA-XXXXXX-Y', 'auto');
ga('require', 'XXXXXX');
ga('set', 'userId', '<?php echo $_SESSION[Session::USER_ID] ?>');
ga('send', 'pageview');
This works as I have all the users I would expect in the userID view in GA. One a user installs the app a user is created in our internal apis and the ip address is recorded. Every 10 minutes I try to link the generated userIDs ( which also have an ip address associated with it), with the users, based on the ip address. When I find a link, I push an install event to GA.
cid=<randstring>
&ea=Install
&ec=<category>
&el=InstallID
&ev=<install_id>
&t=event&
&tid=UA-XXXXXXX-Y
&uid=<mygenerated_user_id>
I can see the GA events perfectly fine and that works. One caveat though, is that the measurement protocol requires the cid, even though it says if the uid is passed this is not needed(fake news). So I just generate a random id to pass in and it works.
Issue: When I look in the reporting views of GA, GA is not linking these events to the web visitors that have the same user_id associated with it. Now, I can't see any of the user_ids to filter down and verify this as GA does not provide me with access to this information.
Expectations: I would expect that when I send an install event to GA with the user_id that GA sees that there are two client_ids with the same user_id and links those together, so I can see what channel lead me to getting that user. However, it's as if GA has no clue who that user_id is and never links them together. I am struggling to figure out what I need to look into to figure out why.
Any information around GA would be helpful as I don't know much about it and it's my first time using it.

How would I have GA track an event that happens on another site?

So I am working with a third party self-contained landing page for a client but I would like any conversions on this site to be tracked to the client's website's google analytics account (or GTM). So, for instance, when the form on the landing page gets submitted, it would fire an event on GA, or when the user downloads a pdf from the success page.
there was a link() function in ga.js, but there doesn't seem to be an equivalent in analytics.js
Just need an example of the code and where on the landing page should it go?
For GTM, use tracking form submission events
On the PDF download event, set up an event tag for when they download the PDF.
Note, if the third-party landing page is on a different domain, you will need to setup cross-domain tracking to ensure your traffic information is correct.
Google Analytics collects and aggregates data based on tracking ID (some like UA-123123-1). Data collection is realized over the HTTP request to https://www.google-analytics.com/collect endpoint with tracking ID as an URL parameter. There is no built-in limitations for analytics data to be sent from different domains. So you may send a proper request from any 3rd party page or server and this will be tracked within a client's google analytics account. You only need to know client's tracking ID.
Within your page you may just place a common analytics snippet
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_TRACKING_ID');
</script>
and replace the GA_TRACKING_ID with client value. Note that only location.path would be reported in the client's Google Analytics.So if your landing page doesn't have the path part it may be mistakingly reported as the main page / of the client's site. To prevent this you may use some arbitrary values to be used in the report and pass them as a parameters with gtag(...) call:
gtag('config', 'GA_TRACKING_ID', {
'page_title' : '3rd party landing page', // will be used in reports
'page_path': '/landingpage' // will be used in reports
});

Google event tracking (background events)

Ok so here is a scenario I would like to get some ideas on:
A user shows up to my site and registers for my service...lets call the service "vaporware".
After registration the user proceeds to view all the glorious features that my cloud based vaporware has to offer. Each feature that they use during their visit is recorded using Event Tracking in Google Analytics and I can effectively track engagement.
Now the problem:
One of the features in my Vapor product has tasks built in. These tasks are important for a number of reasons...they are recurring and do not require any action from the user to execute.
How would I using either "old" google analytics or the new Universal Analytics go about tying these "background events" visitors? I am thinking that the new Measurement Protocol may be have the answer as this perhaps can be considered cross platform tracking...
Regardless this keeps coming up a lot for me and am interested even finding a hack/work around to start recording these types of events in GA.
If they're logged in, you can substitute the autogenerated client ID with your own user/account ID (make sure to anonymize it before sending it to Google).
With the Measurement Protocol it's the cid parameter:
...v=1&tid=UA-XXXX-Y&cid=my-user-identifier&t=event...
In the Universal Analytics JS code, it would be something like this:
ga('create', 'UA-XXXX-Y', {
'clientId': 'my-user-identifier'
});
Hope this helps :)

Can you test google analytics on a localhost address?

I have to test out my new GA account on my local machine.
Will this work just by copying the standard snippet supplied by Google onto the page ?
I don't want to spend 24 hours waiting to see if it will or won't work.
This question remains valid today, however the technology has changed. The old Urchin tracker is deprecated and obsolete. The new asynchronous Google Analytics tracking code uses slightly different code to achieve the same results.
Google Analytics Classic - Asynchronous Syntax - ga.js
The current syntax for setting the tracking domain to none on google analytics looks like this:
_gaq.push(['_setDomainName', 'none']);
Google analytics will then fire off the _utm.gif tracker request on localhost. You can verify this by opening the developer tools in your favorite browser and watching the network requests during page load. If it is working you will see a request for _utm.gif in the network requests list.
Updated 2013 for Universal Analytics - analytics.js
Google released a new version of analytics called "Universal Analytics" (late 2012 or early 2013). As I write, this the program is still in BETA so the above code is still recommended for most users with existing installations of Google Analytics.
However, for new developments using the new analytics.js code, the Google Analytics, Advanced Configuration - Web Tracking Documentation shows that we can test Universal Analytics on localhost with this new code:
ga('create', 'UA-XXXX-Y', {
'cookieDomain': 'none'
});
Check out the linked documentation for more details on advanced configuration of Universal Analytics.
Update 2019
Both Global Site Tag - gtag.js and Universal Analytics - analytics.js will detect localhost automatically. You do not need to make any change to the configuration.
If gtag.js detects that you're running a server locally (e.g. localhost), it automatically sets the cookie_domain to 'none'.
- developers.google.com
Updated for 2014
This can now be achieved by simply setting the domain to none.
ga('create', 'UA-XXXX-Y', 'none');
See: https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#localhost
I had the same problem, and all the solutions didn't work until I did two things:
Obvious code:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXXX-X']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
AND
I added localhost another FQDN - domain name. I did this on Windows sistem by editing:
C:\Windows\System32\drivers\etc\hosts
file, and I put in the following:
127.0.0.1 my.domain.org
Then I went to address http://my.domain.org/WebApp that is serving page with included google analytics JS.
If you are on unix, edit /etc/hosts for same result.
It think that Google should put Intranet configuration in ther GA FAQ. They just say that you need FQDA. Yes, you do, but not for them to access you, you need it just to have Host attribute in HTTP request.
I think another reason for FQDN is COOKIES! Cookies are used to track data and if you don't have FQDN, cookie can not be set, and JS code stops and doesn't get the gif.
After spending about two hours trying to come up with a solution I realized that I had adblockers blocking the call to GA. Once I turned them off I was good to go.
Answer for 2019
The best practice is to setup two separate properties for your development/staging, and your production servers.
You do not want to pollute your Analytics data with test, and setting up filters is not pleasant if you are forced to do that.
That being said, Google Analytics now has real time tracking, and if you want to track Campaigns or Transactions, the lag is around 1 minute until the data is shown on the page, as long as you select the current day.
For example, you create Site and Site Test, and each one ha UA-XXXX-Y code.
In your application logic, where you serve the analytics JavaScript, check your environment and for production use your Site UA-XXXX-Y, and for staging/development use the Site Test one.
You can have this setup until you learn the ins and outs of GA, and then remove it, or keep it if you need to make constant changes (which you will test on development/staging first).
Source: personal experience, various articles.
Now the answer for your question is yes, it will just work by copying the standard snippet. According to documentation, now the standard snippet has automatic cookie domain configuration: ga('create', 'UA-XXXXX-Y', 'auto'); where cookie domain is automatically determined.
In addition, if analytics.js detects that you're running a server
locally (e.g. localhost) it automatically sets the cookieDomain to
'none'.
It will work if you use an IP or set domain to none.
Details here:
http://analyticsimpact.com/2011/01/20/google-analytics-on-intranets-and-development-servers-fqdn/
An easier tool to monitor the tracking tags is to use the Chrome extension (probably available, or the equivalent for other browsers) - Google Tag Assistant. This will show what tags are firing, what problems it has found, and even breaks out stuff like eCommerce values for easy reading. Also works with the Google Tag Manager, and can handle multiple sets of tags on the page.
I just want to add to what's been said so far, it may save a lot of headache, you don't need to wait 24 hour to see if it works, yes the total overview take 24 hour, but in Reporting tab, there is a link on left side to Real-Time result and it will show if anyone currently visiting your site, also I didn't have to set 'cookieDomain': 'none' for it to work on localhost, my setting is on 'auto' and it works just fine (I'm using MVC 5), on top of that I've added the script at the end of head tag as google stated in this page:
Paste your snippet (unaltered, in its entirety) into every web page you want to track. Paste it immediately before the closing </head> tag.
here is more info on how to check to see if analytics works properly.
Following on from Tuong Lu Kim's answer:
Assuming:
ga('create', 'UA-XXXXX-Y', 'auto');
...if analytics.js detects that you're running a server locally (e.g. localhost) it automatically sets the cookieDomain to 'none'....
Excerpt from:
Automatic cookie domain configuration sets the _ga cookie on the highest level domain it can. For example, if your website address is blog.example.co.uk, analytics.js will set the cookie domain to .example.co.uk. In addition, if analytics.js detects that you're running a server locally (e.g. localhost) it automatically sets the cookieDomain to 'none'.
The recommended JavaScript tracking snippet sets the string 'auto' for the cookieDomain field:
Source: https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#automatic_cookie_domain_configuration
I came across this problem recently, and I found it helpful to explore the new documentation by Google on debugging Analytics. It didn't actually care about sending tracking info to Google Analytics, I just wanted to ensure that the events were firing correctly, and the debugging tools gave me the info I needed. YMMV, I realize doesn't exactly answer the question.
For those using google tag manager to integrate with google analytics events you can do what the guys mentioned about to set the cookies flag to none from GTM it self
open GTM > variables > google analytics variables > and set the cookies tag to none

Resources