Consent Mode v2 with server-side GTM
Consent Mode tells Google tags what the visitor agreed to, so they can adjust what they store and send. With server-side GTM the consent state travels with every hit to your server container. Google tags there respect it on their own, but other server tags, such as the Meta Conversions API, do not. This lesson covers both halves.
Advanced 11 min read
What you will learn
- Explain the four Consent Mode v2 signals and the difference between basic and advanced mode.
- Set a default consent state before GTM loads and update it when the visitor accepts.
- Understand how the consent state reaches your server container with each hit.
- Stop non-Google server tags from firing when consent was denied.
- Verify the consent state with Tag Assistant.
Before you start
- GA4 running through your server container (lesson 4).
- A consent banner (CMP) or a plan to add one.
01 The four Consent Mode v2 signals
Consent Mode v2 uses four signals. Each is either granted or denied.
-
ad_storage: cookies and storage for advertising. -
analytics_storage: cookies and storage for analytics, such as the GA4 client ID. -
ad_user_data: whether user data may be sent to Google for advertising. -
ad_personalization: whether data may be used for personalised advertising, such as remarketing.
The last two were added in v2. Google requires them for advertising features for visitors in the European Economic Area (EEA).
There are two ways to run Consent Mode:
- Basic: Google tags do not load at all until the visitor makes a choice. Nothing is sent before consent.
- Advanced: Google tags load right away with the default (usually denied). While consent is denied they send cookieless pings without identifiers, which Google uses for modelling. After consent they work normally.
02 Set the default and update it
The default state must be set before any tag runs. If you set it in code, place it above the GTM snippet.
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
});wait_for_update gives the banner that many milliseconds to report a stored choice before tags fire. When the visitor accepts, the banner sends an update:
gtag('consent', 'update', {
ad_storage: 'granted',
ad_user_data: 'granted',
ad_personalization: 'granted',
analytics_storage: 'granted'
});In practice you rarely write this code yourself. Most consent platforms (CMPs) have a template in the Community Template Gallery that sets the default and the update for you.
- 1 In the web container go to Tags, click New and choose Tag Configuration. Click Discover more tag types in the Community Template Gallery and search for your CMP.
- 2 Configure the default state in the template, usually
deniedfor all four signals. - 3 Set the trigger to Consent Initialization - All Pages, so it runs before every other tag.
- 4 Publish and test the banner in Preview.
03 How consent reaches the server container
Google tags in the web container add the consent state to every hit they send. The gcs parameter carries ad_storage and analytics_storage, and gcd carries all four signals, including how they were set. Because the hit goes to sgtm.example.com, the state arrives at your server container with it.
The GA4 client reads those parameters and passes them on in the event data. Google tags in the server container (the GA4 tag, Google Ads conversion tracking) respect them automatically: when consent is denied in advanced mode, they forward a cookieless ping and do not set or read identifiers.
05 Verify the consent state
- 1 Open the web container in Preview in a fresh private window, so no earlier choice is stored.
- 2 In Tag Assistant select the earliest Consent event in the Summary and open the Consent tab. On-page Default should show
deniedfor the four signals (or your regional defaults). - 3 Accept the banner, select the most recent Consent event and check that On-page Update shows
granted. - 4 In the server Preview, open a request before and after consent and compare
x-ga-gcsin Event Data.
- The default is set before any tag fires.
- All four v2 signals are set in the default and in the update.
- The server container receives the new consent state after the visitor accepts.
- Non-Google server tags only fire with consent.
Frequently asked questions
Should I use basic or advanced Consent Mode?
Advanced mode lets Google model the conversions of visitors who declined, so you usually see more complete numbers. Basic mode sends nothing before consent. Which one you may use depends on your legal assessment, not on the server container.
Does server-side GTM let me skip the consent banner?
No. Moving tags to a server changes where the data is processed, not whether you need consent to collect it. The same consent rules apply.
Why does the server container still receive hits when consent is denied?
In advanced mode Google tags keep sending cookieless pings while consent is denied. The server container receives them with the denied state and the Google tags there forward them without identifiers.
Ready to put it into practice?
Deploy a server GTM container on your own domain in a few minutes. The Free plan needs no card.
Create a free account