Google Ads with Cookie Compliance

Cookbook · guide Last verified View raw markdown (for agents)

In short: keep the Cookie Compliance snippet as the first script in <head>, then paste the Google Ads tag below it. The banner holds the recognised Google loader and conversion files until the visitor allows their categories, in regions whose rule requires consent first.

You need #

Where it goes #

Google's docs place the tag in the page's <head>. With Cookie Compliance installed, keep the banner snippet first, then paste the Ads tag below it — same shape Google gives you:

<!-- Cookie Compliance snippet first, then: -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-XXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'AW-XXXX');
</script>

Firing Ads through Google Tag Manager instead? Put the banner above the GTM container and gate tags with consent triggers — see gtm and the GTM cookie consent guide.

What the order controls #

The banner recognises the googletagmanager.com loader (default category 2 Content Personalisation) and the googleadservices.com/pagead/conversion files (conversion.js, conversion_async) and the googlesyndication.com/pagead/managed file (the conversion and managed files default to category 4 Ad Personalisation). With Google Consent Mode off, in regions whose rule requires consent first, the Tag Manager / Google tag loaders wait until the visitor allows their category; with it on, those loaders load before the choice with denied Consent Mode defaults. The conversion and managed files always wait until their category is allowed where the region requires consent first. They start after Allow. A script placed above the banner snippet runs straight away.

Confirm the result #

View the page source: the banner snippet comes first in <head>, the Ads tag after it. Before choosing, in a region whose rule requires consent first, _gcl_au (and the other _gcl_* cookies Google lists) are absent; the held script shows type="javascript/blocked" in the Elements panel. After Allow, _gcl_au appears. Browser checks: plain-html; full procedure: verify-install.

Gotchas #

More help #