Server-side tracking with GDPR consent: a setup guide for GA4

Server-side tracking moves your tags to a server you control, and the EU consent rules move with them. A GA4 setup with consent checks in the browser and on the server, what regulators have said, and a test checklist.

Server-side tagging moves your tags from the visitor's browser to a server you control, and the EU consent rules move with them: you still need a banner, and the server has to respect every choice the visitor makes. What you gain is control over what each vendor receives and, on your own domain, cookies that can last longer in Safari. This guide sets up GA4 that way, with consent checks in the browser and on the server, and ends with a test checklist.

The short version

  1. 01Server-side tagging changes where tags run. EU regulators say a script that makes the browser send data is covered by the consent rule, so you still need a banner.
  2. 02Consent Mode v2 passes the visitor's choice to Google tags. Basic mode sends nothing before a choice. Advanced mode sends cookieless pings, and we found no regulator ruling on it by name.
  3. 03Set defaults to denied before Google Tag Manager loads and route the Google tag to a server container. Google's server tags follow the consent state. Other tags need a gate you build.
  4. 04Serve the container from your own domain with no third-party CNAME, or Safari may cap its cookies at 7 days.
  5. 05Without consent you can measure very little: in France, anonymous audience counts under strict conditions. Attribution sits outside every exemption we found.
  6. 06Test the requests sent before a choice, the consent value in each hit, and the cookies after a refusal.

Server-side tagging changes who receives the browser's requests and which cookies can be set. What needs consent stays the same.

With server-side Google Tag Manager, the browser sends each event to a server container you run, for example on Cloud Run, where a GA4 client and tag forward it to Google.

Client-side VISITOR'S BROWSER Consent needed for analytics and ads Server-side VISITOR'S BROWSER Consent needed for analytics and ads Request from the browser, cookies set by JavaScript Your tagging server www.example.com/metrics Can also set cookies in its HTTP response GA4 client GA4 tag Only what you choose to forward Google Analytics Ad vendor Google Analytics Ad vendor
Client-side and server-side tagging side by side: the browser still sends the data, and consent is needed in both
Client-sideServer-side
Receives the browser's requestEach vendorYour tagging server
CookiesSet by JavaScriptCan also be set by your server
Consent for analytics and adsNeededNeeded

Two things do change:

  • Cookies can last longer, because a server on your domain can set them in its HTTP response (step 2).
  • You decide what leaves. Transformations can drop or rewrite parameters before any tag sees them, and Google says its GA server tags already redact part of the IP address.

The EDPB, the board of EU data protection authorities, finalised its Guidelines 2/2023 on Article 5(3) of the ePrivacy Directive on 7 October 2024. Paragraph 33 covers JavaScript that instructs the browser to send requests with information: "Such access clearly falls within the scope of Article 5(3) ePD." A Google tag sending events to your server does that. The rule also applies when someone other than the sender of the instruction receives the data (paragraph 34), and even when the information is not personal data (paragraph 10). Being in scope still leaves room for the exemptions in Article 5(3), which national authorities interpret (paragraphs 4 and 56).

A German court has gone further. On 19 March 2025 the Administrative Court of Hanover (10 A 5385/22) held that using Google Tag Manager needed consent, after the authority's lab found that the page sent visitors' IP addresses and device data to googletagmanager.com before any banner interaction. It is one first-instance ruling. If your banner itself loads through Google Tag Manager, GTM runs before the visitor chooses, which is the pattern that court ruled against.

Server-side tagging also will not bring back visitors who refused. Their data stays out of your reports, apart from what Google's modelling estimates. If you are rebuilding measurement around that gap, start with the four step measurement stack we would run after Privacy Sandbox.

Consent Mode passes the visitor's choice to Google tags as named states, each granted or denied, and the tags change what they store and send.

Google lists seven consent types. Four of them drive GA4 and Google Ads:

Consent typeWhat it controls
analytics_storageAnalytics cookies
ad_storageAdvertising cookies
ad_user_dataSending user data to Google for advertising
ad_personalizationPersonalised advertising, such as remarketing

Google added the last two in November 2023, which is what "v2" means. It says that to keep using its tags for measurement, ad personalisation and remarketing, you must collect consent from users in the EEA and pass the signals on. Its EU user consent policy also requires records of consent and clear instructions for withdrawing it.

