Account

What new tool do you want?

Legal & Compliance

Cookie Consent Banner Generator (GDPR-Ready Code)

Generate a lightweight, dependency-free cookie consent banner — Accept all, Reject all and per-category choices — that blocks analytics and marketing scripts until the visitor agrees. Copy-paste HTML, CSS and JavaScript.

For general information only — not legal advice. Laws vary by location; consult a qualified lawyer.

How to use

  1. 1Set the text, colors, position and categories.
  2. 2Copy the code into your site before the closing </body> tag.
  3. 3Change your tracking scripts to type="text/plain" data-consent="analytics" (or marketing) so they run only after consent.

Frequently asked questions

Why must 'Reject all' be as easy as 'Accept all'?

European regulators (including France's CNIL and the UK ICO) treat banners without an equally prominent reject option as invalid consent.

How does blocking work?

Scripts marked type="text/plain" don't run. When the visitor consents to a category, the banner converts matching scripts to real JavaScript and runs them. The choice is stored for 6 months in localStorage.

Does it support Google Consent Mode?

Yes — tick the option and it updates Google Consent Mode v2 (analytics_storage, ad_storage, ad_user_data, ad_personalization) when the visitor chooses.

Why 'Reject all' has to be as easy as 'Accept all'

The generated banner puts Reject and Accept as equally weighted buttons, with Preferences as a third option, because that's the specific pattern European regulators (CNIL, the UK ICO) have penalized companies for not following — burying rejection behind extra clicks while accepting is one tap is treated as invalid consent. The blocking mechanism — tracking scripts marked type="text/plain" so the browser won't execute them — exists so scripts genuinely don't run before consent, rather than just being hidden from a banner while still firing in the background, which is the actual compliance failure regulators look for.

Worked example: Cookie Consent Banner Generator

Turn Analytics on and Marketing off, leaving Google Consent Mode off: the generated code produces a Preferences panel with only one checkbox — Analytics — because the script builds its category list as CATS = ["analytics"]. Any script you later tag data-consent="marketing" would never unblock, since marketing isn't in that list. No Google Consent Mode call appears anywhere in the output, because that block is only written when the GCM toggle is on. Turn GCM on instead, and a gtag("consent", "update", …) call is added that fires whenever the visitor accepts, rejects or saves preferences.

What the toggles change in the generated code

Turning on Analytics or Marketing adds a checkbox for it in Preferences and adds it to the list of categories the script checks before converting a type="text/plain" tag into a real, running script — turn both off and the banner becomes Necessary-only with nothing to unblock. The color field is validated against a hex-color pattern; if what you type doesn't match, the output quietly falls back to the default blue rather than injecting invalid CSS. Position is purely cosmetic and doesn't affect what's blocked.

What generating this code doesn't do for you

The banner only blocks scripts you've actually marked with data-consent attributes — forget to tag a tracking script and it loads regardless of what the visitor chooses, so the output is only as compliant as how thoroughly you apply it across your site. It doesn't write your cookie policy page, doesn't log consent for audit purposes beyond a local browser flag, and doesn't address non-EU/UK frameworks like US state privacy laws, which use different opt-out models. Review the final implementation against your own cookie audit before relying on it.

Related tools

More: Legal & Compliance