Under GDPR, a visitor opts out by withdrawing consent they gave earlier, and Article 7(3) says withdrawing must be as easy as giving consent. On a client site that means a way to change the choice on every page, trackers and cookies that stop when the visitor says no, and a record of the change. With ConsentLayer, withdrawing a category deletes its cookies and writes the change to the consent log.
What a GDPR opt out means for cookies and scripts
GDPR treats cookie consent as opt-in, so on an EU site nothing that tracks a visitor may run until the visitor agrees. An opt out is the reverse move, where the visitor withdraws a consent they already gave. Article 7(3) gives them the right to do that at any time and requires withdrawal to be as easy as giving consent, so a banner that takes one click to accept can’t need an email to the site owner to undo.
Withdrawal works per purpose, so a visitor can keep the essential cookies the site needs to function and switch off analytics or advertising on their own. Once they withdraw, the site has to stop the trackers for that purpose on every later page and stop sending new data to the vendor. The cookies those trackers already set should go as well, because a leftover analytics ID lets the vendor tie the next session to the old one if a single tag slips through.
Withdrawal isn’t retroactive, so processing that happened while consent stood stays lawful and the site doesn’t have to recall data it already sent. The site does have to show that the change happened, which means keeping a record of which purpose the visitor switched off and when they did it.
What you need before you start
An opt out only works on a site that asked first, so get these three things in place before you work on the withdrawal side:
- Access to the
<head>of the client site’s template. The install tag has to load before any tracker does. On WordPress that usually means the theme or a header-scripts plugin, and on a hosted builder it means the site-wide custom code setting.
- A list of the trackers on the site and where each one loads from. Look in the theme, the tag manager container, and any plugin that adds its own pixel. Scripts the banner doesn’t know about tend to live there.
- A banner that holds trackers until consent. ConsentLayer’s banner holds the known trackers back and runs them only after the visitor consents. That gives a later withdrawal something to switch off.
If the banner design is still open, go through these cookie banner examples and the designs regulators reject first, since a Reject button that’s harder to find than Accept fails long before anyone tries to withdraw.
How to let visitors opt out, step by step
Step 1: Set up consent that asks before it tracks
Give your agent one prompt, and replace the placeholder with the domain of the client site you’re setting up:
Set up cookie consent on <your-domain>
Your agent calls setup_site, which creates and scans the site, then sets up the consent categories. It returns the install tag with a real project key. To connect the AI you already use, follow the steps to set up consent from your agent. Without an agent, sign in at app.consentlayer.com and add the site to your organization. The install tag is in the dashboard.
Expected result: an install tag that you paste as the first script in <head>, with no defer and no async. Either attribute lets the page’s other scripts run before the install tag, and that gap is exactly when a tracker drops its first cookie.
Step 2: Give visitors a choice per category
In ConsentLayer, visitors can open a preferences modal and accept or reject each category. Before you move on, read which services the scan put in each category.
Expected result: a modal that lists each category the setup created, each with its own switch.
Step 3: Keep a way to opt out on every page
A visitor who clicked Accept three months ago has to find the way back as easily as they found the banner, and by then the banner is long gone. ConsentLayer adds a floating reopen button with 4 icon choices. Visitors use it to change their decision at any time.
A footer link on its own is a weak withdrawal route. Visitors on long pages and endless blog archives rarely reach the footer. Pick the icon that reads as privacy settings on the client’s design. Two floating buttons stacked in one corner are the first thing a client asks you to fix, so keep it clear of any chat bubble.
Expected result: a reopen button on every page, blog posts and checkout included, that reopens the choice.
Step 4: Make withdrawal delete cookies and stop tracking
A withdrawal that only flips a toggle while the _ga cookie stays in the browser doesn’t honor the opt out, because the next Google tag that loads reads the old ID and carries on.
In ConsentLayer, when a visitor withdraws a category, that category’s cookies are deleted and the change is recorded in the consent log.
Expected result: after the visitor rejects a category, its cookies are gone from the browser’s storage panel and the change appears as a new entry in the consent log.
Check that the opt-out works
Run this test in a private window with dev tools open on the Application tab (Storage in Firefox) and the Network tab. Use the live domain, not a staging copy. A site only counts as protected when the install tag is live in <head> on the real domain.
| What you do | What you should see |
|---|---|
| Click Accept all, then reload the page | _ga cookies in storage and a g/collect request to Google Analytics in Network |
| Open the choice again from the reopen button | The preferences modal, with a separate switch for each category |
| Reject Statistics and save | The _ga cookies leave storage, and a new consent log entry shows Statistics rejected |
| Watch Google tags after the reject | Any collect request that still goes out carries gcs=G110 (ads granted, analytics denied) |
Test Statistics before Marketing, because Google Analytics sets its cookie on the first pageview and you can watch it leave, while ad cookies often only appear after a visitor reaches a page with the pixel. A _ga cookie that comes back after a reload means a script outside the banner’s control is still running.
Common problems and fixes
Analytics still fires after a visitor opts out
Tag the script so it waits for its category: set type="text/plain" and add a data-cl-category attribute, and the script runs only after the visitor consents to that category.
<script type="text/plain" data-cl-category="statistics">
// the analytics snippet that was hard-coded in the theme
</script>
Leave the script where it already lives and don’t move it into a tag manager during the fix. A cookie fix that also changes how the client’s analytics loads gives you two changes to debug at once. On a React or Next.js front end, you can gate scripts in a React app at the component level.
Google tags keep sending data after a withdrawal
Here the tags load correctly but don’t read consent state, so they keep sending as if the visitor had agreed. Google Consent Mode passes each category’s state into the tags, and ConsentLayer maps Essential to the functionality and security storage signals, Statistics to analytics_storage, and Marketing to ad_storage, ad_user_data, and ad_personalization. A visitor who withdraws Marketing therefore turns all three ad signals to denied.
Google’s own tags read those signals by themselves. Non-Google tags in Google Tag Manager, such as a Meta pixel in a Custom HTML tag, don’t read Consent Mode at all, so open each one’s Consent Settings and set “Require additional consent for tag to fire” with ad_storage.
Going further
When the client adds a new purpose or a new tracker, such as a session recording tool, the consent visitors gave earlier doesn’t cover it. Bump the consent version in ConsentLayer, which re-prompts every visitor. Do it in the same deploy that adds the tracker, since even a day’s gap leaves the new tool running on old consent. If you’re still settling on a tool for the rest of your roster, read about choosing a consent management platform for client sites.
GDPR opt out questions
Can an EU site use an opt-out banner instead of opt-in?
Each ConsentLayer site can run opt-in, which is the default, or opt-out. Keep opt-in for EU visitors, because GDPR consent needs a clear affirmative act and pre-ticked boxes or silence don’t qualify. Opt-out mode fits regions whose law allows it, such as California under the CCPA.
How long does a GDPR consent choice last before you ask again?
GDPR sets no fixed period, so the duration is a decision for the controller. ConsentLayer keeps a choice for 365 days by default, and a shorter period means return visitors meet the banner more often, so agree on the number with the client’s legal adviser.
Does an opt-out on the main site also cover its subdomains?
Only when consent is shared. ConsentLayer can share consent across subdomains, so a rejection made on the main domain also holds on a shop or help subdomain. Turn sharing on when one controller runs all of them for the same purposes, and leave it off when a subdomain belongs to a partner.
What should a record of an opt-out contain?
A ConsentLayer log record holds the visitor ID, country, jurisdiction, categories, per-service decisions, GPC and Do Not Sell flags, consent version, anonymized IP, user agent, locale, template, geo group, and a link to a snapshot of the banner version the visitor saw.
Doing this on the next client site with ConsentLayer
On the next client site, search for hard-coded trackers before the install tag goes live, not after the client reports a cookie that won’t go away. Search the theme files and the header-scripts setting for gtag(, fbq(, and _hsq, and tag each hit with its category. Only then paste the install tag first in <head>. To check the work, open the live domain in a fresh private window and look at storage before you click anything.
There should be no _ga, _fbp, or _hjSession cookies until you accept, and each one should leave storage when you reject its category.
Set up the banner, the reopen button, and the consent log on your next client site with the ConsentLayer quick start.
