Back to Blog
Privacy & Security

Cookie Consent Banners: How to Not Screw This Up

Got my cookie banner wrong three times before getting it right. Here is what actually complies with the law and what does not.

Jordan Lee9 min readEuropean Union
Cookie consent interface
Cookie consent interface
Tool Pairing

Use Privacy Guardian while this guide is open

Run a practical privacy review after reading security and compliance guidance.

Open Privacy Guardian
Advertisement

Geographic Note: Cookie consent requirements are primarily driven by GDPR (EU) and ePrivacy Directive. If your website serves EU residents, these requirements apply regardless of your location. Other regions have different cookie and tracking regulations - always check local laws for your target audience.

Three Failed Cookie Banners Before Getting It Right

Cookie banners are everywhere now. Annoying, mostly useless, often illegal. Yeah, illegal. Most cookie banners I see don't actually comply with privacy laws. I know because I got it wrong too. Multiple times.

Why Cookie Banners Even Exist

GDPR in Europe, CCPA in California, similar laws elsewhere. They all basically say: don't track people without permission.

Cookies are how websites track people. Therefore, ask before setting cookies.

Makes sense in theory. In practice, everyone implements it badly.

What I Did Wrong (Version 1)

First cookie banner I made:

"This site uses cookies. By continuing to browse, you accept this."

Simple, right? Also completely non-compliant.

Problems:

  • No option to decline
  • Continued browsing isn't clear consent
  • Didn't specify what types of cookies
  • Set cookies before user even saw the banner

Basically just a notice, not a consent mechanism. That's not allowed anymore.

Cookie Banner Evolution: Wrong vs Right Implementations

Cookie consent compliance analysis
Figure 1: Understanding cookie consent compliance requirements
VersionImplementation / Compliance IssuesLegal Risk / UXMy Rating
Version 1 (Wrong)Implied consent, no opt-out, pre-set cookiesHigh / Simple❌ Illegal
Version 2 (Wrong)Dark patterns, pre-checked boxes, no rejectMedium / Confusing⚠️ Non-compliant
Version 3 (Right)Accept/Reject/Customize with equal buttons, blocks cookiesLow / Clear✅ Compliant
Loading diagram...

Common Non-Compliant Patterns vs Compliant Solutions:

Non-Compliant PatternWhy It's IllegalCompliant AlternativeImpact if Caught
"By continuing, you accept cookies"Implied consent not validActive opt-in required with clear buttonsFines up to 4% revenue (GDPR)
Pre-checked consent boxesNot active opt-inAll boxes unchecked by default€50M fine (max GDPR penalty)
Big "Accept" + hidden "Reject"Dark pattern manipulationEqual visual prominenceOfficial warnings
Set cookies before consentViolation of core principleBlock all scripts until consentImmediate violation
No way to withdraw consentRequired by GDPR Article 7(3)Cookie settings link in footerComplaints to DPA
"Accept or leave" cookie wallConditional access (questionable)Allow basic access without consentLegal grey area, risky
Legitimate interest for adsMisuse of legal basisUse consent for advertisingICO guidance violation
❌ Avoid
Implied Consent
⚠️ Risky
Dark Patterns
✅ Required
Clear Consent

What I Did Wrong (Version 2)

Second attempt:

Banner with two buttons: "Accept All" and "Customize"

Accept All was bright and obvious. Customize was grey and small.

Problems:

  • "Dark pattern" making accept easier than decline
  • No obvious "Reject All" button
  • Pre-checked boxes in customize menu
  • Still set some cookies before consent

Better than version 1. Still not compliant.

What Actually Complies

Talked to a lawyer (expensive). Read actual guidance from data protection authorities (boring). Here's what you need:

Clear consent mechanism:

  • User must actively opt in
  • Silence/inactivity is not consent
  • Continuing to browse is not consent

Equal prominence:

  • "Accept" and "Reject" buttons should look equally important
  • No dark patterns making one easier than the other
  • Can't make reject harder to find

