Cookie banners are one of those things where most implementations are wrong in one of two directions: either they're illegal (pre-checked consent, no reject button, dark patterns) or they're massive overkill (enterprise consent management platforms on a 5-page portfolio site).
Here's the minimum setup that's legally compliant for small sites operating in the EU (including Slovakia), based on what actually matters under GDPR and the ePrivacy Directive.
When you need a cookie banner
You need one if you set cookies that aren't strictly necessary for the site to function. The most common triggers:
- Google Analytics (or any analytics that uses cookies)
- Facebook Pixel, Google Ads, any advertising tracker
- Hotjar, Clarity, or similar session recording tools that use cookies
- Third-party embeds (YouTube, Vimeo) that set their own cookies
You don't need one if you only use:
- Session cookies for authentication (strictly necessary)
- Cookie-free analytics (Plausible, Fathom, Umami, PostHog in cookieless mode)
- No third-party embeds, or embeds loaded only after consent
The simplest legal path: switch to cookie-free analytics and skip the banner entirely. Plausible and Fathom are GDPR-compliant without consent. This is what I recommend for most client sites — no banner, no consent management, no legal risk.
If you do need a banner: the legal requirements
Under GDPR + ePrivacy Directive (as implemented in Slovak law and across the EU):
1. Prior consent for non-essential cookies
You must get consent before setting any non-essential cookie. This means: no Google Analytics tracking on page load. The script loads only after the user clicks "Accept."
Pre-checked boxes are explicitly illegal under GDPR (Planet49 ruling, CJEU 2019). The consent must be an affirmative action — clicking a button, not failing to uncheck a box.
2. Equal prominence for accept and reject
The "Accept" and "Reject" buttons must be equally easy to find and click. Dark patterns — making "Reject" a tiny link while "Accept" is a big green button — violate the GDPR's requirement for freely given consent.
The French CNIL fined Google €150M and Facebook €60M in 2022 specifically for this: making it one click to accept and multiple clicks to reject.
3. Granular category control
Users must be able to consent to specific categories (analytics, marketing, preferences) rather than all-or-nothing. In practice, for a small site with just analytics, two options are enough: "Accept analytics" and "Reject all."
4. Easy withdrawal
Users must be able to withdraw consent as easily as they gave it. A link in the footer ("Cookie Settings") that reopens the banner is the standard approach.
5. Documented proof
You must be able to prove that consent was given. Store a record: timestamp, what was consented to, and the version of the consent text shown. A simple database row or localStorage entry works.
The minimum implementation
For a small Next.js site that needs Google Analytics:
'use client'
import { useState, useEffect } from 'react'
const CONSENT_KEY = 'cookie-consent'
type Consent = 'accepted' | 'rejected' | null
export function CookieBanner() {
const [consent, setConsent] = useState<Consent>(null)
const [visible, setVisible] = useState(false)
useEffect(() => {
const stored = localStorage.getItem(CONSENT_KEY)
if (stored === 'accepted' || stored === 'rejected') {
setConsent(stored)
if (stored === 'accepted') loadAnalytics()
} else {
setVisible(true)
}
}, [])
function accept() {
localStorage.setItem(CONSENT_KEY, 'accepted')
setConsent('accepted')
setVisible(false)
loadAnalytics()
}
function reject() {
localStorage.setItem(CONSENT_KEY, 'rejected')
setConsent('rejected')
setVisible(false)
}
if (!visible) return null
return (
<div role="dialog" aria-label="Cookie consent" className="...">
<p>
We use cookies for analytics to improve this site. See our{' '}
<a href="/privacy">privacy policy</a>.
</p>
<div className="flex gap-3">
<button onClick={reject} className="...">
Reject
</button>
<button onClick={accept} className="...">
Accept
</button>
</div>
</div>
)
}
function loadAnalytics() {
// Load GA4 only after consent
const script = document.createElement('script')
script.src = `https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX`
script.async = true
document.head.appendChild(script)
}
Key points:
- No analytics on page load. The script loads only after
accept(). - Both buttons equally styled. Same size, same prominence.
- Remembers choice. Doesn't ask again on every page load.
- Footer link to reopen. Add a "Cookie Settings" link in the footer that sets
visibletotrue.
The footer consent link
<button
onClick={() => {
localStorage.removeItem(CONSENT_KEY)
window.location.reload()
}}
className="text-sm text-gray-400 hover:text-white"
>
Cookie Settings
</button>
This clears the stored consent and reloads the page, showing the banner again. Simple, compliant, no enterprise consent platform needed.
Slovakia-specific notes
Slovakia implements the ePrivacy Directive through the Electronic Communications Act (zákon č. 452/2021). The requirements align with the EU standard — no Slovakia-specific gotchas. The regulatory authority is the Office for Personal Data Protection (Úrad na ochranu osobných údajov).
For a small service business, the risk of enforcement is low — regulators focus on large companies. But compliance is straightforward enough that there's no reason to skip it. The implementation above takes 30 minutes.
What not to use
- OneTrust, Cookiebot, CookieYes on a small site. These platforms are designed for enterprises with dozens of third-party scripts. For a portfolio with Google Analytics, they're overkill — they add 50–200KB of JavaScript, slow down page load, and often have their own compliance issues.
- Cookie banners that don't actually block cookies. I've seen implementations where the banner shows but analytics loads immediately regardless of the user's choice. This is worse than no banner — it's evidence of knowing about consent requirements and ignoring them.
- "By continuing to browse, you accept cookies." This is not valid consent under GDPR. Consent must be an affirmative action.
The recommendation
For most small sites: switch to cookie-free analytics (Plausible, Fathom) and skip the banner entirely. No legal risk, no UX friction, no implementation cost.
If you need Google Analytics specifically: use the implementation above. 30 minutes of work, legally compliant, no third-party consent platform.
Either way, document it in your privacy policy — what cookies you set, why, and how users can opt out.
Want your site legally compliant without enterprise complexity? Let's talk — I ship GDPR-compliant setups on every EU-facing project.