Blog

Blocking cookies before consent on WordPress: pixels, videos, and Google tags held back until agreement

To block cookies before consent, displaying a banner is not enough: third-party scripts and videos must actually wait for the visitor's agreement. This guide shows you where they leak, how to hold them back with the nexya Cookies module, and how to verify that they fire properly once consent is given.

Blocking cookies before consent on WordPress: pixels, videos, and Google tags held back until agreement

Key points

  • A banner that only displays a message blocks neither pixels nor embedded videos.
  • The Cookies module neutralizes third-party scripts and iframes server-side, category by category, until consent is granted.
  • In advanced Consent Mode v2, the Google tag waits for an interaction, the response to the banner, or five seconds, with signals denied until consent.
  • Service-by-service consent and the appearance of the banner are features of nexya Pro.

The question often comes up on WordPress forums: the banner is in place, the visitor hasn’t clicked anything yet, and yet the ad pixel has already loaded, the YouTube video has already set its cookies, Google Analytics has already sent its first request. Blocking cookies before consent means preventing just that, not just announcing it.

Many banners simply display a message and record the choice. The rest of the page loads normally, with everything it contains. The visitor sees a question, but the answer changes nothing about what their browser has already received.

The other, more discreet problem is the reverse: once agreement is given, the video remains blank or tracking no longer reports anything. Both situations often have the same origin: a script that isn’t sorted into the right category, or isn’t recognized at all.

Why a pixel or video fires anyway

A third-party script arrives on a page through several paths. It can be pasted into the theme, added by a plugin, inserted by a tag manager, or found in the content itself, like a YouTube video embedded in an article. A banner that only monitors one of these paths lets the others through.

Iframes are the most frequent case. An embedded video loads the service’s player as soon as the page is displayed, and this player drops its own cookies. As long as the iframe is present as-is in the code sent to the browser, no response to the banner can stop it.

Finally, people often forget what was added a long time ago: an old pixel, a chat widget, a map. No one remembers it, and it continues to load on every page.

  • a script hardcoded into the theme or added by a plugin
  • a video or map embedded in the content
  • a tag manager that loads other services
  • an old forgotten service still present in the code

How the Cookies module holds back scripts and iframes

The nexya Cookies module handles the problem at its source: server-side, before the page goes to the browser. Third-party scripts and iframes are neutralized until the visitor gives their consent, category by category. An embedded video therefore waits for agreement instead of loading with the page.

To know what to block, the module offers a scan that crawls the site and finds the third-party scripts it loads. This is the easiest way to find forgotten services, the ones no one thought to declare.

Like all nexya modules, Cookies is turned on from the hub. As long as it is turned off, it records nothing: none of its hooks run on the site. The module is free, for as many sites as you want.

A banner that blocks nothing only informs. Blocking must take place before the page leaves the server.

Holding back third-party scripts until consent, in four steps

  1. 1

    Turn on the Cookies module from the hub

    In the nexya hub, activate the Cookies module. As long as it is turned off, none of its hooks run on the site.

    Turn on the Cookies module from the hub
  2. 2

    Run the site scan

    The scan crawls the site and finds the third-party scripts it loads. Spot forgotten services, like an old pixel or a widget.

    Run the site scan
  3. 3

    Configure the banner and Consent Mode v2

    Set up the banner, check that each service is in the correct category, and enable Google Consent Mode v2 if you use Analytics or Tag Manager.

    Configure the banner and Consent Mode v2
  4. 4

    Test in an incognito window

    Open the site in an incognito window, refuse, check that videos and pixels wait, then accept and reload to see them fire.

For Google tools, the module supports Google Consent Mode v2. Consent signals remain on “denied” until the visitor accepts.

In advanced mode, the Google tag (Analytics 4 or Tag Manager) no longer loads with the page since version 1.6.2. It waits for the visitor’s first scroll, click, or keystroke, their response to the banner, or five seconds after page load. This makes the page lighter for speed tests like PageSpeed.

This delay explains a frequent remark: by opening the browser tools right after loading, you don’t see the Google tag yet. This is not a malfunction. Move the page, click, or wait a few seconds, and it appears, with signals still refused until agreement is given.

When a service no longer loads after agreement

If a video or tool remains silent even though the visitor has accepted, first look at the service category. Blocking is done category by category: a service sorted into a category that the visitor refused remains blocked, even if they accepted the others.

Then run the scan again. A service added after the first pass may not yet be known to the module. Always test in a private window, with no saved choice, to see the site as a new visitor, then accept and reload.

If you need finer tuning, with agreement given service by service rather than by category, that is a feature of nexya Pro.

  • check the category of the service in question
  • run the scan again after any addition of a plugin or integration
  • test in a private window, refuse, then accept
  • wait for interaction or five seconds for the Google tag in advanced mode

What is free, what requires nexya Pro

The consent banner, the blocking of third-party scripts and iframes until agreement, the scan that finds them, and Google Consent Mode v2 are part of the free version.

nexya Pro, sold on nexya.dev, adds the banner appearance and service-by-service consent. The free version does not contain this code; nexya Pro is delivered by Freemius after purchase and uses the same settings.

By default, the plugin sends nothing to a third party. Functions that use the network are listed in the external services section of the plugin.

FAQ

Why does my YouTube video load before the visitor accepts?

Because the iframe is sent as-is to the browser. The Cookies module neutralizes it server-side as long as the visitor has not accepted the relevant category.

I don't see Google Analytics upon page load, is this normal?

Yes, in advanced Consent Mode v2. Since version 1.6.2, the Google tag waits for the first scroll, click, or keystroke, the response to the banner, or five seconds after loading.

How can I tell which third-party scripts my site is loading?

The Cookies module offers a scan that crawls the site and finds third-party scripts. Run it again after each extension or integration addition.

Is service-by-service consent free?

No. The free version blocks by category; service-by-service consent is part of nexya Pro.

The modules in this post

nexya cookie nexya hub

Try nexya Pro free for 7 days

Every module, forms, newsletters and the page cache, on your site. No commitment.

See the plans Or discover the free version