Granular choices:

  • Let users choose categories (necessary, analytics, marketing, etc)
  • Can't be all-or-nothing
  • Necessary cookies are exempt, everything else needs consent

Actually block cookies:

  • Don't set cookies before consent is given
  • This is the part everyone messes up
  • Banner is useless if you set cookies anyway

Easy to change later:

  • Users can change their mind
  • Need obvious way to access consent settings again

That's the minimum. Some jurisdictions require more.

My Current Implementation

Here's what I use now:

Banner shows up, blocks the page

  • Clear message: "We use cookies to improve your experience"
  • Three equal-sized buttons: "Accept All" | "Reject All" | "Customize"
  • Link to cookie policy

No cookies set at all until user chooses

  • Site functions with necessary cookies only by default
  • Analytics, ads, etc only load after consent

Customize menu lets you pick categories:

  • Necessary (always on, can't disable)
  • Analytics (off by default)
  • Marketing (off by default)
  • Social Media (off by default)

Settings accessible from footer:

  • "Cookie Settings" link always available
  • Can change mind anytime

Tool I use: Cookie Consent by Osano (free tier). There are others.

The Technical Part Everyone Forgets

Having a banner is not enough. You actually need to block cookies.

Before consent:

// Don't do this:
gtag('config', 'GA_MEASUREMENT_ID');

// Do this:
if (userConsentedToAnalytics) {
  gtag('config', 'GA_MEASUREMENT_ID');
}

Every single tracking script needs to be conditional on consent.

Google Analytics, Facebook Pixel, ad networks, everything. If they set cookies, they need consent first.

I use Google Tag Manager for this. Consent checks built in. Makes it easier.

Necessary vs Non-Necessary Cookies

Here's what confused me: what counts as "necessary"?

Necessary cookies (don't need consent):

  • Session management (keeping you logged in)
  • Shopping cart
  • Security features
  • Load balancing
  • Accessibility settings

Not necessary (needs consent):

  • Analytics
  • Advertising
  • Social media widgets
  • Anything that tracks across sites

The test: would the site work without it? If yes, it's not necessary.

I thought analytics were necessary to "improve the site." Nope. Nice to have, not necessary.

Cookie Categories: Necessary vs Non-Necessary (Detailed Breakdown)

Strictly Necessary (No Consent Required):

Cookie TypePurpose & ExamplesDurationReason
SessionLogin state: PHPSESSID, sessionidSessionSite functionality
Shopping CartCart items: cart_token, cart_id7-30 daysCore feature
SecurityCSRF, fraud: csrf_token, security_sessionSessionProtect user
Load BalancingTraffic distribution: AWSALB, lb_cookieSessionTechnical need
AccessibilityFont, contrast: accessibility_prefs1 yearUser needs
Consent StorageChoice記錄: cookie_consent, gdpr_consent1 yearLegal requirement
LanguageLocale: locale, language1 yearBasic UX

Requires Consent:

Cookie TypePurpose & ExamplesDurationWhy Consent Needed
AnalyticsVisitor stats: _ga, _gid, _gat2 yearsTracks behavior
AdvertisingAd targeting: _fbp, IDE, test_cookie90 days-2 yearsPersonal data
Social MediaSharing: fr, datr, personalization_id90 daysThird-party tracking
MarketingCampaigns: campaign_id, utm_source30-90 daysPromotional tracking
Third-partyChat, video: intercom_session, vuidVariesExternal services

The "Necessary" Test (Decision Tree):

QuestionIf Yes →If No →Conclusion
Would core functionality break without it?Probably necessaryAsk next questionCheck next
Is it required for security/legal compliance?NecessaryAsk next questionCheck next
Does it track user across sites?Needs consent (not necessary)Ask next questionCheck next
Does it serve personalized ads/content?Needs consent (not necessary)Probably necessaryMay be necessary

Real-World Examples:

ScenarioCookie PurposeClassificationConsent Needed?Why
E-commerce site: User adds item to cartShopping cartNecessaryNoSite can't function
Same site: Google Analytics tracks add-to-cartAnalyticsNon-necessaryYesNice to have, not required
Blog: Remembers "dark mode" preferencePreferenceNecessaryNoUser explicitly requested
Same blog: Facebook Pixel tracks pageviewsAdvertisingNon-necessaryYesTracking, not functionality
Forum: Session cookie for logged-in stateSessionNecessaryNoRequired for login
Same forum: Track which threads user openedAnalyticsNon-necessaryYesStatistical, not necessary

Common Mistakes I See

Pre-checked boxes Not allowed. User must actively check them.

"Legitimate interest" abuse Some banners claim "legitimate interest" for analytics and ads. That's not how legitimate interest works. Tracking for ads is not legitimate interest.

Making reject difficult Hiding the reject button, making it small, requiring multiple clicks to reject. All not allowed.

Cookie walls "Accept cookies or you can't use the site." Legally questionable in EU. Probably going to be banned everywhere eventually.

Assuming consent "By using this site you consent to cookies." Not consent. Needs active opt-in.

Setting cookies before consent Saw one site that set 40 cookies before even showing the banner. That's not how this works.

Different Laws, Different Rules

GDPR (Europe): Strictest. Requires opt-in for non-necessary cookies. Can't use pre-checked boxes. Must be easy to decline.

CCPA (California): Different approach. Users can opt out after the fact. "Do Not Sell My Info" link required. Less strict on initial consent.

ePrivacy Directive: EU law specifically about cookies. Similar to GDPR but older. Most sites need to comply with both.

If you have global traffic, easiest approach: comply with GDPR. If it passes GDPR, it passes everything else.

Privacy Laws Comparison: GDPR vs CCPA vs ePrivacy

FactorGDPR (EU)CCPA (California)ePrivacy / LGPDMy Recommendation
Applies ToEU residentsCalifornia residentsEU / Brazil residentsComply with GDPR = covers most
Consent RequirementYes, opt-inOpt-out allowedYes, opt-in (both)Opt-in by default
Cookie ConsentRequired for non-necessaryNot specifically requiredCookies (ePrivacy) / Required (LGPD)Get consent upfront
Pre-checked BoxesNot allowedAllowed (opt-out)Not allowed (both)Don't use
Right to WithdrawRequired (all)Required (all)Required (all)Footer link to settings
"Do Not Sell" LinkNot requiredRequiredNot required (both)Add if targeting CA
Data Processing RecordRequired (>250 employees)LimitedNot specified / RequiredKeep consent logs
Maximum Fine€20M or 4% revenue$7,500 per violation€20M / R$50M or 2-4% revenueTake seriously
Grace PeriodNone, immediate30 days to cureNone, immediate (both)Assume immediate
Legitimate InterestCan use (limited)Not applicableCan use (limited, both)Use consent instead

Compliance Strategy Matrix:

Your TrafficLaws to Comply WithCookie Banner StrategyComplexityMy Approach
EU onlyGDPR + ePrivacyStrict opt-inMediumFull GDPR compliance
California onlyCCPAOpt-out linkEasy"Do Not Sell" link
US only (non-CA)State laws varyVaries by stateMediumFollow GDPR anyway (future-proof)
Global (incl. EU)GDPR + othersStrictest (GDPR)HardApply GDPR to everyone
Global (no EU)CCPA + othersCCPA baselineEasyCCPA + opt-in for good practice

Key Differences in Practice:

AspectGDPR ApproachCCPA ApproachWhat I Do
Initial stateNo cookies until consentCan set cookies, offer opt-outGDPR (safer)
Banner typeOpt-in: Accept/Reject/CustomizeNotice + "Do Not Sell" linkOpt-in for all
Default boxesUncheckedCan be checkedAlways unchecked
Reject buttonMust be prominentNot requiredAlways prominent
AnalyticsNeeds consentCan use, must allow opt-outGet consent
Record keepingConsent records requiredLess detailedKeep all records

What About "Legitimate Interest"?

GDPR has six legal bases for processing data. "Legitimate interest" is one.

Some cookie tools let you claim legitimate interest for analytics and marketing. Sounds good, doesn't actually work.

The UK's ICO (data protection authority) basically said analytics and advertising are not legitimate interest. You need consent.

Don't try to be clever with legitimate interest. Just get consent.

Implementation Options

DIY (what I did initially):

  • Write your own JavaScript
  • Manage consent yourself
  • Free but time-consuming
  • Easy to mess up

Cookie consent tools (what I use now):

  • Osano (free tier exists)
  • CookieBot (paid)
  • OneTrust (enterprise, expensive)
  • Termly (affordable, decent)

Tag management approach:

  • Google Tag Manager with consent mode
  • Blocks tags until consent given
  • Works well with Google services
  • Free

I use Osano for the banner + Google Tag Manager for tag blocking. Good combo.

Cookie Consent Tools Comparison

ToolPriceKey FeaturesRating / Best For
Osano (Free)Free tierEasy, GDPR compliant, basic banner8/10 - Small-medium sites
CookieBot$9-108/monthAuto-scanning, detailed reports9/10 - Professional sites
OneTrust$1,000+/yearEnterprise features, complex setup7/10 - Large enterprises
Termly$10-200/monthPolicy generator, auto-scanner8/10 - Mid-size businesses
Cookie Consent (Silktide)FreeSimple, lightweight, very easy7/10 - Basic compliance
iubenda€27-297/yearLegal docs + banner, multi-language8/10 - International sites
Cookieyes$9-19/monthAuto-blocking, customization7/10 - Budget-conscious
DIY (Custom)Free (time cost)Full control, requires dev skills5/10 - Developers only
Google Tag ManagerFreeTag blocking, Google analytics8/10 - Google users

Feature Comparison:

FeatureFree ToolsPaid Tools ($10-50/mo)Enterprise ($1000+)What You Really Need
Basic consent bannerYesYesYesEssential
Cookie blockingManualAutomaticAutomaticEssential
Consent loggingLimitedYesAdvancedEssential
Auto cookie scanningNoYesYesNice to have
CustomizationLimitedFullFullNice to have
Multi-languageLimited30+ languages100+If international
Geolocation rulesNoBasicAdvancedIf needed
A/B testingNoNoYesNot essential
Legal supportNoTemplatesFullHire lawyer separately
White labelNoSomeYesNot essential

My Tech Stack Recommendation:

Site TypeBanner + Tag ManagementPolicy Docs / CostSetup Time
Personal blogCookie Consent (free) + ManualTermly (free) / $0/mo2 hours
Small businessOsano + Google Tag Manager (free)iubenda / $2.25/mo4 hours
E-commerceCookieBot ($12/mo) + GTMIncluded / $12/mo6 hours
SaaS productTermly ($20/mo) + GTMIncluded / $20/mo8 hours
EnterpriseOneTrust ($1500+/yr, all-in-one)Included / $125+/mo40+ hours

Testing Your Implementation

Here's how to check if yours actually works:

1. Clear all cookies and cache

2. Load site in incognito/private mode

3. Before clicking anything on the banner, check cookies: Developer tools → Application/Storage → Cookies

Should only see necessary cookies. No analytics, no ads, no tracking.

4. Click "Reject All"

Check cookies again. Still should only see necessary cookies.

5. Reload page, click "Accept All"

Now you should see analytics, ads, etc.

6. Click your "Cookie Settings" link

Should be able to change your mind.

If any of these fail, your implementation doesn't work.

I test mine every few months. Tools update, things break.

The Annoyance Factor

Yeah, cookie banners are annoying for users. I get it.

But getting fined is more annoying. Getting legal notices is more annoying. Having your site blocked in entire countries is more annoying.

Make the banner as non-intrusive as possible while still complying. That's the balance.

Tips for less annoying banners:

  • Don't show it on every page visit (store choice)
  • Make it small but visible
  • Clear, simple language
  • Fast to interact with

Some sites show it as a small bar at bottom. Some as a modal. Both can work if implemented right.

Mobile Considerations

Banner takes up more screen space on mobile. Design accordingly.

What works on mobile:

  • Bottom banner (doesn't block content as much)
  • Simple choices (don't make people scroll through options on tiny screen)
  • Big touch targets (small buttons are frustrating)

What doesn't work:

  • Full-screen modals that are hard to dismiss
  • Tiny "Customize" links
  • Horizontal scrolling for options

Test on actual phones. What looks fine on desktop can be terrible on mobile.

Updating Your Cookie Policy

Banner is only part of it. Need an actual cookie policy page too.

Should include:

  • What cookies you use
  • Why you use them
  • How long they last
  • Who else sees the data (third parties)
  • How to disable them

My cookie policy structure:

  1. What are cookies (brief explanation)
  2. What cookies we use (table with name, purpose, duration)
  3. Your choices (link to manage consent)
  4. Third-party cookies (list of services)
  5. Contact info for questions

Not complicated. Just be specific and honest.

When You Add New Tracking

Added new analytics tool? Updated pixel? New ad network?

You need to:

  1. Update cookie banner categories
  2. Update cookie policy
  3. Make sure it's blocked until consent

I forgot to do this once. Added a new tracking script, didn't update the consent system. Script ran for everyone regardless of consent.

Fixed it when I noticed. But that's a compliance violation.

The Consent Database

Need to keep records of who consented to what and when.

Why: If someone complains, you need proof they consented.

Most cookie consent tools handle this automatically. Store:

  • Timestamp of consent
  • What they consented to
  • IP address (maybe, depends on your privacy policy)
  • Consent ID

How long to keep these records? Check your local laws. Usually 1-3 years after the consent.

Multi-Region Compliance

Have users in EU and California? Need to handle both GDPR and CCPA.

Option 1: Apply GDPR rules to everyone. Simplest approach.

Option 2: Detect user location and show appropriate banner. More complex but more tailored.

I do option 1. Not worth the hassle of maintaining two different systems.

What Happens If You Get It Wrong

Best case: Nothing. You fix it when you notice.

Likely case: Someone complains. You get a warning. You fix it.

Worst case: Official complaint to data protection authority. Investigation. Potential fine.

Fines are rare for small sites. But warnings and complaints are common. Better to do it right from the start.

My Actual Checklist

Before launching your cookie banner:

  • Banner shows before any non-necessary cookies set
  • Clear accept and reject options
  • Options have equal visual weight
  • Granular controls available
  • Scripts actually blocked until consent given
  • Can change mind later (visible link)
  • Cookie policy page exists and is specific
  • Tested in incognito mode
  • Works on mobile
  • Consent stored properly

Do these things and you're in good shape.

Tools I Actually Use

Banner: Osano Cookie Consent (free tier) Tag management: Google Tag Manager Testing: Browser dev tools + privacy extensions Policy generation: Started with iubenda, customized it

Don't need expensive tools for basic compliance. Free options exist and work fine.

Final Thoughts

Cookie banners suck but they're necessary. Do it right or don't do it.

"Right" means:

  • Actually blocking cookies until consent
  • Giving real choices
  • Making reject as easy as accept
  • Keeping records

Takes a few hours to set up properly. Then it's done and you don't worry about it.

Much better than half-assing it and getting compliance issues later.

Just do it right the first time. Trust me.

Complete Cookie Consent Implementation Workflow

Loading diagram...

Implementation Time Breakdown:

StepDIY ApproachUsing ToolTime SavedDifficulty
1. Audit cookies1-2 hours30 min (auto-scan)50-75%Medium
2. Choose legal basis2-3 hours (research)30 min (built-in)75%Hard
3. Select & setup toolN/A1-2 hoursN/AEasy
4. Configure banner4-6 hours (coding)1 hour (UI)80%Hard (DIY)
5. Block scripts3-5 hours30 min-2 hours60%Hard
6. Test thoroughly2-3 hours1-2 hours30%Medium
7. Documentation2-3 hours1 hour50%Medium
Total16-24 hours5-9 hours~65% fasterMuch easier

ROI Calculation:

  • DIY: 20 hours × $50/hour = $1,000 (your time)
  • Tool: 7 hours × $50/hour + $120/year = $470/year
  • Savings: $530/year + less legal risk + auto-updates

Your Complete Compliance Checklist

PhaseTaskRequired / TimeRisk if SkippedStatus
🔍 AuditList all cookies on siteCritical / 30 minHigh (violations)⬜
Categorize each cookie (necessary vs not)Critical / 1 hourHigh⬜
Identify all tracking scriptsCritical / 30 minHigh⬜
Check third-party widgets (chat, social)Critical / 20 minMedium⬜
📋 LegalDetermine which laws apply to youCritical / 30 minCritical⬜
Decide on legal basis (consent vs LI)Critical / 1 hourHigh⬜
Draft or update cookie policyCritical / 2 hoursHigh⬜
Consult lawyer (if budget allows)Recommended / 1-2 hoursMedium⬜
🛠️ TechnicalChoose consent management toolCritical / 1 hourHigh⬜
Install banner on siteCritical / 30 minCritical⬜
Configure 3 buttons (Accept/Reject/Customize)Critical / 30 minHigh⬜
Set up cookie categoriesCritical / 1 hourHigh⬜
Block all non-necessary scriptsCritical / 2-3 hoursCritical⬜
Implement consent triggersCritical / 1-2 hoursCritical⬜
Add cookie settings link to footerCritical / 10 minMedium⬜
Set up consent logging/storageCritical / 30 minHigh⬜
🧪 TestingTest: No cookies before banner shownCritical / 10 minCritical⬜
Test: Reject all blocks all non-necessaryCritical / 10 minCritical⬜
Test: Accept all loads everythingCritical / 10 minHigh⬜
Test: Customize options workCritical / 15 minHigh⬜
Test: Can change mind laterCritical / 5 minMedium⬜
Test: Works on mobileCritical / 15 minHigh⬜
Test: Works on all major browsersRecommended / 30 minLow⬜
📄 DocumentationUpdate privacy policyCritical / 1 hourHigh⬜
Create cookie policy pageCritical / 1 hourHigh⬜
Document consent records retentionCritical / 30 minMedium⬜
Train team on complianceRecommended / 1 hourMedium⬜
📊 OngoingMonitor for new cookies (monthly)Critical / 15 min/moHigh⬜
Review and update as laws changeCritical / VariesHigh⬜
Check consent records quarterlyRecommended / 30 min/qtrLow⬜

Common Issues & Quick Fixes:

IssueCauseHow to FixTime to Fix
Cookies set before banner shownScripts load before consent checkMove all tracking to Tag Manager with consent triggers1-2 hours
"Reject" doesn't block cookiesScripts not checking consent stateImplement proper consent checks in code2-3 hours
Banner shows on every pageConsent choice not storedEnable consent cookie (ironically, this one IS necessary)30 min
No "Reject All" buttonBanner misconfiguredAdd reject button with equal prominence15 min
Pre-checked boxesDefault settings wrongSet all to unchecked by default5 min
Can't change mindNo settings linkAdd "Cookie Settings" link in footer10 min
Mobile banner too bigNot responsiveAdjust CSS or use bottom banner1 hour
Banner conflicts with designStyling issuesCustomize colors/position1-2 hours

Quick Start (Minimum Viable - 4 hours):

  1. Install Osano free tier (30 min)
  2. Set up GTM consent mode (1 hour)
  3. Test in incognito (30 min)
  4. Update privacy policy (2 hours)
  5. Result: Basic GDPR compliance

Full Compliance (Recommended - 8 hours):

  1. Everything above PLUS:
  2. Detailed cookie audit
  3. Granular category setup
  4. Comprehensive testing

Data Sources

This article is based on official privacy regulations and guidance:

Note: Cookie consent requirements vary by region. GDPR applies to EU residents; other regions have different requirements (CCPA in California, LGPD in Brazil, etc.). Always audit your specific cookies and consult legal guidance for your target audience.


Related Reading

Explore more privacy and security articles to protect your digital life:

Advertisement
Next Reading

Related guides worth indexing with this article

See all articles