Each page sets a default, then an update when the visitor chooses. The default must run before any tag sends data.

Inline script in the page head: consent default, everything denied except security_storage Must run before any tag sends data Google Tag Manager snippet loads Banner fires on the Consent Initialization trigger Visitor chooses: consent update to granted or denied Google tags send hits that carry the consent state ONE PAGE LOAD 1 2 3 4 5 wait_for_update: 500 ms for the banner to apply a stored choice
The order on every page load: the consent default first, then Tag Manager, then the banner and the visitor's choice

Put the default in an inline script in the page head, ahead of the Google Tag Manager snippet. A strict version looks like this:

<script id="consent-defaults">
  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
  });
  gtag('set', 'ads_data_redaction', true);
</script>
<!-- The Google Tag Manager snippet comes after this script -->

Everything starts denied except security storage. wait_for_update gives the banner 500 milliseconds to apply a stored choice, and ads_data_redaction strips ad click IDs from Google Ads requests while ad_storage is denied. With no region parameter, visitors outside Europe start denied too. Google calls region-scoped defaults best practice:

// Denied by default where consent is required
gtag('consent', 'default', {
  ad_storage: 'denied',
  ad_user_data: 'denied',
  ad_personalization: 'denied',
  analytics_storage: 'denied',
  region: ['PL', 'DE', 'FR' /* every EEA country, plus GB and CH */]
});
// A default without a region applies to everyone else
gtag('consent', 'default', {
  ad_storage: 'granted',
  ad_user_data: 'granted',
  ad_personalization: 'granted',
  analytics_storage: 'granted'
});

Basic and advanced mode differ in what reaches Google:

BasicAdvanced
Google tags before a choiceBlockedLoaded with defaults
Sent after a refusalNothing, not even the consent stateConsent state and cookieless pings
GA4 behavioural modellingNoYes, above a traffic floor
Google Ads conversion modellingGeneral modelAdvertiser-specific model

Google says a cookieless ping carries a timestamp, the user agent, the referrer, whether the visit had an ad click ID, the consent states and a random number per page load. Like any request it also carries the IP address, which Google says GA4 does not store or log.

As of November 2026, Google's behavioural modelling needs at least 1,000 events a day with analytics_storage denied for 7 days, and at least 1,000 daily users with it granted on 7 of the previous 28 days. Google says even that does not guarantee eligibility.

We found no regulator decision on advanced mode by name, and in our reading its pings are what paragraph 33 describes. We would use basic mode for EEA visitors unless your legal team signs off on advanced.

Check each part in Preview before you start the next.

1. Create the server container in an EU region

Create a Tag Manager container of type Server. Google's automatic provisioning puts it on Cloud Run, always in the us-central1 region, so provision it manually in Google Cloud if you want an EU region. Then check that it answers:

curl https://YOUR-CLOUD-RUN-URL/healthy
# expected output: ok

As of November 2026, Google estimates about $45 a month per server, recommends at least two to reduce the risk of data loss in an outage, and expects 2 to 10 autoscaled servers to handle 35 to 350 requests per second. That is $90 a month for the recommended two and $450 at ten.

Monthly Cloud Run cost at Google's estimate of $45 per server
Recommended minimum, 2 servers
90 USD
Top of the 2 to 10 autoscaling range
450 USD

Google for Developers, Set up server-side tagging with Cloud Run (2 x 45 and 10 x 45)

2. Serve it from your own domain

Google's custom domain guide compares three options for a site on www.example.com:

