Search tools

Search for a command to run...

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.