ConsentLayer hero with logo and the headline 'How to Set Up a GDPR-Compliant Cookie Banner' on a dark background, consentlayer.com at bottom

How to Set Up a GDPR-Compliant Cookie Banner

A GDPR-compliant cookie banner holds every non-essential tracker until the visitor opts in, with reject next to accept. The visitor can change the choice later, and each decision is recorded so you can show it to the client. On a client site you set this up with one prompt to your agent or from the dashboard, and the banner holds known trackers until the visitor consents, then runs the held scripts.

What GDPR compliance means for a cookie banner

Under EU law, a website may store or read a non-essential cookie on a visitor’s device only after the visitor agrees, and that agreement has to meet the GDPR’s standard for consent. Strictly necessary cookies, such as the session cookie that keeps a cart or a login working, need no consent. Analytics, advertising pixels, chat widgets, and embedded video or maps all count as non-essential, so they wait.

A banner meets the standard when it does these things on the live site:

  • It blocks non-essential cookies and scripts until the visitor clicks a choice. Scrolling, closing the banner, or continuing to browse doesn’t count as consent.
  • It offers a reject option that is as easy to use as accept, with no pre-ticked boxes, and it lets the visitor choose purpose by purpose.
  • It lets the visitor withdraw consent later, and withdrawing must be as easy as giving it.
  • It keeps a record of each decision, so the site owner can show that consent was given.

What a GDPR-compliant cookie banner must do

The rule that a site must ask before it stores a cookie comes from the ePrivacy Directive, and the GDPR sets what valid consent is: freely given, specific, informed, and unambiguous, given by an active click. Tie each requirement to something you can check on the client’s live site, because a banner that looks right in a screenshot can still let every tracker through.

Trackers wait until the visitor chooses

When Google Analytics or the Meta Pixel fires before the visitor clicks, the banner is only decoration and the client’s site collects data without consent. Take a client site that runs Google Analytics through Google Tag Manager, plus a Meta Pixel that the client’s ad agency pasted into the footer. With no blocking, both send requests on the first page load while the banner is still on screen, so the visitor’s click changes nothing.

Once the banner is in place, the first load on that same site shows no request to either host, and the requests start only after the visitor accepts.

Reject sits next to accept, category by category

Check that the first screen offers reject with the same weight as accept, and that a visitor can open the preferences modal and accept or reject Statistics and Marketing one by one. Regulators judge the design as well as the wording, and the cookie banner designs that regulators reject share a few habits you can spot in a minute:

  • A large accept button next to a small grey reject link, which makes one choice look like the default.
  • Reject hidden behind a “Manage settings” click, so rejecting takes two clicks while accepting takes one.
  • Category toggles that arrive already switched on in the preferences modal.

The visitor can change the choice, and the change is recorded

Check that a visitor who withdraws Marketing loses those cookies and leaves a log entry the client can show an auditor. Withdrawing a category deletes its cookies and records the change in the consent log, so run this check once per client site:

  1. In a private window, accept all categories. In DevTools, open the Application tab and note the Marketing cookies under Cookies.
  2. Reopen the preferences modal and switch Marketing off.
  3. Reload the page. The Marketing cookies should be gone from the Application tab.
  4. Open the consent log in the dashboard and find the entry for that change, with Marketing now rejected.

What you need before you start

  • Edit access to the client site’s <head>, either through the repo or through the builder’s head-code setting.
  • A list of the tools the client runs: analytics, ad pixels, chat widgets, and video or map embeds.
  • Your agent, connected to ConsentLayer, or a dashboard login.

Clients often add pixels through an agency or a plugin without telling you. Treat their list as a starting point, and let the scan in step 1 fill the gaps.

Set up the banner step by step

1. Scan the client site and create the banner

Send this prompt to your agent, and replace the placeholder with the domain of the site you are setting up (your own or a client’s):

"Set up a GDPR cookie banner for <your-domain> and give me the install snippet."

What happens: your agent calls setup_site, one tool call that creates the site and scans it. It then configures consent categories and returns the install tag with a real project key. The full agent flow is in the guide to set up consent by telling your coding agent.

Without an agent: sign in to the dashboard and add a site with the client’s domain. When the scan finishes, copy the tag it shows.

2. Add the tag to <head> before every other script

Send this prompt to your agent from inside the client site’s repo:

“Add the ConsentLayer tag to the head of every page, above Google Tag Manager and every other script.”

