Cookies

Setting up Google Analytics, Google Ads and Tag Manager with consent

Contents
  1. What Google requires
  2. Where the law asks for consent, and where it does not
  3. Step 1: put the Trust Center line first
  4. Step 2: keep the ad click when cookies are off
  5. Step 3: tag each Google script with its category
  6. Step 4: Google Tag Manager
  7. Step 5: enhanced conversions and offline uploads
  8. Step 6: health, wellbeing and other sensitive businesses
  9. If you show Google ads on your site (AdSense or Ad Manager)
  10. What to expect in your reports
  11. Check that it works

If you run Google Ads, Google Analytics 4 or Google Tag Manager, your cookie banner decides how much of your advertising you can measure. Set up badly, a banner either breaks the law or switches off conversion tracking for visitors who never needed to be asked. This guide covers what Google requires, where the law asks for consent and where it does not, and the exact steps to connect Google's tags to the Trust Center consent panel.

What Google requires

Google's EU user consent policy applies to visitors in the European Economic Area, the United Kingdom and Switzerland. For those visitors you must get legally valid consent for cookies where the law requires it, get consent before personal data is used to personalise ads, keep records of each consent, tell people how to withdraw it, and name each party that receives their data. Google can limit or suspend your account if you do not.

Google's tags learn the visitor's choice through Consent Mode. Version 2 has four signals:

  • analytics_storage: analytics cookies such as _ga.
  • ad_storage: advertising cookies such as _gcl_au.
  • ad_user_data: sending user data to Google for advertising.
  • ad_personalization: using the data for remarketing and personalised ads.

Advertisers who show ads to EEA and UK visitors need these signals to keep building remarketing audiences and measuring conversions for those visitors.

Privacy law is not the same everywhere, so one banner setting for the whole world is either too strict or not strict enough. The Trust Center panel applies the rule for the visitor's location, read from Cloudflare's country data without storing an IP address:

ModeWhere (examples)What happens before a choice
Opt-inEU and EEA, United Kingdom, Quebec, Brazil, Singapore, South Africa, TurkeyA panel asks first; analytics and advertising tags wait for consent.
Opt-outAustralia, Canada outside Quebec, Switzerland, US states with a privacy lawA bar at the bottom of the page; tags run, with a clear way to switch them off. Global Privacy Control keeps advertising off.
NoticeOther US states, New Zealand, JapanA bar explains the cookies; tags run.

So an Australian business advertising mainly in Australia does not lose its Australian conversions by adding Trust Center: Australian visitors see a bar, not a wall, and Google is told consent is granted from their first page view. The tags that would break the law in London still wait there. Switzerland is the one exception for Google: its law starts tracking on, but Google's policy covers Swiss visitors, so Google's advertising signals stay denied there until the visitor accepts Marketing.

Step 1: put the Trust Center line first

Paste the line from https://<your Trust Center host>/consent/bootstrap.txt at the very top of your site's head code, above every Google tag. It must come first: Google's consent defaults only work if they are set before any tag sends data.

The line sets all four Consent Mode signals to denied, then to granted for visitors in locations where tracking starts on (advertising stays denied for browsers that send Global Privacy Control, and in Switzerland). It uses wait_for_update: 500, turns on ads_data_redaction (ad click identifiers are removed from Google Ads requests while advertising consent is denied) and replays a returning visitor's saved choice straight away. When a visitor chooses, the panel sends the update: the Analytics category grants analytics_storage, and the Marketing category grants the three advertising signals.

Step 2: keep the ad click when cookies are off

Add URL passthrough to your Google tag, before the config lines:

gtag('set', 'url_passthrough', true);

While advertising cookies are denied, Google then carries the click identifiers (gclid, wbraid and others) in the page links instead of a cookie, so a visitor who clicks an ad and accepts on the second page is still credited to the ad. In Google Tag Manager, add the configuration parameter url_passthrough with the value true to the Google tag instead.

Step 3: tag each Google script with its category

Change each Google script so it waits for its category. Keep every other attribute and the code inside unchanged.

Google Analytics 4 is analytics:

