Skip to content

No. 107Security7 min read1,904 words

GDPR cookie consent: what your website must do

When a website needs cookie consent under the ePrivacy Directive and GDPR, what makes consent valid, the banners regulators reject, and a build checklist.

Written by
Lazy Devs
Published
Updated
Sources
Cited inline

Key takeaways · 05

The short version

  1. 01In the EU, Article 5(3) of the ePrivacy Directive requires consent before a site stores or reads information on a visitor's device, unless it is strictly necessary for a service the visitor asked for. It covers any information, not only personal data.
  2. 02Valid consent means a clear affirmative action. Pre-ticked boxes, silence, inactivity and scrolling do not count, and withdrawing consent must be as easy as giving it.
  3. 03A vast majority of EU regulators in the EDPB's cookie banner taskforce treat an Accept button without a Reject option on the same layer as an infringement, and reject cookie walls that make access conditional on consent.
  4. 04Google Consent Mode passes the visitor's choice to Google tags. It does not collect consent for you, so you still need a compliant banner and a default of denied.
  5. 05Since 5 February 2026 UK law has an exception for first-party statistics used to improve a service, provided visitors are told and can object for free. Advertising and cross-site tracking still need consent.
On this page · 10

Cookie consent is the part of EU privacy law that every website team touches, and the part most often built wrong. The rule is simple to state: before your site stores or reads anything on a visitor's device that is not strictly necessary, you need their consent, and that consent has to be real. The details of what "real" means come from the ePrivacy Directive, the GDPR, a Court of Justice ruling and guidance from European regulators.

This guide covers what needs consent, what makes consent valid, the banner patterns regulators have called out, how Google Consent Mode fits in, the UK's newer rules, and the checklist we use when we build or fix a consent flow. Every legal point links to its official source. It is an engineering guide, not legal advice.

The rule: Article 5(3) of the ePrivacy Directive

The core obligation is in Article 5(3) of the ePrivacy Directive (2002/58/EC, as amended). Storing information, or gaining access to information already stored, on a user's device is "only allowed on condition that the subscriber or user concerned has given his or her consent, having been provided with clear and comprehensive information" about the purposes.

Two exemptions apply, both narrow:

  • Transmission: storage "for the sole purpose of carrying out the transmission of a communication over an electronic communications network".
  • Strictly necessary: storage that is "strictly necessary in order for the provider of an information society service explicitly requested by the subscriber or user to provide the service".

Three things follow for engineers:

  1. It is not only about cookies. The rule covers any storage or access on the device: cookies, localStorage, pixels that read identifiers and similar techniques.
  2. It is not only about personal data. In Planet49 (C-673/17), the Court of Justice noted that Article 5(3) refers to "the storing of information" without specifying that it must be personal data.
  3. "Strictly necessary" means necessary for what the visitor asked for. A login session, a shopping basket or a security token qualifies. Analytics, advertising and most third-party embeds do not.

Article 5(3) is implemented in each member state's national law and enforced by national authorities, so wording and penalties vary by country.

The ePrivacy Directive borrows the GDPR's definition of consent. Article 4(11) GDPR defines it as "any freely given, specific, informed and unambiguous indication of the data subject's wishes by which he or she, by a statement or by a clear affirmative action, signifies agreement".

The rest of the GDPR and the case law turn that into concrete rules:

  • No pre-ticked boxes. Recital 32 of the GDPR says "silence, pre-ticked boxes or inactivity should not therefore constitute consent". Planet49 confirmed that consent "is not validly constituted" when it relies on "a pre-ticked checkbox which the user must deselect to refuse his or her consent".
  • Tell people how long and who. Planet49 also held that the information given must include "the duration of the operation of cookies and whether or not third parties may have access to those cookies".
  • Scrolling is not consent. The EDPB's Guidelines 05/2020 on consent say scrolling or swiping through a page "will not under any circumstances satisfy the requirement of a clear and affirmative action".
  • No cookie walls. The same guidelines say "access to services and functionalities must not be made conditional on the consent of a user" to storing or accessing information on their device.
  • Withdrawal as easy as consent. Article 7(3) GDPR gives people the right to withdraw consent at any time and says "it shall be as easy to withdraw as to give consent".
  • Be able to prove it. Article 7(1) GDPR requires the controller to be able to demonstrate that consent was given.

