Free cookie banner meeting GDPR banner UI requirements. One script tag - zero backend setup, zero fees, zero personal data.
This is how the banner looks on your website. Click the buttons to test it.
This website uses cookies
We use cookies to ensure the best experience. You can accept all or customize your preferences.
Handles consent categories: necessary, statistics, and marketing. Note: full GDPR compliance requires implementing your own server-side consent logs.
Vanilla JS, zero dependencies, Shadow DOM. Won't slow down your website.
Available forever at no cost. The only ask: keep the "Powered by SN Solutions" link.
Set language, privacy policy link, and accent color via data-* attributes.
Copy the code
Copy the script tag below.
Paste before closing body tag
Paste the code just before the closing body tag in your HTML.
Done!
Refresh your page - the banner will appear automatically.
<script
src="https://snsolutions.pl/cookie-widget.js"
data-lang="en"
data-privacy-url="/privacy-policy"
data-accent-color="#2563eb"
></script>data-langBanner language (pl or en)"pl" | "en"data-privacy-urlLink to your privacy policy"/polityka-prywatnosci"data-accent-colorButton accent color (HEX)"#2563eb"The widget automatically integrates with GTM via Google Consent Mode v2 and the dataLayer. One snippet in the head section is required - BEFORE the GTM tag:
1Paste the following code into the head section of your page, BEFORE the GTM script. It sets defaults to denied and restores consent for returning users before GTM loads:
<!-- Consent Mode v2 – paste BEFORE GTM script -->
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
// 1. Set defaults to denied (required by Consent Mode v2)
gtag('consent', 'default', {
analytics_storage: 'denied',
ad_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied'
});
// 2. If user already gave consent - restore it
// BEFORE GTM loads, so page_view is correctly tagged
try {
var _c = JSON.parse(localStorage.getItem('ns-cookie-consent') || 'null');
if (_c && _c.v === 1) {
gtag('consent', 'update', {
analytics_storage: _c.statistics ? 'granted' : 'denied',
ad_storage: _c.marketing ? 'granted' : 'denied',
ad_user_data: _c.marketing ? 'granted' : 'denied',
ad_personalization: _c.marketing ? 'granted' : 'denied'
});
}
} catch(e) {}
</script>⚠ Without this snippet, GTM may send analytics data before the user gives consent.
2The widget will automatically call gtag('consent', 'update', ...) after each consent change.
// Widget automatically calls:
gtag('consent', 'update', {
analytics_storage: 'granted' | 'denied',
ad_storage: 'granted' | 'denied',
ad_user_data: 'granted' | 'denied',
ad_personalization: 'granted' | 'denied'
});
// And pushes to dataLayer:
dataLayer.push({ event: 'cookieConsentUpdated', cookieConsent: { ... } });3In GTM, use a Custom Event trigger named cookieConsentUpdated or the built-in Consent Mode support.
Important: consent log responsibility
This widget provides a GDPR-compliant consent mechanism (UI) that meets the banner form requirements. However, GDPR Art. 7 places on the data controller (website owner) the obligation to prove that consent was obtained. This requires maintaining server-side consent logs. The widget stores user choices in localStorage - this does not constitute sufficient proof for supervisory authorities. The website owner is solely responsible for implementing server-side consent logging.
The widget emits a nsCookieConsent event on every consent change. By capturing it, you can save choices to your own server:
document.addEventListener('nsCookieConsent', async function(e) {
await fetch('/api/consent-log', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
ts: e.detail.ts,
necessary: e.detail.necessary,
statistics: e.detail.statistics,
marketing: e.detail.marketing,
bannerVersion: 1,
sessionId: crypto.randomUUID() // anonymous identifier
})
});
});⚠ Your endpoint should store: timestamp, category choices, banner version, and an anonymous session identifier. Do not store IP addresses without a separate legal basis.
Is the widget really free?
Yes, completely. The only ask is to keep the "Powered by SN Solutions" link in the banner.
Does it collect user data?
No. The widget sends no personal data. The only thing it may send is the installation domain name (for our statistics), with no visitor data.
Is the widget enough for full GDPR compliance?
The widget meets GDPR banner UI requirements: no pre-ticked boxes, equally prominent reject button, and ability to withdraw consent. However, it does not provide server-side consent logging required by GDPR Art. 7 - data controllers must maintain their own server-side consent records. See the detailed description and example in the section above.
What if I want to remove the "Powered by" link?
The link is a condition of using the free version. If you need a white-label version or more advanced configuration, contact us.
The widget is just one piece of the puzzle. We'll build you a website that attracts customers.
Free consultation