Prompt
How do I configure geo-targeted cookie banners for GDPR and CCPA?
Latest observation
To configure geo-targeted cookie banners for GDPR and CCPA/CPRA, the basic idea is:
- Show a consent banner to users in regions where consent is required or expected
- Tailor the banner behavior and wording by region
- Prevent non-essential cookies from loading until the user has made a choice
- Store and honor the user’s preference
Here’s a practical way to set it up.
1) Decide which regions get which experience
Typical rule set:
GDPR / UK GDPR / EEA
For users in the EU/EEA/UK:
- Show a consent-first banner
- Block analytics, advertising, and other non-essential cookies until consent
- Provide Accept, Reject, and Preferences options
- Consent must be:
- informed
- freely given
- specific
- unambiguous
- revocable
CCPA / CPRA (California)
For California users:
- Show a banner that includes a “Do Not Sell or Share My Personal Information” option if applicable
- If using advertising/retargeting or sharing data for cross-context behavioral advertising, offer an opt-out
- A “cookie consent” popup is not always legally required in the same way as GDPR, but a privacy/opt-out notice is commonly needed
Other regions
You can:
- show a minimal banner, or
- show no banner unless required by your policy or local law
2) Use geo-detection to route users into the right banner logic
Common approaches:
Server-side geo detection
Use the request’s IP address via:
- CDN/edge location headers
- GeoIP database
- cloud provider geo headers
This is usually the best place to decide which banner to render.
Client-side detection
Less reliable. Usually only use it as a fallback.
Best practice
Use server-side geo detection to set a region flag like:
region = "eea"region = "uk"region = "ca"region = "rest-of-world"
Then your frontend loads the appropriate consent UI and cookie rules.
3) Block tags until consent is known
For GDPR regions, don’t load:
- Google Analytics
- Meta Pixel
- Google Ads
- Hotjar
- other marketing/analytics scripts
until consent is granted.
Ways to do this:
- Use a Consent Management Platform (CMP) such as OneTrust, Cookiebot, Didomi, Axeptio, etc.
- Or implement a custom consent gate that only injects scripts after approval
If you use Google tools, enable:
- Google Consent Mode v2
- Set default consent to denied in EEA/UK until the user chooses
4) Configure the banner by region
GDPR banner configuration
Recommended settings:
- Buttons:
- Accept all
- Reject all
- Customize
- Categories:
- Necessary
- Analytics
- Marketing
- Preferences
- Default state:
- Only necessary cookies active
- No pre-checked boxes
- Clear cookie policy link
- Easy withdrawal of consent later
CCPA banner configuration
Recommended settings:
- “Do Not Sell or Share My Personal Information”
- Link to privacy policy
- If applicable, link to a Global Privacy Control (GPC) compliant opt-out flow
- Do not force acceptance as a condition of use unless legally allowed
For California users, your banner may also include:
- “Manage privacy choices”
- “Opt out of sale/share”
- “Reject non-essential cookies” if you want a unified experience
5) Store consent states separately
You’ll typically want to store:
- user region
- consent status by category
- timestamp
- policy version
- source of consent
Example consent states:
necessary: trueanalytics: falsemarketing: falsepreferences: true
Store this in:
- a first-party cookie
- localStorage
- server-side profile if the user is logged in
Make sure the banner reappears if:
- consent expires
- policy version changes
- user clears cookies
6) Respect Global Privacy Control for California
If you have California users, support GPC (Global Privacy Control):
- If the browser sends a GPC signal, treat it as an opt-out of sale/share where required
- Ensure your backend and CMP can detect and honor it
This is especially important for CCPA/CPRA compliance.
7) Make the logic look something like this
High-level flow:
On page load:
detect user region
check existing consent
if region = EEA/UK:
show GDPR banner
block non-essential tags until choice
else if region = California:
show CCPA/CPRA notice
honor opt-out / GPC
else:
follow default policy
optionally show minimal notice
8) Example implementation pattern
Frontend logic
- Render banner based on
region - Load scripts only after consent
Pseudo-code:
if (region === "eea" || region === "uk") {
disableAnalytics();
showGDPRBanner();
} else if (region === "ca") {
showCCPABanner();
if (gpcSignalDetected) {
optOutOfSaleShare();
}
} else {
loadDefaultScripts();
}
Script loading gate
function loadAnalytics() {
if (consent.analytics) {
// inject analytics script
}
}
9) Keep the privacy policy and cookie policy aligned
Your banner should match:
- what cookies you actually use
- what vendors you share data with
- how users can change their preferences later
If your policy says “analytics is optional,” the banner must allow rejecting it.
10) Test by geography
Test from:
- EU IPs
- UK IPs
- California IPs
- non-regulated regions
Verify:
- correct banner appears
- no non-essential scripts load before consent
- opt-out works
- consent is saved and respected on return visits
- GPC is honored for California
11) Common mistakes to avoid
- Showing only an “OK” button in GDPR regions
- Loading analytics before consent
- Hiding the reject option
- Bundling necessary and non-necessary cookies together
- Ignoring California opt-out rights
- Not providing a way to change consent later
- Not recording consent version/timestamp
12) If you want the easiest setup
Use a CMP with geo-targeting built in. Most major CMPs let you:
- define regions
- customize banner text and button behavior
- block scripts automatically
- support Consent Mode and GPC
- maintain audit logs
If you want, I can also provide:
- a CMP configuration checklist,
- sample code for a custom banner, or
- a region-to-banner decision table for GDPR vs CCPA.