<script type="text/plain" data-tc-consent="analytics" async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
<script type="text/plain" data-tc-consent="analytics">
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('set', 'url_passthrough', true);
  gtag('config', 'G-XXXXXXX');
</script>

A Google Ads tag (AW-) and Floodlight are marketing: use data-tc-consent="marketing".

In opt-out and notice locations they run straight away and Google is told consent is granted from the first page view, so your ads are measured as before. In opt-in locations they run the moment the visitor accepts that category. The Trust Center cookie scanner lists every tag on your site that still runs before a choice, with the re-tagged version ready to paste.

Step 4: Google Tag Manager

A Tag Manager container usually holds tags from several companies, often Meta, Microsoft and TikTok as well as Google. Use two locks:

  1. The container. Re-tag the Tag Manager script with the category of its most intrusive tag, which is marketing whenever it holds any advertising pixel. If you want Analytics for visitors who accept analytics only, move the GA4 tag out of the container and add it directly as in step 3.
  2. Each tag. In the container, open Admin, Container settings, and turn on the consent overview. For every tag that is not from Google, open Advanced settings, Consent settings, choose Require additional consent for tag to fire, and add ad_storage for advertising pixels, analytics_storage for analytics tools. Google's own tags read Consent Mode by themselves.

Step 5: enhanced conversions and offline uploads

Enhanced conversions send a hashed email address or phone number with each conversion, which recovers much of the measurement lost to browsers and banners. Hashing does not make it anonymous: it is still personal data. Send it only for visitors who granted Marketing, and list Google as a recipient in your privacy policy. The same applies to offline conversion imports and Customer Match lists.

Step 6: health, wellbeing and other sensitive businesses

If you sell health, physiotherapy, therapy, fertility or similar services, two extra rules apply.

  • Google's own rules. Ads promoting products in the Health category cannot use advertiser-curated audiences such as remarketing lists and Customer Match. Ask your account manager how your campaigns are classified before you plan around remarketing.
  • The law. Health information is sensitive almost everywhere. In Australia, the OAIC's guidance on tracking pixels says pixels are not banned but sensitive information needs consent. Keep Google tags off pages and forms that collect symptoms, conditions or assessment answers, keep condition names out of page addresses and form fields that tags read, and never send them as conversion values or event names.

If you show Google ads on your site (AdSense or Ad Manager)

This is a separate rule for publishers, not advertisers. Sites that earn money from AdSense, Ad Manager or AdMob ads shown to visitors in the EEA, the UK or Switzerland must use a Google-certified consent tool built on the IAB Transparency and Consent Framework. The Trust Center panel is not a certified framework tool. If you run Google ads for revenue, either keep them off for those visitors or use a certified tool for that traffic.

What to expect in your reports

  • Opt-out and notice locations: no change, apart from people who choose I Do Not Accept Cookies or switch Marketing off.
  • Opt-in locations: fewer recorded conversions, because visitors who decline are no longer tracked. Google Ads fills part of the gap with modelled conversions.
  • GA4 modelling: Analytics models declined visitors only when Google tags load before the choice, and only for properties with at least 1,000 events a day from declined visitors for 7 days and at least 1,000 daily users who accepted on 7 of the previous 28 days (Google's thresholds). With tags waiting for consent, as in step 3, small and medium sites should expect real numbers, not modelled ones.

Before you switch, record two weeks of conversions in Google Ads and Analytics, tell whoever manages your campaigns the date, and compare the two weeks after. Automated bidding takes a few days to settle; avoid changing budgets or targets in that window because of the drop alone.

Check that it works

  1. Open your site in a private window with Google Tag Assistant connected. From an opt-in location, before you choose, the Consent tab should show all four signals as denied; from an opt-out location, granted.
  2. Accept, and check the signals change to granted and the GA4 tag fires once.
  3. Reject in a fresh window, and check no _ga or _gcl cookies appear.
  4. In Google Ads, open Goals, Conversions, and check the consent mode diagnostics for each conversion action.
  5. Run the Trust Center cookie scan on your site: it should report no tags running before consent in opt-in mode.

See what your own website shows

The free scan checks your site for cookies set before consent, missing policies and basic security settings, and gives you a score in under a minute.

Run the free scan →