Guide

How to Block Google Analytics Until Consent

By Published 13 July 2026

To block Google Analytics until consent, set Google Consent Mode v2 to denied by default, then update it to granted only after the visitor accepts. With analytics_storage at denied, GA4 stores no analytics cookies and sends no measurement until the visitor agrees. Under UK PECR, analytics that share data with Google need consent first, so the default has to be denied.

This is the compliant way to run GA4 in the UK and EU. Turning the tag off entirely loses the modelled data that Consent Mode preserves, and loading GA4 normally sets cookies before consent, which breaks PECR.

The steps

  1. Set the Consent Mode default to denied, before GA4 loads. The default command has to run first, so put it high in the <head>, above your GA4 or Google Tag Manager tag.
  2. Load GA4 or gtag.js after the default. With the default in place, GA4 starts in a consent-aware state and holds back cookies and measurement.
  3. Update consent when the visitor accepts. Your banner sends a Consent Mode update that flips analytics_storage to granted, and GA4 begins full measurement from that point.
  4. Verify it. Open your site in a private window, check that no _ga cookie is set before you accept, then accept and confirm GA4 starts. Google's Tag Assistant shows the Consent Mode state at each step.

Steps 1 to 3 are exactly what the Consentfolio snippet does. The first line sets the denied defaults, the async tag renders the banner, and accepting sends the update. You paste one snippet and the sequence is handled. See how to set up Google Consent Mode v2.

GA4 does not sit idle. With Consent Mode v2 in advanced mode, it sends cookieless pings that Google uses to model the traffic you did not measure directly, so your reports keep a shape rather than dropping to zero. In basic mode, GA4 sends nothing until consent. Consentfolio uses the advanced pattern, so you keep modelled data without setting cookies before consent. Read Consent Mode basic vs advanced.

Frequently asked questions

Does Google Analytics still work with Consent Mode denied? Yes, in a limited way. It collects no analytics cookies and no direct measurement until consent, but in advanced mode it sends cookieless pings that Google uses to model the gap. Full measurement resumes when the visitor accepts.

Do I still need a cookie banner if I use Consent Mode? Yes. Consent Mode manages how Google tags behave, but you still need a banner to collect and record the consent that flips the signals. See UK cookie law explained.

Is Google Analytics GDPR compliant once I block it until consent? Blocking until consent is the core of it, but compliance also depends on your data-sharing settings and disclosures. See is Google Analytics GDPR compliant in 2026?.


Written by Tudor Rusmanica, founder of Consentfolio. Tudor has spent over a decade in agency SEO, working where search performance meets data protection: the analytics, tagging and consent setups that keep measurement useful and lawful. Connect on LinkedIn.

Published 13 July 2026. Last reviewed 13 July 2026.

Questions? consentfolio.com · This guide is general information, not legal advice.