What happens: your agent edits the layout or template that renders <head> and puts the tag first. The tag must load synchronously, with no defer and no async, before other scripts, because a tracker that runs first cannot be held. For a React or Next.js app, the React cookie consent guide shows how to put it in the document head, not inside a component that mounts after hydration. You’ll then see the tag in the page source above analytics and pixels.

Performance plugins and build settings that add defer to every script on the page will add it to this tag too, so exclude the tag from them.

Without an agent: paste the tag into the builder’s head-code setting or the site’s main template as the first script in <head>.

3. Deploy and run the installation check

Deploy the change and purge the page cache and any CDN cache. Then send this prompt:

“Run the installation check for the client site.”

What happens: your agent calls check_installation, which fetches the live homepage and confirms the tag is in <head> without defer or async. You get a pass that confirms the tag is live on the real domain. Skip the purge and the check can read stale cached HTML, which reports the tag as missing even though the deploy worked.

Without an agent: open the site in the dashboard and run the installation check there after the deploy.

Check that trackers wait for consent

The installation check proves the tag is in place, and the Network test proves the blocking works. Run it in this order, because a choice you make in one test is stored and spoils the next one:

  1. Open a private window and open DevTools before you load anything. In the Network tab, turn on Preserve log.
  1. Load the client’s homepage and do not click the banner. Filter the requests by google-analytics, facebook, and any ad host on the client’s list. None of them should appear.
  1. Click reject and visit two more pages. The same hosts shouldn’t send anything.
  1. Close that window and open a new private one, so the stored reject does not carry over.
  1. Open the preferences modal and accept Statistics only. Analytics requests start now, while Meta and the other ad hosts stay silent.

When all five steps pass, blocking works with the tag live in <head> on the real domain, and the banner records every decision.

Common problems and fixes

A script the scanner did not recognize keeps running

This shows up in step 2 of the Network test as a request to a host you did not expect, often a booking widget or an inline snippet a previous developer left in a template.

Scripts the library does not recognize go to a review queue, where they are approved with a category and blocking rule, or dismissed. Ask your agent “Show me the unrecognized scripts on the client site”, then approve the one that sends requests with the right category and blocking on. Run the Network test again in a new private window afterwards.

A YouTube video or Google Map sets cookies on page load

An embedded iframe loads its own page from the video or map host, so it can set cookies before the visitor touches the banner. Embeds from YouTube, Vimeo, DailyMotion, Google Maps, reCAPTCHA, X, and Instagram are replaced with a click-to-load placeholder until consent. To fix it, confirm the placeholder shows in a fresh private window.

The click-to-load placeholder is for embeds from those hosts. Replace an embed from a host outside that list with a plain link or a static image.

Going further

  • Visitors from California need a different set of controls, a Do Not Sell or Share link and Global Privacy Control, which the guide to a CCPA cookie banner on a client site covers.
  • For the next site, run the same three prompts and the same Network test, so every client site on your roster gets the same setup and the same proof.

FAQ

Do I need Google Consent Mode v2 as well as a GDPR cookie banner?

Yes, if the client runs Google tags, because Consent Mode is how those tags learn the visitor’s choice. The banner installs a gtag stub with all Consent Mode signals denied except security_storage, with a 500 ms wait_for_update, so Google tags start in the denied state.

What counts as proof of consent under the GDPR?

Each consent 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.

How often does a GDPR cookie banner have to ask again?

Consent lasts 365 days by default, and after that the visitor sees the banner again. Ask sooner when the client adds a tool for a new purpose, since the earlier answer did not cover it.

Is a cookie banner the same as a cookie policy?

No. The banner collects a choice, and the policy is the page that explains which cookies the site uses and why. ConsentLayer generates a hosted cookie policy from the site’s categories, services, and cookies, and rebuilds it when they change.

How ConsentLayer handles a roster of client sites

Connect ConsentLayer to your agent once, as an MCP server, and sign in through your browser, so every later prompt acts on your organization and its client sites. From then on, each new client site is one prompt to set up and one prompt to check.

To see where each site stands, ask your agent “List my sites with their compliance scores.” Each site comes back with a score out of 100, with the open items named, so you know which client site still needs a fix before you report to that client. On the Studio and Agency plans, one pageview allowance covers every site in the organization, so a quiet site and a busy one draw from the same pool.

ConsentLayer gives you technical enforcement and audit logs, not legal advice, and the compliance score measures the technical setup, not legal sufficiency. The steps in this guide aren’t legal advice either, so ask the client’s lawyer to confirm that the banner wording and categories fit that client’s business.

Set up the banner on your first client site with the Quick Start guide.