OptionExample URLServer-set cookies
Same origin (Google's best practice)https://www.example.com/metricsFull access
Subdomainhttps://metrics.example.comFull access
Default domainhttps://metrics.run.appNone, JavaScript cookies only

WebKit, the engine behind Safari, deletes cookies written by JavaScript after 7 days without user interaction, or after 24 hours on a landing page when it detects link decoration, such as a click ID added to the link as a URL parameter. Cookies set in an HTTP response are spared unless WebKit detects cloaking: a subdomain that resolves through a CNAME to a third-party host, or one on an IP address too far from the site's. Then the cap is 7 days. WebKit's July 2024 post defines too far: IPv4 against IPv6, or fewer than 16 shared leading bits for IPv4, 64 for IPv6.

With same origin, your CDN forwards /metrics to the tagging server, so the request goes to the page's own host, with the page's own DNS record and IP address, and neither cloaking test can trigger. We would pick it for that reason. If you use a subdomain, check its DNS:

dig +short www.example.com
dig +short metrics.example.com
# A CNAME to another company's domain, or IPv4 addresses that differ
# in their first two numbers, means Safari caps server-set cookies at 7 days

3. Send the Google tag's hits to the server container

In the web container, keep the consent defaults first and fire your banner on the Consent Initialization trigger. That loads the banner through GTM, so weigh the Hanover ruling above with your legal team. In your Google tag's Configuration settings, add server_container_url with your server's URL as the value. In gtag.js:

gtag('config', 'G-XXXXXXXXXX', {
  server_container_url: 'https://www.example.com/metrics'
});

If your site sends a Content Security Policy, allow the server URL in img-src, connect-src and frame-src. Google's course suggests sending server-side hits to a new GA4 property first, in parallel, until the numbers match. Before you change the Google tag itself, check how the merger of the Google tag and Tag Manager affects consent and server-side setups.

4. Set up the GA4 client and tag

The server container ships with a Google Analytics: GA4 client. Leave Default GA4 paths checked so it claims /g/collect requests, and keep client identification on JavaScript Managed until the custom domain works. Then:

  1. 01Create a Google Analytics: GA4 tag and leave its fields on the defaults. It inherits the measurement ID and parameters from the client.
  2. 02Trigger it with a Custom trigger on Some Events where Client Name equals GA4.
  3. 03Open Preview, load your site and watch the collect requests arrive.

Google's guide says "you only need to set up consent mode in the web container". The Google tag adds consent parameters to each request, and the GA4, Google Ads and Floodlight tags in the server adjust to them. gcs carries ad_storage and analytics_storage. gcd carries more detail and is always sent. Google warns that both may change.

Google's own Transformations example treats G100 and G110 as analytics denied, which gives this reading:

gcsad_storageanalytics_storage
G100denieddenied
G101deniedgranted
G110granteddenied
G111grantedgranted

Non-Google tags, such as a Meta Conversions API tag, ignore these parameters, so gate them yourself. Google's internal parameters page names the event data field x-ga-gcs and says names may change, so confirm it on the Event Data tab in Preview first.

Variable   {{gcs}}        Event Data, key path: x-ga-gcs
Trigger    Ads consent    Custom, fires on Some Events
                          Client Name   equals          GA4
                          {{gcs}}       matches RegEx   ^G11[01]$
Make it the only trigger on every advertising tag that is not Google's.
A request without gcs fails the match, so the tag stays silent.
SERVER CONTAINER Request to /g/collect, carries gcs GA4 client GA4 tag Adjusts to the consent parameters on its own Ads consent trigger {{gcs}} matches ^G11[01]$ G110 or G111, ad_storage granted Meta Conversions API tag fires G100, G101 or no gcs Tag stays silent
Inside the server container: Google's tags read the consent state themselves, other vendors' tags need a trigger that checks gcs

gcs says nothing about ad_user_data. If a vendor needs the v2 signals, we would have the banner push its full choice to the dataLayer and send it as an event parameter.

Two more controls belong here:

  • Google's Transformations page shows an Exclude parameters rule that drops selected custom dimensions when {{gcs}} equals G100 or G110.
  • For tags other than Google Analytics, Google's help page shortens IP addresses with this variable, mapped onto ip_override by an Augment event transformation:
const getAnonymizedIpAddress = require('getAnonymizedIpAddress');
return getAnonymizedIpAddress();

Switching the GA4 client to Server Managed makes the server write an HttpOnly cookie, which practitioner guides call FPID. Google's consent page says no Analytics cookies are set on the client or the server while analytics_storage is denied, and a July 2026 practitioner reference says you stop FPID by blanking the cookie name. Check the response headers on a refused visit.

6. Keep personal data out of Cloud Run logs

By default Cloud Run logs every request with its query parameters, and GA4 requests carry the page address and the client ID in theirs. Google offers this Logs Router filter to drop request logs:

NOT LOG_ID("run.googleapis.com/requests")

Google frames it as a cost saving. We would also treat those logs as personal data with a retention period of their own.

The rule is consent first, with narrow exemptions that differ by country, and fines for ignoring it. The documents that matter for this setup, oldest first:

DateDocumentWhat it says
2002, amended 2009ePrivacy Directive, Article 5(3)Consent to store or read information on a device, unless strictly necessary
7 October 2024EDPB Guidelines 2/2023, version 2.0Script-triggered requests, tracking pixels and some IP-based tracking are in scope
November 2024German DSK guidance for digital services, version 1.2No general answer on whether audience measurement is exempt
19 March 2025Administrative Court of Hanover, 10 A 5385/22Google Tag Manager needs consent, and a steering banner gives no free consent
4 July 2025CNIL audience measurement guidance and self-assessment toolConsent-free measurement under strict conditions, in France
3 September 2025General Court, Latombe (T-553/23)Upholds the EU-US Data Privacy Framework, with an appeal pending
21 October 2026Council mandate on the Digital OmnibusWould add consent exemptions, audience measurement among them. Not law

In 2025 the CNIL issued 83 sanctions totalling 486,839,500 euros, and 21 organisations were sanctioned under the tracker rules: trackers placed without consent, too little information, or refusals ignored. The Google and Shein decisions of 1 September 2025 made up 475 million euros of that total, leaving 11.84 million for all the others. In the Shein case, new trackers were placed after visitors clicked reject all. Your tests have to rule that out.

CNIL fines in 2025, million euros
Google, cookies and Gmail ads
325
Shein, cookies
150
All other 2025 fines combined
11.84

CNIL, Sanctions et mesures correctrices, bilan 2025, 9 February 2026

The Lower Saxony authority reads the Hanover judgment as requiring a clearly visible reject-all button on the first layer whenever there is an accept-all button. In one large crawl, more than half the banners showed no reject option on their first screen. Midas Nouwens and colleagues crawled up to 10,000 top sites on each national domain, such as .pl, in 31 European countries in August and September 2024, and published in April 2025. 67% of the sites showed a consent interface. Of those interfaces, 88% offered accept, 54% offered settings, 45% offered reject, and 15% passed the authors' minimal test: accept and reject equally visible, plus settings or purpose controls with nothing pre-ticked.

Consent interfaces with each element, top national sites in 31 countries, 2024
Accept option
88%
Settings option
54%
Reject option
45%
Minimally compliant
15%

Nouwens et al., A Cross-Country Analysis of GDPR Cookie Banners, CHI 2025

Transfers are a separate matter. A server in an EU region still forwards GA4 data to Google, and Google says it relies on the Data Privacy Framework to move that data to the US; the Commission's adequacy decision behind it was published in the Official Journal on 20 September 2023. The General Court upheld the framework in a judgment now under appeal (C-703/25 P).

The Commission proposed on 19 November 2025 to move the cookie rules for personal data into the GDPR, and the Council's mandate of 21 October 2026 keeps them in the ePrivacy Directive with more exemptions from cookie consent. Neither is law, and Parliament had not agreed its position by 19 November 2026.

This article is not legal advice. It describes what the published texts say, and your data protection officer or lawyer decides for your site.

In France you can run anonymous audience statistics for your own use, with marketing measurement switched off. In Germany there is no general answer.

The CNIL page of 4 July 2025 allows an exemption under Article 82 of the French data protection act when trackers only measure the site's audience, for the publisher alone, and produce only anonymous statistics. The data must not be cross-referenced with other processing, passed to third parties in non-anonymous form, or used to follow people across sites. The CNIL recommends a cookie lifetime of 13 months, not extended on later visits, and keeping the data for 25 months at most. Its self-assessment tool for vendors, from the same month, gets specific, though it calls the technical measures recommendations:

Fits the exemptionMust be switched off
At most three kinds of events: page views, clicks on buttons and links, and load time, scroll or time on pageMeasuring conversion channels, ad campaigns and acquisition channels
A first-party cookieUTM and campaign IDs in URLs, and CRM identifiers
The IP address for city-level location, then at least its last octet removedSession replay
Reports aggregated to the nearest tenAny reuse of the data by the tool's provider for its own purposes
An opt-out link in the privacy policyAny referrer detail beyond the domain

Attribution, the data a team losing conversions wants back, is on the switch-off list. We could not find a CNIL document that confirms a GA4 setup fits these conditions.

The DSK guidance declines to say whether audience measurement is exempt, since the term spans anything from a page counter to a full analysis. It notes that counting page views needs no more than a counter, log files without personal data, or a simple counting pixel of the site itself. It also says that even simple visitor counting is not automatically part of the service the user asked for.

Where an exemption does apply, we think the server container is a good place to enforce it, because transformations can drop identifiers and campaign parameters before anything leaves. It cannot fix a browser tag that reads more from the device than the exemption allows.

Run these ten checks in a clean browser profile at an EEA location, once for each choice.

CHROME DEVTOOLS SCHEMATIC Network collect collect www.example.com collect www.example.com collect www.example.com Payload gcs G100 G100, ad_storage and analytics_storage denied
What to look for in the Network tab before any choice: the consent state carried by a collect request
  1. 01Before any choice, reload with the Network tab open. In basic mode nothing goes to your tagging server or to Google. In advanced mode, collect requests carry gcs=G100.
  2. 02Reject all. In advanced mode hits carry G100, and no _ga or _gcl cookies appear on this page or the next.
  3. 03Accept analytics only. Hits carry G101, and only analytics cookies appear.
  4. 04Accept everything. Hits carry G111.
  5. 05In server Preview, open a G100 event. No non-Google tag may fire, and Tag Details should show that your transformations ran.
  6. 06On the refused visit, the tagging server's responses contain no Set-Cookie for FPID or any other identifier.
  7. 07Withdraw consent through your settings link. An update to denied goes out on the same page, and later hits carry G100.
  8. 08Check the banner the way the Hanover court would: reject on the first layer, as easy as accept, and both choices remembered.
  9. 09In Safari, accept and read the server-set cookie's expiry. Seven days points to CNAME or IP cloaking.
  10. 10Open YOUR-SERVER-URL/healthy and expect ok, then confirm that consent records are kept, as Google's policy requires.

Sources

  1. 01European Data Protection Board, Guidelines 2/2023 on Technical Scope of Art. 5(3) of ePrivacy Directive, version 2.0, 7 October 2024
  2. 02Verwaltungsgericht Hannover, Judgment 10 A 5385/22, 19 March 2025
  3. 03Der Landesbeauftragte für den Datenschutz Niedersachsen, Urteil zu manipulativem Cookie-Banner, 20 May 2025
  4. 04Google for Developers, Consent mode overview, updated 30 July 2026
  5. 05Google for Developers, Set up consent mode on websites, updated 13 October 2026
  6. 06Google Analytics Help, Consent mode on websites and mobile apps, archived copy of 15 November 2026
  7. 07Google Analytics Help, Behavioral modeling for consent mode, archived copy of 11 November 2026
  8. 08Google Ads Help, Updates to consent mode for traffic in European Economic Area (EEA), archived copy of 12 October 2026
  9. 09Google, EU user consent policy, archived copy of 3 November 2026
  10. 10Google for Developers, Implement consent mode with server-side Tag Manager, updated 30 July 2026
  11. 11Google for Developers, Setting up a new server container, updated 30 July 2026
  12. 12Google for Developers, Configuring the Google Analytics 4 data stream with server-side tagging, updated 30 July 2026
  13. 13Google for Developers, Set up server-side tagging with Cloud Run, updated 12 May 2026
  14. 14Google for Developers, Custom domain configuration, updated 27 June 2025
  15. 15Google for Developers, An introduction to server-side tagging, updated 30 July 2026
  16. 16Google for Developers, Send data to server-side Tag Manager, updated 6 November 2026
  17. 17Tag Manager Help, Set up Google Analytics in Tag Manager, archived copy of 16 November 2026
  18. 18Google for Developers, Control the event parameters available to tags with Transformations, updated 30 July 2026
  19. 19Tag Manager Help, IP address redaction for server-side tagging, read 21 November 2026
  20. 20Anders Elmgren, Server-side GTM cookie and FPID reference, 20 July 2026
  21. 21WebKit, Tracking Prevention in WebKit, archived copy of 15 November 2026
  22. 22WebKit, Private Browsing 2.0, 16 July 2024
  23. 23CNIL, Cookies : solutions pour les outils de mesure d'audience, 4 July 2025
  24. 24CNIL, Outil d'auto-évaluation relatif à la mise en œuvre d'une solution de mesure d'audience exemptée de consentement, July 2025
  25. 25CNIL, Cookies déposés sans consentement : la CNIL sanctionne SHEIN, 3 September 2025
  26. 26CNIL, Publicités insérées entre les courriels et cookies : la CNIL sanctionne GOOGLE, 3 September 2025
  27. 27CNIL, Sanctions et mesures correctrices : la CNIL présente le bilan 2025, 9 February 2026
  28. 28Datenschutzkonferenz, Orientierungshilfe der Aufsichtsbehörden für Anbieter:innen von digitalen Diensten, version 1.2, November 2024
  29. 29Midas Nouwens, Janus Bager Kristensen, Kristjan Maalt and Rolf Bagge, A Cross-Country Analysis of GDPR Cookie Banners and Flexible Methods for Scraping Them, CHI 2025, 25 April 2025
  30. 30Court of Justice of the European Union, The General Court dismisses an action for annulment of the new framework for the transfer of personal data between the EU and the US, 3 September 2025
  31. 31Official Journal of the EU, Case C-703/25 P: Appeal brought on 31 October 2025 by Philippe Latombe, 22 December 2025
  32. 32European Commission, Digital Omnibus Regulation Proposal, COM(2025) 837, 19 November 2025
  33. 33Council of the EU, Digital rulebook: Council agrees position to simplify data protection, privacy and cyber reporting rules, 21 October 2026
  34. 34IAPP, One year on, Digital Omnibus may face delays, 19 November 2026
  35. 35Google for Developers, Internal parameters, updated 10 August 2026
  36. 36Google, Advertising and analytics products: Information about international data transfers, 9 September 2024
  37. 37European Commission, Implementing Decision (EU) 2023/1795 on the adequate level of protection of personal data under the EU-US Data Privacy Framework, published in the Official Journal on 20 September 2023

Frequently asked questions

Does server-side tracking remove the need for a cookie banner?

No. The EDPB's Guidelines 2/2023 say that JavaScript which makes the browser send information falls under Article 5(3) of the ePrivacy Directive, whoever receives it. The server container also takes its consent state from the browser, so the banner is still where consent is given.

What is the difference between basic and advanced Consent Mode?

In basic mode Google tags do not load until the visitor accepts, so nothing reaches Google before a choice. In advanced mode the tags load at once and, while consent is denied, send cookieless pings that Google uses for modelling. We found no regulator decision on advanced mode by name, so treat the choice as one for your legal team.

Can I use GA4 without consent in the EU?

Only inside a national exemption, and the exemptions are narrow. France's CNIL allows consent-free audience measurement that produces anonymous statistics for the site owner alone, with campaign and acquisition-channel measurement switched off. Germany's authorities decline to give a general answer, and we could not find a regulator document that confirms a GA4 setup fits any exemption.

Why do Safari visitors still look new after moving to server-side tagging?

Safari deletes cookies written by JavaScript after 7 days without interaction, and caps cookies set by a server at 7 days when that server sits behind a third-party CNAME or on an IP address too far from the site's. Serve the container from your own origin and let the server set the identifier.

Do I need Consent Mode v2 if I do not run personalised ads?

Google's help page says that if you already use consent mode and do not use personalised advertising such as remarketing, the v2 update needs no action from you. You still need valid consent for analytics cookies where the law requires it, which Google's EU user consent policy also demands.

  • Server-side tagging
  • GA4
  • Consent Mode
  • GDPR

Recommended Reading

View all articles

Let's find your next move.

Direct, confidential, and pragmatic. Discuss channel opportunities, technical audits, or tailored team scope with our senior practice leads.

WhatsAppTelegram

Warsaw · 09:00–18:00 CET