Consent Mode v2 generator

Google needs Consent Mode v2 to measure and remarket to visitors from the EEA and the UK. Choose where consent is required and copy the snippet that goes before your Google tag, plus the two lines your banner calls on accept and reject.

  • Free
  • No sign-up
  • Runs in your browser
Where consent is required

How long Google tags wait for your consent banner to load (0–5 000 ms).

Put this before your Google tag or GTM container
<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,
    region: ["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","RO","SK","SI","ES","SE","IS","LI","NO","GB","CH"]
  });
  gtag("consent", "default", {
    ad_storage: "granted",
    ad_user_data: "granted",
    ad_personalization: "granted",
    analytics_storage: "granted"
  });
  gtag("set", "ads_data_redaction", true);
  gtag("set", "url_passthrough", true);
</script>
Run this when the visitor accepts
gtag("consent", "update", {
  ad_storage: "granted",
  ad_user_data: "granted",
  ad_personalization: "granted",
  analytics_storage: "granted"
});
…and this when they reject
gtag("consent", "update", {
  ad_storage: "denied",
  ad_user_data: "denied",
  ad_personalization: "denied",
  analytics_storage: "denied"
});

Google requires Consent Mode v2 (ad_user_data and ad_personalization) to measure and remarket to visitors in the EEA and the UK.

A region-specific default wins over the general one, so visitors elsewhere keep full measurement.

Your consent banner must call the update command; this snippet only sets the starting state.

How it works

1

Visitors in Bangladesh keep full measurement

In the regional setup only the 32 listed countries start as denied; everyone else starts granted, so a Bangladeshi store selling at home loses nothing.

2

Order matters

The default command must run before the Google tag or the GTM container loads, so put the snippet first in <head>.

3

The banner does the rest

This sets the starting state. Your consent banner must run the update command when a visitor chooses.

Questions

Do I need Consent Mode if I only sell in Bangladesh?

Not for Bangladeshi visitors. You need it if you advertise to people in the EEA or the UK, because Google uses it to decide what it may measure for them.

What do ads_data_redaction and url_passthrough do?

With ads consent denied, ads_data_redaction removes ad click ids from requests, and url_passthrough carries click information in page links instead of cookies.

Let Trakero do this for every order

Trakero captures click ids, hashes customer data and sends each purchase once to Meta, TikTok, GA4 and more from your server, so ad blockers and Safari can't lose it.

Start free

Tracking rules change. We'll tell you.

A short email when Meta, Google or TikTok change a tracking rule that affects stores, and when we add a free tool. A few a year. Unsubscribe in one click.

We use your address only for these emails. Privacy policy.