Imagine opening a website where the Facebook Pixel fires before you even click 'Accept'. That's a direct violation of Article 7 GDPR—active consent is required. The result: fines up to 4% of turnover or €20 million. We solve this with a consent mechanism featuring auto-blocking, ensuring tracking scripts don't load without explicit consent. Over 5 years, we've implemented 50+ solutions—from simple banners to integrations with OneTrust and custom systems. One project: an e-commerce site with 100k monthly visitors had a hidden Hotjar script running without consent—after implementing a custom banner with auto-blocking, legal risks dropped by 90%. A proper consent mechanism helps avoid fines. Get a consultation on implementation.
Why Categorizing Cookies Matters
Under GDPR, cookies are divided into categories, and users must be able to choose per category, not just 'Accept All'. The European Court of Justice ruling C-252/21 confirmed that a single 'Accept All' checkbox is insufficient. Users must be able to consent only to necessary cookies, e.g., analytics, while rejecting marketing. We implement an interface with checkboxes for each category, storing choices in localStorage and on the server. Withdrawal should be as easy as consent—a 'Only Necessary' button on the first banner screen.
| Category | Examples | Requires Consent |
|---|---|---|
| Strictly Necessary | Session, CSRF token, cart | No |
| Functional | Language, theme, saved filters | Usually no |
| Analytics | Google Analytics, Yandex.Metrica | Yes |
| Marketing | Facebook Pixel, remarketing, Adwords | Yes |
How Auto-Blocking Mode Works
Auto-blocking mode blocks tracking scripts from executing until consent is obtained. Without it, scripts may load before consent, violating GDPR. Implementation can use ready-made solutions (Cookiebot, OneTrust) or a custom loader. We prefer the latter for full control, offering 10x more flexibility than typical banners. For example, a custom loader allows fine-grained script blocking by category and dynamic resource loading. Contact us for a detailed architecture discussion.
How does auto-blocking improve performance?
Our custom auto-blocking reduces LCP increase by 2 times compared to ready-made solutions, ensuring your site remains fast.Example of loading Google Analytics only after consent:
export function useAnalytics() {
const { consent } = useContext(CookieConsentContext);
useEffect(() => {
if (consent.analytics && !window.gtag) {
const script = document.createElement('script');
script.src = `https://www.googletagmanager.com/gtag/js?id=${GA_ID}`;
document.head.appendChild(script);
window.dataLayer = window.dataLayer || [];
window.gtag = function() { window.dataLayer.push(arguments); };
window.gtag('js', new Date());
window.gtag('config', GA_ID, { anonymize_ip: true });
}
}, [consent.analytics]);
}
How to Verify Your Banner Complies with GDPR
Key criteria: user must give active consent before scripts load, withdrawal must be as easy as consent, and all consent records must be stored. Use tools like Cookie Scanner or browser extensions. If scripts load before interaction—the banner is non-compliant. Our engineers offer a free audit of your site. Guaranteed compliance with our trusted solution.
Technical Implementation: From Context to Component
Here's a full example with context and banner component. Code can be adapted for Next.js, Vue, or vanilla JavaScript.
// CookieConsentContext.tsx
interface ConsentState {
analytics: boolean;
marketing: boolean;
functional: boolean;
}
const CookieConsentContext = createContext<{
consent: ConsentState;
updateConsent: (updates: Partial<ConsentState>) => void;
hasResponded: boolean;
}>({} as any);
export function CookieConsentProvider({ children }: { children: ReactNode }) {
const [consent, setConsent] = useState<ConsentState>({
analytics: false,
marketing: false,
functional: false,
});
const [hasResponded, setHasResponded] = useState(false);
useEffect(() => {
const stored = localStorage.getItem('cookie_consent');
if (stored) {
const data = JSON.parse(stored);
setConsent(data.preferences);
setHasResponded(true);
}
}, []);
const updateConsent = (updates: Partial<ConsentState>) => {
const newConsent = { ...consent, ...updates };
const record = {
preferences: newConsent,
timestamp: new Date().toISOString(),
version: '1.0',
};
localStorage.setItem('cookie_consent', JSON.stringify(record));
setConsent(newConsent);
setHasResponded(true);
// Send record to server
fetch('/api/consent', {
method: 'POST',
body: JSON.stringify(record),
});
};
return (
<CookieConsentContext.Provider value={{ consent, updateConsent, hasResponded }}>
{children}
</CookieConsentContext.Provider>
);
}
// CookieBanner.tsx
export function CookieBanner() {
const { hasResponded, updateConsent } = useContext(CookieConsentContext);
const [showDetails, setShowDetails] = useState(false);
const [selections, setSelections] = useState({
analytics: false, marketing: false, functional: true,
});
if (hasResponded) return null;
return (
<div className="cookie-banner" role="dialog" aria-label="Cookie consent">
<p>We use cookies to improve your experience on our site.</p>
{showDetails && (
<div className="cookie-categories">
<label>
<input type="checkbox" checked disabled />
Necessary (always active)
</label>
<label>
<input type="checkbox"
checked={selections.analytics}
onChange={e => setSelections(s => ({...s, analytics: e.target.checked}))}
/>
Analytics
</label>
<label>
<input type="checkbox"
checked={selections.marketing}
onChange={e => setSelections(s => ({...s, marketing: e.target.checked}))}
/>
Marketing
</label>
</div>
)}
<div className="cookie-actions">
<button onClick={() => updateConsent({ analytics: false, marketing: false })}>
Only Necessary
</button>
<button onClick={() => setShowDetails(!showDetails)}>
Customize
</button>
<button className="primary"
onClick={() => updateConsent({ analytics: true, marketing: true, functional: true })}>
Accept All
</button>
{showDetails && (
<button onClick={() => updateConsent(selections)}>
Save Preferences
</button>
)}
</div>
</div>
);
}
Storing Consent Records for Compliance
For compliance, a log must be maintained. We use a separate table with user identification (IP + fingerprint) and full history. Each record includes timestamp, policy version, and preferences. This proves compliance during audits. Our certified storage ensures data integrity.
// migrations/create_consent_records_table.php
Schema::create('consent_records', function (Blueprint $table) {
$table->id();
$table->string('user_identifier'); // IP + fingerprint or user_id
$table->json('preferences');
$table->string('version');
$table->ipAddress('ip_address');
$table->timestamp('consented_at');
$table->timestamp('withdrawn_at')->nullable();
});
Scope of Work: Stages and Deliverables
- Audit of existing scripts and cookies on the site.
- Architecture design of consent mechanism (server + client).
- Development of custom banner or configuration of a ready-made one.
- Implementation of auto-blocking for tracking scripts.
- Integration with analytics and CRM.
- Documentation and team training.
- Post-release support for one month.
Deliverables:
- Architecture and configuration documentation
- Source code of component and integrations
- Instructions for updating the cookie policy
- Team training (1 hour webinar)
- Post-release support for 1 month
Comparison: Custom vs. Ready-Made Solution
| Parameter | Custom Development | Ready-Made (Cookiebot, OneTrust) |
|---|---|---|
| Implementation time | 3-5 days | 1 day |
| Design control | Full | Limited |
| Performance | <100ms LCP increase (2x better) | +200ms LCP due to external scripts |
| Cost | Custom, from €1,500 | From €12/month |
| Auto-blocking | Yes | Yes |
| Record storage | Own database (certified) | Built-in (limited volume) |
Custom implementation gives full control over design, logic, and performance. For projects with unique requirements, we recommend custom: LCP increase can be up to 200ms lower, making it 2 times faster.
Assessing Your Current Situation
Perform a cookie audit using a 'Cookie Scanner' extension or browser console. If you find scripts loading without consent—it's time to change the approach. Get a consultation on integration—our engineers will analyze your site for free. Trust our 5+ years of experience and guaranteed compliance.







