PrivacyQuick

All documentation pages ↓

Google Consent Mode v2

PrivacyQuick sends Consent Mode v2 signals to Google tags automatically. You don't need to write any consent code.

Google tags, including GA4, Google Ads, Floodlight and anything in Google Tag Manager, adjust their behaviour based on Consent Mode signals. PrivacyQuick sends those signals from the visitor's choice, through the standard gtag('consent', …) command on window.dataLayer. If gtag isn't defined on your page yet, the SDK creates the usual stub that pushes to dataLayer, so the signals reach GTM either way.

What the SDK sends

Default, as soon as the script runs

Before it does anything else, the SDK sends a default command. For a new visitor, everything is denied except security storage:

gtag('consent', 'default', {
  analytics_storage: 'denied',
  ad_storage: 'denied',
  ad_user_data: 'denied',
  ad_personalization: 'denied',
  functionality_storage: 'denied',
  personalization_storage: 'denied',
  security_storage: 'granted',
  wait_for_update: 500
});

For a returning visitor, the default already reflects their stored choice. A visitor who accepted analytics last week starts with analytics_storage: 'granted', with no flash of denied state.

Update, when something changes

The SDK sends an update command when:

  • your site settings arrive and the visitor's state differs from the default. For example, a US visitor in opt-out mode is granted the categories your site uses straight away.
  • the visitor makes or changes a choice, through the banner, the preferences panel or the JavaScript API.

If nothing changed, no update is sent.

How categories map to signals

PrivacyQuick categoryConsent Mode signals
analyticsanalytics_storage
marketingad_storage, ad_user_data, ad_personalization
functionalfunctionality_storage, personalization_storage
necessarysecurity_storage (always granted)

A signal is granted only when the visitor has allowed its category and your banner offers that category. If your banner has no Marketing category, the three ad signals stay denied.

Load order and the inline default snippet

Google expects the consent default to be set before any Google tag runs. The PrivacyQuick snippet loads with async, so if your gtag.js or GTM snippet sits above it, or loads faster, a Google tag could run before any default exists.

There are two ways to prevent this:

  1. Put the PrivacyQuick snippet first in the <head>, above your Google tags. This is enough for most sites.
  2. Add the inline default snippet if gtag.js or GTM must load first, or you can't control the order (for example in some CMS themes). Paste it above all Google tags. The dashboard shows the same snippet under the install code.
<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',functionality_storage:'denied',personalization_storage:'denied',security_storage:'granted',wait_for_update:500});</script>

This runs synchronously, so a denied default is in place before anything else. When PrivacyQuick loads, it sends its own signals from the visitor's stored choice and updates them whenever the visitor decides. wait_for_update: 500 tells Google tags to wait up to 500 ms for that update before they fire.

Google Tag Manager

You don't need a CMP template in GTM. PrivacyQuick pushes the consent commands to dataLayer itself. To set up the container:

  1. In GTM, open Admin → Container Settings and turn on Enable consent overview.
  2. Open the consent overview (the shield icon on the Tags page). Google tags have built-in consent checks and need nothing more.
  3. For every non-Google tag, choose Require additional consent for tag to fire and add the right signal: ad_storage for advertising tags such as Meta, LinkedIn or TikTok, and analytics_storage for analytics tags such as Hotjar.
  4. Publish the container, then check your setup in Tag Assistant's preview mode. The Consent tab shows the default and update states for each event.

Firing tags right after the visitor accepts

GTM checks consent at the moment a trigger fires. A tag on a Page View trigger that was blocked when the page loaded won't fire on that page just because the visitor clicks Accept. It fires on the next page view. To fire it straight away, push an event when the choice is made and add a Custom Event trigger for pq_consent_update:

<script>
document.addEventListener('pq:consent', function (e) {
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({ event: 'pq_consent_update', pq_categories: e.detail.categories.join(' ') });
});
</script>

The consent update is pushed before the pq:consent event fires, so tags triggered by this event see the new state.

Blocking versus Consent Mode

You can use Google tags with PrivacyQuick in two ways:

  • Block the tag with type="text/plain" data-category="analytics", as in the script blocking guide. Nothing loads from Google until consent. Google calls this basic Consent Mode.
  • Load the tag normally and let it read the signals. Before consent, Google tags send cookieless pings that Google uses for modelling. Google calls this advanced Consent Mode.

Which approach is right for you depends on your legal advice and on how much measurement data you need. PrivacyQuick supports both.

Global Privacy Control

In opt-out mode, which is the default for US visitors on the Starter and Pro plans, the SDK checks navigator.globalPrivacyControl. If the browser sends the GPC signal and the visitor hasn't chosen yet, the SDK treats it as an opt-out of sale and sharing:

  • The Marketing category is switched off, so ad_storage, ad_user_data and ad_personalization are denied.
  • Analytics and Functional stay on, as is normal in opt-out mode.
  • No banner is shown. The choice is stored and recorded with the action gpc.

You can switch GPC handling off in the banner settings, but we don't recommend it. In opt-in mode, GPC changes nothing, because marketing is already off until the visitor allows it. More detail is on the CCPA and Do Not Sell page.

Switching Consent Mode off

The banner settings have a Google Consent Mode switch, which is on by default. When it's off, the SDK stops sending update commands. The initial default is still sent, because the SDK sends it before your settings load. Google tags that rely on Consent Mode would then stay in the denied state. Turn it off only if you don't use Google tags, or if you block all of them with script tagging.

Checking it works

Open your site in a private window, then type dataLayer in the browser console. You should see a consent / default entry first. After you click a banner button, you should see a consent / update entry with the new values. Google's Tag Assistant shows the same information for each tag.