# Consent Mode v2 in code: basic vs advanced, and how to prove your cookie banner actually blocks anything

Two things get mixed up in almost every cookie-banner ticket. The banner is the part that asks the visitor. Google Consent Mode is the part that tells Google's tags what the visitor answered. A site can have a perfectly designed banner and still send data to Google before anyone clicks, or a correct Consent Mode setup behind a banner nobody can refuse. Regulators fine the first kind of mistake; Google penalises the second.

This is the developer-side version of a guide we wrote for site owners. It covers what the four consent signals are, the `gtag` calls behind basic and advanced mode, what each mode sends before the visitor has answered, and the DevTools check that tells you whether your banner blocks anything at all. It describes the rules as of autumn 2026 and is not legal advice.

## TL;DR

- **The rule** is Article 5(3) of the ePrivacy Directive: nothing that is not strictly necessary may be stored on or read from the device without consent. Cookies, localStorage and device identifiers all count.
- **Consent Mode v2** passes four signals to Google's tags. Since March 2024, Google needs them for advertising and measurement on visitors in the European Economic Area.
- **Basic mode** loads no Google tag until the visitor answers. **Advanced mode** loads the tags at once, consent denied, and sends cookieless pings.
- **Test it in a private window**: before you click anything, the Network tab should show no requests to Google, Meta or any other tracker.
- **The cheapest banner is no banner**: self-hosted fonts, click-to-load embeds and cookie-free analytics remove most of the reasons for one.

## The four signals

| Signal | Controls | Since |
| --- | --- | --- |
| `ad_storage` | Advertising cookies | Version 1 |
| `analytics_storage` | Analytics cookies | Version 1 |
| `ad_user_data` | Sending user data to Google for advertising | Version 2, November 2023 |
| `ad_personalization` | Personalised advertising, such as remarketing | Version 2, November 2023 |

An advertiser who sends no consent signals for EEA visitors loses them from remarketing audiences and from Google's measurement features, which is why a site that advertises to Europe needs both pieces: a banner that asks, and Consent Mode that passes the answer on.

## The part both modes share

Every setup starts the same way, before any Google script: the `dataLayer`, the `gtag` function, and a default state with everything denied.

```html
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() { dataLayer.push(arguments); }

  // Before anything else: nothing granted until the visitor says so.
  gtag('consent', 'default', {
    ad_storage: 'denied',
    ad_user_data: 'denied',
    ad_personalization: 'denied',
    analytics_storage: 'denied',
  });
</script>
```

The order matters. A `consent default` call that runs after the Google tag has already fired is too late; the first hit went out under no consent state at all. Put this block first in the `<head>`, above any tag manager or `gtag.js` include.

The visitor's choice itself may be stored without asking: remembering a refusal is strictly necessary to respect it. On every page load, read it back and send it as an update before any tag runs, or the visitor gets asked again on every page.

## Basic mode: nothing loads until the answer

In basic mode the Google tag is not requested at all until the visitor answers. If they refuse, nothing is sent to Google, not even the refusal.

```js
// Called by your banner with the visitor's choice (or on page load, with the stored one).
function applyConsent({ analytics, ads }) {
  gtag('consent', 'update', {
    analytics_storage: analytics ? 'granted' : 'denied',
    ad_storage: ads ? 'granted' : 'denied',
    ad_user_data: ads ? 'granted' : 'denied',
    ad_personalization: ads ? 'granted' : 'denied',
  });

  if (!analytics && !ads) return; // refused: no script, no request, nothing

  const s = document.createElement('script');
  s.async = true;
  s.src = 'https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX';
  document.head.appendChild(s);
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');
}
```

The price is data. Google's documentation says basic mode feeds a general conversion-modelling model rather than one specific to your account, so the gaps left by people who refused are filled less precisely.

## Advanced mode: the tags load first

In advanced mode the Google tag loads straight away, with the denied defaults in place, and the banner only updates the state:

```html
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() { dataLayer.push(arguments); }
  gtag('consent', 'default', {
    ad_storage: 'denied',
    ad_user_data: 'denied',
    ad_personalization: 'denied',
    analytics_storage: 'denied',
    wait_for_update: 500, // ms to wait for a banner that restores a stored choice
  });
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');
</script>
```

While consent is denied, the tags set no cookies but still send cookieless pings, which Google uses to model the conversions it can no longer observe; Google says advanced mode gets an advertiser-specific model, and that modelling only starts once a site sends enough data.

**Advanced mode recovers more data, but those pings travel from the visitor's browser to Google before the visitor has agreed to anything.** That is the part a data-protection adviser needs to approve, not the developer. Our recommendation is basic mode unless someone with that responsibility has signed off on advanced.

## Prove it: the ten-minute DevTools check

A misconfigured consent platform is the most common way a banner ends up decorative: it shows, it records the click, and the tags were never wired to wait for it. The check needs no tools beyond the browser.

