All Articles
ComplianceEU

WordPress Cookie Consent: What GDPR Requires and How to Test

WordPress Cookie Consent: What GDPR Requires and How to Test

WordPress cookie consent means asking visitors for opt-in permission before your site stores or reads non-essential cookies, and keeping those scripts switched off until they agree. A banner that only displays a notice does not meet that standard. The blocking, the choices and the proof matter more than the design.

What the law actually requires

Two EU laws apply, and people often blur them. The ePrivacy Directive (2002/58/EC), Article 5(3), as amended by Directive 2009/136/EC, covers the act of storing information on a visitor's device or reading information already stored there. That is only allowed with the user's consent, unless an exemption applies. You can read the directive on EUR-Lex.

The GDPR (Regulation (EU) 2016/679) then defines what valid consent is. Article 4(11) requires it to be unambiguous and given by a clear affirmative action, and Article 7 sets the conditions, including that withdrawing must be as easy as giving it. The full text is on EUR-Lex.

In practice this gives you a simple rule. If a cookie or similar technology is not strictly necessary, you need a real opt-in before it is set. Legitimate interest is not a substitute here: it cannot justify placing or reading cookies under Article 5(3), even if it might support some later processing of the data. If you want the wider picture of how privacy law differs from product-security law, see GDPR vs. the EU Cyber Resilience Act for WordPress.

Which cookies need consent and which do not

The rule has two sides. Consent is needed for anything that is not strictly necessary for a service the visitor asked for. Consent is not needed for storage that is strictly necessary for that service.

The usual exempt examples are a shopping cart cookie, a login session cookie, a load balancing cookie, and a bot protection cookie such as __cf_bm. WordPress core's own login and comment cookies sit in a similar space, though you should check what your particular theme and plugins add on top.

Most marketing and measurement tools fall on the consent side:

  • Analytics scripts that set identifiers
  • Advertising and retargeting pixels
  • Embedded video players and social widgets that set their own cookies
  • A/B testing tools that tag visitors

The rule is also not limited to cookies. EDPB Guidelines 2/2023 on the technical scope of Article 5(3) explain that it covers tracking pixels, tracking links, local storage, certain forms of fingerprinting and similar techniques. So moving an identifier from a cookie into localStorage does not take you outside the rule.

Start with an inventory. Load your site in a clean browser profile, list every cookie and storage key, and mark each as necessary or not. Anything you cannot explain should be treated as non-essential until you know what sets it.

What a valid consent banner must offer

A compliant banner is mostly a set of behaviours, not a layout. The choices must be real, and refusing must not be penalised by design.

The Court of Justice ruled in Planet49 (C-673/17) that a website cannot validly seek ePrivacy consent with pre-ticked checkboxes. So every optional category must start switched off, and consent must come from an action the visitor takes.

Use this checklist when you review a banner:

  • Opt-in by default: no pre-ticked boxes, and no consent inferred from scrolling or continued browsing.
  • Granular choices: visitors can accept or refuse by purpose, such as analytics or marketing, not only all or nothing.
  • Equal ease: a reject option is as easy to reach as accept, ideally at the same level of the banner.
  • Plain information: the banner says what each category does and who sets the cookies.
  • Withdrawal: a persistent link or button lets visitors change their mind at any time.

A useful rule of thumb is that the visitor should be able to refuse in the same number of clicks it takes to accept. If your banner needs one click to agree and three to decline, expect it to be criticised. A banner can look polished and still fail every item above, so check behaviour rather than appearance.

How a banner should block scripts on WordPress

This is the part many guides skip. Some snippets describe adding a cookie notice with a bit of CSS. That only displays a message. It does not stop a single script from running, so it does nothing for compliance.

Proper prior blocking means non-essential scripts do not execute until consent is recorded. Cookie plugins typically do this in one of three ways: they rewrite script tags so the browser ignores them until consent, they use a tag manager that fires tags only after a consent signal, or they scan and block known third-party domains. Each has trade-offs. Rewriting is predictable for scripts you control, but embedded iframes and scripts injected by other plugins can slip past.

On WordPress the leaks usually come from a few places:

  • Analytics or pixel code pasted into the theme header or a header and footer plugin
  • Scripts added by a marketing or form plugin without a consent hook
  • Embeds such as YouTube, maps and social feeds loaded in posts
  • Fonts or libraries pulled from external servers

