I am looking for a way to disable the cookies set by Google Analytics. I found some infos in Google's devguides: https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#disabling_cookies
Here it says that I should add the following code:
ga('create', 'UA-XXXXXXXXX-X', {
'storage': 'none'
});
But where exactly? I already tried to add it inside the tracking code:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXXX-X');
ga('create', 'UA-XXXXXXXXX-X', {
'storage': 'none'
});
</script>
I'm grateful for every clue.
Can Google Analytics work without cookies? Yes, using Google Consent Mode can make your website run Google Analytics based on the consent state of your end-users.
GA4 is promoted as privacy-centric and has been designed to work with or without cookies. By leveraging machine learning and statistical modeling, GA4 can fill in data gaps as the world becomes less and less dependent on cookies.
If you have to make a choice between Gtag and GTM, my recommendation would be to go with GTM. Once your developer has implemented the Google Tag Manager container everything can be done within the platform, you won't need to hardcode anything in the source.
Given you use gtag.js
(based on your example):
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('consent', 'default', {
'ad_storage': 'denied',
'analytics_storage': 'denied'
});
gtag('config', 'xxx');
https://developers.google.com/tag-platform/devguides/consent#set_consent_defaults
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With