What Is a Cookie Banner and How Does It Work

What Is a Cookie Banner and How Does It Work

A cookie banner is the notice a website shows on a visitor’s first page view, asking them to accept or reject cookies and trackers the site doesn’t need. A working banner also holds those trackers until the visitor chooses and records the decision, because buttons alone don’t stop a script.

What a cookie banner is

It’s also called a cookie consent banner, a consent pop-up, or a cookie notice. It asks only about the optional trackers, such as analytics and ad pixels, not the login or cart cookies that the site needs to work.

Every working banner has two separate parts. The first is the notice the visitor sees, with accept and reject buttons and a way to change the choice later. Behind it, the banner script holds trackers until the visitor decides, then saves the decision. On its own, the notice does nothing to a tracker, because a Google Analytics or Meta Pixel tag runs as soon as the browser reads it unless something stops it.

A site is protected only when both parts run on the real domain visitors use. The banner script has to be live on production, not staging, and each decision has to be stored.

Why a cookie banner matters for the client sites you build

When a pixel fires before the banner, the letter goes to the client, who calls you because you built the site. Demand letters about pixels that fire before consent can start from one Meta Pixel. GA4 and Google Ads also read consent signals, and a wrong one costs the client measured conversions. That’s why I add the banner before any tracker goes live.

When a site needs a cookie banner

The trigger is the trackers on the site, not the business size. A five-page site with GA4 needs one for visitors from:

  • The EU and UK, where ePrivacy rules and GDPR require prior opt-in consent for non-essential cookies.
  • California and other US states, which require notice at collection, an opt-out of sale or sharing, and respect for Global Privacy Control. See how to set up a CCPA cookie banner on a client site.
  • Brazil, where the LGPD needs a legal basis, usually consent, for marketing trackers.

How a cookie banner works

It holds trackers until the visitor chooses

Analytics and ad trackers wait from page load until the visitor clicks. The banner script runs them after the visitor accepts. Until then they’ve sent nothing, so a reject leaves no data to clean up.

It asks for opt-in or opt-out, and reads the browser’s own signal

A visitor whose browser sends Global Privacy Control is treated as a reject. The banner records a reject and sets the Do Not Sell flag. Instead of a prompt, the visitor sees a short notice. GDPR is opt-in, and optional trackers stay off until the visitor agrees. California is opt-out, and GPC is that opt-out.

It passes the choice to Google tags

Which consent category turns on which Google signal decides whether the client’s GA4 and Ads data match the visitor’s choice. Google Consent Mode v2 carries the choice to Google’s tags, but only a banner can supply it:

  • Essential turns on functionality_storage and security_storage.
  • Statistics turns on analytics_storage.
  • Marketing turns on ad_storage, ad_user_data, and ad_personalization.

It records each decision

A client forwards a visitor’s email saying they never agreed to tracking. Their 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. Send the snapshot first, because it shows that day’s wording.

Common misunderstandings about cookie banners

A banner with buttons is the whole job

A banner made from a prompt or a free script often shows buttons while trackers still fire, and nothing connects the buttons to the trackers. One case is a WooCommerce store whose Tag Manager adds a chat widget after load. ConsentLayer fully blocks late trackers through a MutationObserver and interception of createElement, appendChild, insertBefore, and src changes. Treat a banner as a mock-up until the network tab shows no pixel request before the click. See cookie banner examples and the designs regulators reject.

A banner makes the site compliant

A banner is technical enforcement plus an audit log. Legal sufficiency is the client’s lawyer’s call, and the privacy policy counts too. ConsentLayer’s compliance score checks the technical setup and gives a score out of 100, with the open items named.

Cookie banner FAQ

Do I need a cookie banner if I only use Google Analytics?

For EU and UK traffic you do, since GA4 sets cookies. ConsentLayer’s 18 built-in blocking patterns cover Google Analytics and gtag, alongside Meta, Google Ads, TikTok, LinkedIn, Microsoft Clarity, and Hotjar.

Does a cookie banner need a reject button?

For European visitors, refusing should be as easy as agreeing. Visitors can also open a preferences modal and accept or reject each category, so someone can allow statistics only.

What is the difference between a cookie banner and a consent management platform?

The banner is the visible piece of a consent management platform, which also finds the trackers to hold. ConsentLayer’s scanner checks up to 10 URLs per scan and matches results against its service library. More on choosing a consent management platform for client sites.

How often should I update a cookie banner?

Change it when a new service joins the site. Bumping the consent version re-prompts every visitor, so save it for changes people must agree to again.

A cookie banner in practice

Take a client’s marketing site with GA4 and a Meta Pixel. Give your agent one prompt, with the placeholder replaced by your own or your client’s domain:

Set up cookie consent on <your-domain>

Your agent runs setup_site, one tool call that creates and scans the site. It also configures consent categories and returns the banner script with a real project key. Paste the script into <head> above the other tags. After you deploy, ask your agent to check the install. check_installation fetches the live homepage and confirms the script is in <head> without defer or async, which catches WordPress speed plugins that defer scripts.

Without an agent, sign in through your browser and add the site in the dashboard. Copy the script into <head> and deploy. The site is protected once the live script blocks trackers and records each decision.

See how ConsentLayer holds trackers until consent and records every decision on a client site: ConsentLayer features.