When you choose a consent plugin, ask whether it blocks before consent by default, how you tell it about custom scripts, and whether it handles iframes with a placeholder. Blocking also helps speed, since fewer third-party requests load on the first view. If that matters to you, the PageSpeed Insights guide covers how third-party code affects scores.

Consent records and withdrawal

The GDPR puts the burden of proof on you. If a regulator or a visitor asks, you should be able to show that consent was given. Some guides also describe consent logging as part of a compliant setup, and it is the practical way to meet that burden.

A useful consent record usually stores the following:

  • A timestamp of the choice
  • The categories accepted or refused
  • The version of the banner text and cookie policy shown at the time
  • A pseudonymous identifier, so a visitor's record can be found if they ask

Keep the log minimal. It exists to prove a choice, not to build another profile of the visitor, and the log itself is personal data that needs a retention period you can defend.

Withdrawal is the other half. Consent must be as easy to withdraw as to give, so a small floating button or a footer link such as Cookie settings should reopen the preferences panel on every page. When a visitor withdraws, the plugin should stop the relevant scripts and, where possible, delete the cookies those scripts already set. Re-asking is also reasonable after your cookie set changes materially or after a sensible interval, as long as you do not pester visitors who have already refused.

How to check your banner works

None of the top guides we reviewed gave a concrete test procedure, so here is a simple one you can run in about fifteen minutes. Use a private window with extensions disabled, and open the browser developer tools on the Application and Network tabs.

Step What to do What you should see
1 Load the home page, do not touch the banner Only necessary cookies; no analytics or ad requests in Network
2 Click reject or close, then browse several pages Still no non-essential cookies, local storage keys or tracker requests
3 Accept one category only Only that category's scripts and cookies appear
4 Accept all, reload Chosen tools now load, and the choice persists
5 Reopen settings and withdraw Scripts stop on the next load; cookies are cleared where possible

Repeat the test on a post with an embedded video, on your contact form page and, if you run a shop, at checkout. Embeds and form plugins are where leaks hide. Also check the mobile layout, since banners often cover the reject button on small screens.

Save screenshots of the Network tab results with a date. That gives you your own evidence if you are ever asked how you verified the setup.

Current legal status and what to do next

The rules are still the ones above. The ePrivacy Regulation, which was meant to replace the 2002 directive, was withdrawn in 2025, and the Digital Omnibus proposal is not law. One part of that proposal would fold the Article 5(3) cookie-consent rule into the GDPR, but it is only a proposal. Check the current status on EUR-Lex or the European Commission site before you change your approach.

Bottom line: treat consent as a technical control you can test, not a notice you can display. Fix the inventory first, then block scripts before consent, then keep a record, then retest after every plugin or theme change.

Cookies are one part of a wider compliance picture for EU-facing sites. If you also maintain WordPress products or plugins sold in the EU, the EU CRA guide for WordPress owners explains the security side, and the free Erdo CRA Compliance plugin helps you cover its practical requirements. Hardening your site also reduces what attackers can do with the data you collect, as covered in the WordPress security hardening checklist.

Frequently asked questions

Do I need a cookie banner if most of my visitors are outside the EU?
You need one if your site uses non-essential cookies and has visitors from regions with consent rules, such as the EU. Where your visitors are matters more than where you are based. If you serve EU visitors at all, a compliant banner is the safer default.
Are login or shopping cart cookies exempt from consent?
Yes. Cookies that are strictly necessary for a service the visitor requested are exempt. Examples include a shopping cart cookie, a login session cookie, a load balancing cookie and a bot protection cookie such as __cf_bm. Still, mention them in your cookie policy so visitors can see what is set.
Is legitimate interest enough for analytics cookies?
No. Under Article 5(3) of the ePrivacy Directive, legitimate interest cannot justify placing or reading cookies on a device. Analytics tools that set identifiers need the visitor's consent first. Some privacy-friendly setups avoid storing anything on the device, but check that claim carefully for each tool you use.
Are pre-ticked boxes valid consent?
No. The Court of Justice decided in Planet49 (C-673/17) that pre-ticked checkboxes cannot give valid consent under the ePrivacy Directive. Optional categories must start off, and the visitor must take a clear action to switch them on, in line with GDPR Article 4(11).
Do tracking pixels and local storage need consent too?
Yes. EDPB Guidelines 2/2023 explain that Article 5(3) is technology-neutral. It also covers tracking pixels, tracking links, local storage and certain forms of fingerprinting. If a tool stores or reads information on the visitor's device for a non-essential purpose, treat it like a cookie.