Learn

Why Google Analytics loads before the cookie banner on WordPress

You installed a cookie banner on WordPress and Google Analytics still loads before anyone clicks it. Sometimes that is Consent Mode working as designed; often it is a plugin that never waits. This guide shows how to tell the two apart and what Site Kit, MonsterInsights and GTM4WP offer to make the tag wait.

To see what your page loads before consent, run the free WordPress check.

Check my WordPress site

First: is it tracking, or a Consent Mode ping?

With Google Consent Mode, the Google tag is allowed to load before the visitor answers the banner and send a request that says consent was not given. That request carries no Analytics cookie. So seeing googletagmanager.com before consent is not, on its own, the problem. What it sends is.

  1. Open a page in a private window and do not answer the banner.
  2. In the developer tools, Network tab, filter by collect and open a request to google-analytics.com/g/collect.
  3. Find the gcs parameter. G100 means analytics and ads storage were denied: a Consent Mode ping. G111 means both were granted before anyone agreed, which is only right where your setup grants by default on purpose, such as for visitors outside the EEA and the UK. No gcs at all, plus an _ga cookie, means Consent Mode is not set up and the tag is tracking. No collect request at all before an answer means the tag is being held back.

The guide to checking whether Google Consent Mode works goes through the other parameters.

Why it happens on WordPress

  • The analytics plugin and the banner plugin do not talk to each other. The banner shows, and the plugin that adds Google Analytics loads it anyway, because nothing told it to wait.
  • The tag is pasted into the theme or a snippet. A banner plugin can only hold back the scripts it knows about. Code in header.php or a WPCode snippet runs unless the banner blocks scripts automatically and recognises this one.
  • Two copies of the tag. One respects consent and the other, left over from an earlier setup, does not.
  • Tag Manager fires it on every page. The container has a Google Analytics tag with no consent check, or Consent Mode defaults set to granted.

Before changing settings, find where the tag comes from: which WordPress plugin adds a tracker.

Site Kit by Google

Site Kit has a Consent Mode setting under Site Kit > Settings > Admin Settings. When it is on, visitors from the EEA, Switzerland and the UK get no Analytics or Ads cookies until they consent; Google receives only the denied ping described above. It only learns about that consent through the WP Consent API plugin and a banner plugin that supports it; Site Kit names Complianz, Cookiebot and CookieYes, and says not to also turn on the banner plugin's own Consent Mode feature.

Source: Site Kit, Consent Mode

MonsterInsights

MonsterInsights handles this through its EU Compliance addon, which lists EEA Consent Mode and integrations with CookieBot, Cookie Notice, CookieYes and Complianz that hold off tracking until the visitor consents. If you use MonsterInsights with a different banner, check the result with the steps above.

Source: MonsterInsights EU Compliance addon

GTM4WP (Google Tag Manager for WordPress)

GTM4WP can set the Consent Mode defaults: the Google Consent Mode option in its Consent mode & consent tools settings. Turn it on only if your banner plugin sends just the update after the visitor answers, not the defaults; if both send defaults, they can overwrite each other. Each signal you tick there counts as granted before the visitor agrees, so for visitors in the EEA and the UK leave them unticked. It has integrations for Cookiebot, CookieYes and Axeptio.

The defaults only cover the tags that read Consent Mode. A Meta Pixel or another non-Google tag inside the container still needs its own consent condition in Tag Manager.

Source: GTM4WP, Consent mode and consent tools

Check it again

After any change, clear the site's cache and any optimisation plugin's cache, then repeat the gcs check in a private window, once without answering the banner and once after rejecting. Then run the free WordPress check to see the trackers your page loads. This guide is practical advice for an audit, not legal advice.

See what loads before your banner is answered

The free check lists the trackers your page loads, with no account and nothing to install.

Check my WordPress site