Open the site in a private window and, before clicking anything, open DevTools. Under Application → Cookies, only strictly necessary cookies should be listed. In the Network tab, filter for `google-analytics|googletagmanager|doubleclick|facebook|linkedin` and reload: in basic mode the list should be empty. In advanced mode you will see requests to Google, and the `gcs` parameter on them shows the consent state the tag sent: `G100` means advertising and analytics storage both denied, `G111` both granted.

You can also read the consent calls straight from the console:

```js
dataLayer.filter(e => e[0] === 'consent')
```

The first entry should be the `default` with everything denied, and it should come before anything else Google-related in the `dataLayer`. Then click reject, reload, and repeat all of it: the refusal has to survive navigation, not just the current page.

Two more things to check while DevTools is open. Third-party embeds that set storage as soon as they load, such as a YouTube video, a Google Map or a chat widget, are not covered by Consent Mode at all; they need to wait for consent or load on click. And the banner should have a reserved place in the layout, so it does not push the page around when it appears and count against Cumulative Layout Shift.

## What a valid banner looks like

**Refusing has to take exactly as much effort as accepting: one click, on the first screen.** That is the point regulators have enforced hardest. In December 2021 France's CNIL fined Google €150 million and Facebook €60 million because refusing took several clicks and accepting took one. On 1 September 2025 it fined Shein €150 million for advertising cookies placed before any choice and after a refusal, and Google €325 million, partly because refusing advertising cookies at account creation had been harder than accepting them.

The rest follows from what consent means: no pre-ticked boxes (the EU Court of Justice said so in Planet49, 2019), no consent by scrolling, a separate choice per purpose, and a way to change one's mind that is as easy as the original answer, usually a small link that reopens the banner. If you advertise with Google, use a platform from Google's list of certified ones, such as Cookiebot, Usercentrics, OneTrust, Didomi, iubenda, CookieYes or Complianz; they send the Consent Mode signals for you, and the work left is putting every tool on the site under the right purpose and checking that each one waits.

## The cheapest banner is the one you do not need

**If nothing on the site needs consent, there is nothing to ask, and building a site that way is a legitimate engineering choice, not a loophole.** Most sites need a banner because of three or four tools, and each of them is a decision. Fonts can be served from your own domain instead of Google's, which also removes a third-party connection. Analytics can be cookie-free when you do not run ads. Videos and maps can load only when someone asks for them:

```html
<button class="video-facade" data-id="VIDEO_ID">Play the video (loads YouTube)</button>
<script>
  document.querySelectorAll('.video-facade').forEach(button =>
    button.addEventListener('click', () => {
      const frame = document.createElement('iframe');
      frame.src = `https://www.youtube-nocookie.com/embed/${button.dataset.id}?autoplay=1`;
      frame.allow = 'autoplay; encrypted-media';
      frame.allowFullscreen = true;
      button.replaceWith(frame);
    })
  );
</script>
```

Our own sites are built this way: [levelui.com](http://levelui.com?utm_source=hashnode), [levelui.de](http://levelui.de?utm_source=hashnode) and [levelui.ro](http://levelui.ro?utm_source=hashnode) set no cookies for visitors and load no third-party scripts, so there is no banner. Visits are counted by our own analytics on our own server, which stores no cookie and keeps no identifier longer than a day. We do advertise on Google, and an enquiry is reported to Google Ads from our server, only after it has reached us and only if the visitor ticked an unticked box on the form allowing it. A privacy notice is still required either way; what disappears is the question.

## What may change

The European Commission's Digital Omnibus proposal of November 2025 would move the cookie rule into the GDPR, require refusal in a single click and let browsers send consent signals automatically. The Council agreed its own position on 21 October 2026, keeping the rule in the ePrivacy Directive and dropping the browser signals; Parliament has not voted yet, so none of it applies. Whatever comes out of it, the safe assumption is that refusing will get easier, not harder, so build for that.

---

*Originally published on* [*levelui.com*](https://levelui.com/resources/cookie-banner-consent-mode-v2?utm_source=hashnode)*, with the table of what on a typical site needs consent first, the German and Romanian cookie laws, the full source list and answers to the questions clients ask, such as whether Google Analytics can run without a banner. Also available in* [*German*](https://levelui.de/resources/cookie-banner-consent-mode-v2?utm_source=hashnode) *and* [*Romanian*](https://levelui.ro/resources/cookie-banner-consent-mode-v2?utm_source=hashnode)*.*

*This copy is a snapshot from the day it was posted, and it will not be updated here. The original on* [*levelui.com*](https://levelui.com?utm_source=hashnode) *is the version we keep current: when a regulator publishes a decision, Google changes a requirement or the EU law moves, that is where the correction lands. If you want the up-to-date version, follow the link above.*

*We are* [*Level UI*](https://levelui.com?utm_source=hashnode)*, a web design and development agency in Bucharest.*
