Can Google Analytics be configured to disable cookie usage when user consent is missing

I’m working on making my website compliant with GDPR and cookie consent laws. The issue I’m facing is that users need to give permission before any cookies get placed on their devices.

My current situation:
Right now I’m only loading the Google Analytics tracking code after someone clicks accept on my cookie banner. But this means I’m losing analytics data from visitors who haven’t made a choice yet.

What I want to achieve:
I’d like to load Google Analytics for all visitors but have it work differently based on consent status. For users who said yes to cookies, it should work normally. For users who haven’t decided or said no, it should collect basic data without using cookies.

My question:
Does Google Analytics have a built-in way to turn off cookie usage? I’m looking for something like a configuration option that tells GA to run in a cookie-free mode.

I tried looking through the GA documentation but couldn’t find clear instructions on how to handle this consent scenario. Has anyone dealt with this before or know where to find the right settings?

I set this up about six months ago and hit some gotchas you should know about. Consent mode works great, but you’ve got to initialize it right from the beginning - don’t load GA normally first then try switching modes later. That’ll drop cookies before users even consent. Also heads up, the cookieless data is pretty limited and uses modeling to fill gaps. Good for basic traffic patterns but you won’t get the detailed user journey stuff like with full tracking. The switch between modes is smooth once people consent though. What really helped me was testing different consent scenarios in dev tools to make sure no cookies were getting set when they shouldn’t be.

GA4 has built-in options for exactly this. Set the storage parameter to denied for both analytics_storage and ad_storage when users haven’t consented yet. GA4 will still collect basic data but won’t drop cookies on their device.

You can do this through Google Tag Manager or directly in your gtag setup. Once users give consent, just update those storage settings and GA4 starts using cookies for detailed tracking.

I set this up last year and it works great - you get some analytics while staying GDPR compliant. Google calls it “consent mode” and it’s pretty much the standard approach now.

yeah, consent mode’s definitely ur best bet! just use gtag.js instead of the old analytics.js - the older version doesn’t handle this properly. had the same problem last month and switching to gtag solved everything for our client sites.