[00] Subset Opt-Out, Guide
Show a cookie banner only to EU and UK visitors in WordPress
Show an opt-in cookie banner to visitors in the EU and UK, and a privacy choices link to US visitors, on one WordPress site without breaking your page cache.
- Published
- Fix uses
- Subset Opt-Out Pro
- Reading time
- 5 min
Two rules that point in opposite directions
The EU and UK rules are opt-in. Before you store or read non-essential cookies on a visitor’s device, you need their consent. US state privacy laws are opt-out: your scripts can run by default, and a visitor can tell you to stop selling or sharing their data. A site with visitors in both places has to treat them differently, or pick the stricter rule for everyone.
This is general background, not legal advice, so check with a lawyer which rules apply to you.
What the EU and UK ask for
In the EU, the rule for cookies comes from the ePrivacy Directive. The EU’s Your Europe guidance on online privacy (opens in a new tab) says cookies used for behavioural advertising, analytics or market research need the user’s consent. Cookies strictly necessary for a service the person asked for, such as a shopping basket or a login, don’t. The same page says withdrawing consent has to be no harder than accepting cookies.
In the UK, the rule is in the Privacy and Electronic Communications Regulations (PECR). The ICO’s page on cookies and similar technologies (opens in a new tab) says consent has to be a clear positive action, and that you can’t set non-essential cookies on your home page before the visitor has agreed.
The UK has since loosened the rule for analytics. Under the Data (Use and Access) Act 2025, the ICO’s guidance on the exceptions (opens in a new tab) allows cookies used only for statistics about how your site is used, if you tell visitors and give them a free way to object. The same guidance says the exception doesn’t cover online advertising, which still needs consent.
In practice, that means a banner shown before any advertising script runs, with a way to refuse and a way to change the choice later.
What US state laws ask for
Most US state privacy laws let you run ad trackers by default. A visitor can opt out of the sale or sharing of their personal information, usually through a link on every page, and you have to honour it. Several states, including California, also require you to treat a Global Privacy Control (GPC) signal from the visitor’s browser as an opt-out.
What the law requires covers the opt-out model in more detail, and US state privacy laws for WordPress sites compares the states, with a source for each.
Asking everyone first
The fix that needs no location data is to show the opt-in banner to every visitor, wherever they are. It meets the stricter rule everywhere. The cost is that you lose analytics and ad data from US visitors who never click Accept all, even though their state’s law only required an opt-out. You still need the US opt-out link and GPC handling alongside it. If that cost is too high, you need to know where each visitor is.
Telling visitors apart without breaking the cache
Most WordPress hosts and CDNs can tell your site the visitor’s country in a request header. Cloudflare sends CF-IPCountry to your server by default, and its Add visitor location headers (opens in a new tab) Managed Transform adds the region too.
The catch is page caching. If PHP reads that header and prints the banner for EU visitors only, the cache stores whichever version it saw first. A US visitor can then get the EU page, or an EU visitor the US one. The decision has to happen after the cached page reaches the browser.
How Subset Opt-Out Pro does both
Subset Opt-Out handles the US side in the free plugin: the Your Privacy Choices link, GPC, and holding back ad trackers for visitors who opt out. Pro adds opt-in mode, which shows a consent banner with Accept all, Reject all and Customize. Nothing optional runs until the visitor accepts.
To limit the banner to some regions, open Subset → Opt-Out, go to the Regions tab and find By region. The choices are:
- European Union and European Economic Area (EU/EEA): the 27 EU countries plus Iceland, Liechtenstein and Norway.
- United Kingdom.
- Switzerland, a separate choice because it’s usually treated as opt-out.
- Other countries, where you type two-letter codes, such as
JE, GG, IMfor Jersey, Guernsey and the Isle of Man.
Click Save opt-in settings. Visitors in the chosen countries get the banner. Everyone else gets the opt-out behaviour, with the privacy choices link and GPC.
If your site handles health, children’s or other sensitive data, the Sensitive data setting on the same tab makes every visitor opt-in, and the regions then make no difference.
On the same tab, State-aware behavior can show the opt-out link and notice bar only to visitors in the US states you select. Visitors known to be outside the US don’t see them unless you tick Also show them to visitors known to be outside the United States.
Where the country comes from
Pro reads the country from a header your host or CDN adds: Cloudflare, CloudFront, Vercel, Netlify, a generic X-Geo-Country header, or the GEOIP_* variables some hosts set. It reads no IP address and makes no third-party lookup.
The Regions tab shows the country it saw on your own request, and which provider’s header it came from. If it says no location header was found, your host or CDN needs a setting changed. On Cloudflare, that’s the Managed Transform above.
When no country is found
Pro fails closed. A visitor whose country can’t be told is treated as being in an opt-in region and sees the banner. That also applies while the location is loading on the first page of a visit, and when the lookup takes longer than three seconds.
Without a location header, every visitor gets the banner, including your US visitors. Check the Regions tab after you turn regions on.
Why your page cache keeps working
Every visitor gets the same HTML. The server prints opt-in for everyone, and a script in the browser relaxes it to opt-out for a visitor known to be outside your regions. Held scripts are then released without a reload, and the banner waits for the answer so US visitors don’t see it flash.
The browser gets its country from a small REST endpoint on your own site, once per session. That response is sent with no-store, so no cache keeps it, and the browser remembers the answer for an hour. Your page cache needs no changes. Getting started covers installing Pro and the caching plugins Subset Opt-Out works with.