Where processing breaches the GDPR's conditions for consent, Article 83(5) allows fines of up to EUR 20 million or 4% of total worldwide annual turnover, whichever is higher.

The banner patterns regulators reject

In January 2023 the EDPB published the report of its Cookie Banner Taskforce, which coordinated how national authorities handled complaints about cookie banners filed by the privacy group NOYB. Its positions are a minimum common view, not a full list, but it is the clearest public statement of which designs regulators treat as non-compliant.

  • No Reject on the first layer. "A vast majority of authorities considered that the absence of refuse/reject/not consent options on any layer with a consent button of the cookie consent banner is not in line with the requirements for a valid consent and thus constitutes an infringement." If Accept is on the first screen, Reject belongs there too.
  • Pre-ticked category boxes. Pre-ticked boxes in the settings layer "do not lead to valid consent".
  • Unreadable alternatives. No universal colour standard is imposed, but a refuse option whose text contrast is "so minimal that the text is unreadable to virtually any user" was called manifestly misleading.
  • Legitimate interest for cookies. The taskforce confirmed that "the legal basis for the placement/reading of cookies pursuant to Article 5 (3) cannot be the legitimate interests of the controller".
  • "Essential" labels on non-essential cookies. Classifying analytics or advertising cookies as strictly necessary does not exempt them, and site owners are expected to maintain the list and be able to demonstrate why each "essential" cookie is essential.
  • No way back. Sites should offer an easily accessible way to withdraw consent at any time, "such as an icon (small hovering and permanently visible icon) or a link placed on a visible and standardized place". The exact mechanism is not mandated, but withdrawing must be as easy as consenting.

Most sites that need a banner run Google tags, and Google's consent mode is how those tags learn the visitor's choice. It is worth being precise about what it does:

  • It defines consent types, including ad_storage, ad_user_data, ad_personalization and analytics_storage. Google added two parameters in November 2023, ad_user_data and ad_personalization, known as consent mode v2.
  • You set a default state before any measurement (gtag('consent', 'default', {...})) and update it when the visitor chooses.
  • Basic mode blocks Google tags until the visitor interacts with the banner. Advanced mode loads the tags with your defaults and, when consent is denied, sends cookieless pings that Google uses for modelling.

Consent mode does not collect consent. It relays a decision your banner has already collected, so the banner still has to meet every rule above. Whether advanced mode's cookieless pings fit your interpretation of the law is a question for your legal adviser before you choose it over basic mode.

On this website, a small script sets every Google consent type to denied before Google Analytics loads, and analytics storage is only granted when a visitor presses Accept. Accept and Decline sit side by side on the first layer.

The UK: PECR and the 2026 exceptions

The UK equivalent is regulation 6 of the Privacy and Electronic Communications Regulations (PECR). The Data (Use and Access) Act 2025 inserted a new Schedule A1 into PECR, in force from 5 February 2026, which lists situations where consent is not needed. Alongside the familiar transmission and strictly necessary exceptions, it adds:

  • Statistics to improve your service or website. Storage or access whose sole purpose is to collect statistics about how the service or website is used, "with a view to making improvements". The information may only be shared with someone helping you make those improvements, visitors must get "clear and comprehensive information" about the purpose, and they must be given "a simple means of objecting, free of charge".
  • Appearance and preferences. Storage that only adapts how the site looks or works to the visitor's preferences.
  • Emergency assistance. Narrow cases where a person is requesting emergency help.

This is narrower than "analytics no longer needs consent". Advertising, cross-site tracking and analytics shared with a provider for its own purposes still need consent, and UK GDPR still applies to any personal data collected. The ICO's guidance on storage and access technologies explains how the regulator applies the exceptions. If you serve both the UK and the EU, design for the stricter EU rule.

Engineering checklist

