Open source · MIT licence

The PrivacyPill cookie banner, free and open source

Our consent banner without the hosted parts: one dependency-free file with Accept, Reject, categories, Google Consent Mode v2 and script blocking. It runs entirely on your site and never calls our servers.

v1.2.1On GitHub now; npm package coming soon. Download it today.

gzipped, six languages
8.9 kBgzipped, six languages
dependencies
0dependencies
network requests
0network requests
free for any site
MITfree for any site

What's in it

The same banner our hosted script runs, with the same tests, minus anything that talks to a server.

  • Accept all and Reject all side by side, with the same weight
  • A close X that counts as Reject, and a line in the message saying so
  • Strictly necessary, analytics, marketing and functional categories, none pre-ticked
  • Google Consent Mode v2 defaults and updates
  • Script, iframe and embed blocking with data attributes
  • Focus trap, focus starting on Customise, focus returned after closing
  • English, German, French, Dutch, Spanish and Italian
  • Four layouts, themed through config, in Shadow DOM

Works offline

There's no config download, no consent log and no badge. The visitor's choice lives in one first-party cookie on your domain, and the only thing the script talks to is your page and, if you use them, Google tags through the dataLayer. Host the file yourself so no third party sees your visitors before they choose.

The ES module with English only is 6.7 kB gzipped; add the other languages you need from /locales.

Download

Version 1.2.1. Check the SHA-256 if you copy the files around. The same source is on GitHub, where you can also report a bug. The npm package is coming soon.

  • Script file

    Upload it to your site and add one script tag. Starts on its own, all six languages.

    consent-banner.min.js · 23.0 kB

    SHA-256 ab5b50536fcdbfc7fd7af3d431bf82c5c008834f914dd80c314f5bcbdba992be

    Download
  • npm package

    The exact package that goes to npm: ES modules, script build and TypeScript types.

    kalmwerk-consent-banner-1.2.1.tgz · 26.3 kB

    SHA-256 476ceed5c8efe00a70626403566c9fff0ed9d635e52616d5743eae771b844494

    Download
  • Source code

    The full repository with tests, CI and the release workflow. MIT licence included.

    consent-banner-1.2.1-source.zip · 64.4 kB

    SHA-256 d9ce32be99b1b5382491cefdc20f61f67ba21789747bfc0803d1b977918e6a6a

    Download

Install it

  1. 1

    Upload the file

    Put consent-banner.min.js on your own site, next to your other scripts.
  2. 2

    Add it to the top of <head>

    First the fail-safe line, so Google tags start denied even if the banner loads late, then the banner itself. Options go in data-config.
    html
    <!-- Top of <head>, before Google Tag Manager or any analytics -->
    <script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag('consent','default',{ad_storage:'denied',ad_user_data:'denied',ad_personalization:'denied',analytics_storage:'denied',functionality_storage:'denied',personalization_storage:'denied',security_storage:'granted',wait_for_update:500});</script>
    <script src="/consent-banner.min.js" data-config='{"policyUrl":"/privacy"}'></script>
  3. 3

    Block the trackers that need consent

    Change their type to text/plain and name the category. They run as soon as the visitor allows it.
    html
    <!-- Runs only after the visitor allows "analytics" -->
    <script type="text/plain" data-pp-category="analytics"
            src="https://static.hotjar.com/c/hotjar-1234567.js?sv=6"></script>
    
    <!-- Inline scripts work too -->
    <script type="text/plain" data-pp-category="marketing">
      fbq('init', '000000000000000'); fbq('track', 'PageView');
    </script>
    
    <!-- Embeds: load the iframe only after consent -->
    <iframe data-pp-category="functional"
            data-pp-src="https://www.youtube-nocookie.com/embed/VIDEO_ID"></iframe>
  4. 4

    Let visitors change their mind

    html
    <!-- Anywhere, e.g. your footer: lets visitors change their mind -->
    <button type="button" onclick="PrivacyPill.open()">Cookie settings</button>

With npm or a bundler

Until it's on npm, install the package straight from this site:

shell
npm install https://privacy-pill-consent-studio.lovable.app/open-source/kalmwerk-consent-banner-1.2.1.tgz

Once it's published, this becomes npm install @kalmwerk/consent-banner. The import paths stay the same:

js
import { initConsentBanner } from "@kalmwerk/consent-banner";
import { de, fr, nl } from "@kalmwerk/consent-banner/locales";

// Once, in browser code (for example a useEffect in your root layout)
initConsentBanner({ policyUrl: "/privacy", locales: { de, fr, nl } });

Every option, the JavaScript API and the Consent Mode mapping are in the README inside the package. The banner uses the same data attributes and window.PrivacyPill API as our install docs describe.

Open source or hosted PrivacyPill?

Same banner. Hosted PrivacyPill adds the tools around it.

FeatureOpen-source bannerHosted PrivacyPill
Accept, Reject, close X and categoriesIncludedIncluded
Google Consent Mode v2IncludedIncluded
Script and iframe blockingIncludedIncluded
Six languages and keyboard focus handlingIncludedIncluded
Visual editor with live previewYou edit the config by handIncluded
Hosted config: change the banner without redeployingNot includedIncluded
Proof-of-consent log and CSV exportOnly if you log on() events yourself30 days free, 12 months on paid plans
Cookie and tracker scanFree scan on this siteManual, plus monthly rescans on Pro
Geo-targeting (EU/EEA, UK, Switzerland, California)Not includedPro
Requests to PrivacyPill's serversNoneBanner config and consent log
PriceFree, MIT licenceFree for 1 site · Pro and Lifetime open soon

Want a visual editor, hosted config, consent logs and a cookie scan? Design a hosted banner or scan your site free.

GDPR and ePrivacy notes

This isn't legal advice, and no banner makes a site compliant on its own. Here is what the banner takes care of, and what stays with you.

The banner

  • Keeps optional cookies and Consent Mode signals off until the visitor chooses
  • Puts Reject next to Accept with the same style; the close X and Escape count as Reject
  • Asks per category, with nothing pre-ticked
  • Lets visitors change or withdraw their choice at any time
  • Asks again after 182 days, or when you bump the revision

You

  • Mark every non-essential script, pixel and embed; it can only hold back what you tag
  • Write and link a cookie policy that lists your tools
  • Keep records of consent if you need to show them (GDPR Article 7). The banner stores nothing outside the visitor's browser
  • For AdSense, Ad Manager or AdMob in the EEA, UK or Switzerland, use a Google-certified CMP: this banner isn't one and doesn't do IAB TCF
  • Check local guidance; the banner shows to every visitor and has no geo-targeting

Questions

What PrivacyPill costs

The free plan works today. Pro and Lifetime open soon — join the waitlist and we'll email you once when they do.

Compare plans
  • FreeAvailable now

    €0forever

    • 1 domain, 5,000 pageviews a month
    • Consent Mode v2, 6 languages, consent log
    Design your banner free
  • LifetimeOpens soon

    €49once

    • 1 domain, unlimited pageviews
    • Every future update, no renewals
  • ProOpens soon

    €9/month · or €79/year

    • Unlimited domains and pageviews
    • Monthly rescans, geo-targeting

Setting it up on a specific platform?

Our guides cover Next.js, Lovable, Bolt, v0, WordPress, Shopify, Webflow and more.

Platform guides