What we check when we build a consent flow or audit an existing one:

  • Inventory everything stored on the device. Cookies, localStorage, sessionStorage and pixels, first and third party, on every template. Record purpose, duration and who can read it.
  • Classify honestly. Only what the visitor's requested service cannot work without is strictly necessary.
  • Nothing non-essential before consent. Tags load with storage denied, or not at all, until the visitor chooses. Verify in a fresh browser profile with the network tab open.
  • Accept and Reject on the first layer, equally easy. Same size, same number of clicks, readable contrast for both.
  • No pre-ticked categories in the settings layer.
  • No cookie wall. The site works when consent is refused.
  • Durations and third parties disclosed in the banner's detail layer or cookie policy, as Planet49 requires.
  • A persistent way to change your mind, such as a "Cookie settings" link in the footer, that reopens the choices and removes non-essential cookies on withdrawal.
  • Consent recorded with timestamp, choices and banner version, so you can demonstrate it.
  • Consent mode defaults set before any Google tag fires, and updated from the banner's decision.
  • Re-ask when purposes change, for example when a new vendor is added.
  • Re-test after every release that adds a script. Marketing tags are the usual way compliant sites drift out of compliance.

Common mistakes

  • Trusting the vendor default. Consent platforms ship with configurable layouts; the default is not always the compliant one. Check the first layer yourself.
  • Firing tags "just for the first page view". Anything that stores or reads before consent breaches Article 5(3), even once.
  • Hiding Reject behind "Manage preferences". That is exactly the first-layer pattern regulators flagged.
  • Forgetting embeds. Video players, maps and social widgets often set their own cookies. Load them behind a click-to-load placeholder.
  • No withdrawal path. A banner that never comes back after the first choice leaves visitors with no easy way to withdraw.
  • Treating consent as a launch task. Every new script can break it. Put the consent check in your website launch checklist and your release process.

Third-party scripts are also a performance problem: in our Forbes Cloud 100 homepage speed study, the median homepage contacted 20 or more third-party domains. A consent audit is a good moment to remove the ones nobody uses. For the measurement side, see product analytics without creeping on users.

This article explains the rules as published in the official texts linked above, as of November 2026. National implementations of the ePrivacy Directive differ, and your obligations depend on what your site does and where your visitors are. Have a qualified privacy lawyer review your consent setup.

Sources

This guide is part of our compliance and risk guides, alongside the European Accessibility Act explainer and our web application security checklist. If you need a consent flow built or fixed as part of a website redesign or ongoing maintenance and support, tell us about your site.

FAQ · 05 questions

Frequently asked questions

Do I need cookie consent for Google Analytics in the EU?

In practice, yes. Analytics cookies are not strictly necessary to provide a service the visitor asked for, so Article 5(3) of the ePrivacy Directive requires consent before they are set or read. Load analytics with storage denied by default and only grant it after the visitor accepts.

Is a cookie banner with only an Accept button legal?

Regulators in the EDPB Cookie Banner Taskforce said a vast majority of authorities consider a banner without a refuse or reject option on any layer that has an Accept button to be an infringement. Put Reject next to Accept, with equal prominence.

Do strictly necessary cookies need consent?

No. The ePrivacy Directive exempts storage that is strictly necessary to provide a service the visitor explicitly requested, such as a session or a shopping basket. Regulators warn that labelling analytics or advertising cookies as essential does not make them exempt.

Can I block my website until visitors accept cookies?

Not under EDPB guidance. The EDPB's consent guidelines say access to services and functionalities must not be made conditional on consent to cookies, which is what a cookie wall does.

Does the UK still require cookie consent?

Mostly. The Privacy and Electronic Communications Regulations still require consent, but since 5 February 2026 there are new exceptions, including first-party statistics used to improve your service or website, as long as visitors get clear information and a simple, free way to object.

Related service

API & Backend Engineering

Secure, well-documented APIs that scale.

Learn more

Next step

Want this built right?

This is the work we do every day. Tell us what you are building and we will show you exactly how we would ship it.

First reply
Within 1 business day
Typical start
1–2 weeks
Pricing
Fixed price per phase
You own
All code and accounts