Cookie-Banner-Generator

Generates a working consent banner - blocks tagged scripts until consent, Google Consent Mode v2, no dark patterns.

100 % kostenlos. Läuft vollständig in deinem Browser: deine Dateien und Daten verlassen dein Gerät nie, und es wird nichts auf einen Server hochgeladen.

Vorlage, keine Rechtsberatung. This generates working code, not legal advice. It gives you a compliant mechanism; whether your site is compliant also depends on what you connect to it. Two things it cannot do for you: tag every third-party script so the blocker can hold it back, and keep a record of consents if your regulator expects one. Test it with your browser developer tools open - if a tracking cookie appears before you click Accept, something is still loading outside the blocker.

Mit einem Beispiel starten

Füllt jede Antwort mit einem durchgerechneten Beispiel, das du bearbeiten kannst. Nimm das, das deinem Geschäft am nächsten kommt.

0 of 3 details filled
Your site
Which consent model

Opt-in is required in the UK and EU. If you have any European visitors at all, choose it.

Opt-in is required in the UK and EU. If you have any European visitors at all, choose it.
Erscheinungsbild
Recommended. A single Accept-or-Reject is legal but converts worse than letting people keep analytics on and turn advertising off.
Signals and behaviour
Needed if you use Google Analytics or Google Ads and have EEA or UK visitors. Without it Google stops modelling data for those users.
Required in California and several other US states. The browser sends it automatically; this treats it as a rejection.
Consent has to be as easy to withdraw as it was to give, so there must be a way back to this after the banner is gone.

Cookie Consent Banner

5 sections · 1111 words · updates as you type

Cookie Consent Banner

Last updated: 12 November 2026

Paste this into your site

<!-- Cookie consent banner. Put the <style> and <script> in <head>,
     and the markup just before </body>. -->
<style>
#cc-banner{position:fixed;z-index:2147483000;right:16px;bottom:16px;max-width:420px;width:calc(100% - 32px);
  box-sizing:border-box;padding:20px;background:#fff;color:#0f172a;border:1px solid #e2e8f0;
  border-radius:14px;box-shadow:0 10px 40px rgba(2,6,23,.18);
  font:15px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
#cc-banner h2{margin:0 0 8px;font-size:1rem;font-weight:650}
#cc-banner p{margin:0 0 14px;color:#475569}
#cc-banner a{color:#4f46e5;text-decoration:underline}
#cc-actions{display:flex;gap:10px;flex-wrap:wrap}
#cc-banner button{flex:1 1 auto;min-width:120px;padding:11px 16px;border-radius:9px;
  font:inherit;font-weight:600;cursor:pointer;border:1px solid #4f46e5}
#cc-accept{background:#4f46e5;color:#fff}
#cc-reject{background:transparent;color:#4f46e5}
#cc-prefs{flex:0 0 auto;min-width:0;background:transparent;color:#475569;border-color:transparent;text-decoration:underline}
#cc-banner button:focus-visible{outline:3px solid #4f46e5;outline-offset:2px}
#cc-options{display:none;margin:0 0 14px;padding:12px 0 0;border-top:1px solid #e2e8f0}
#cc-options.cc-open{display:block}
#cc-options label{display:flex;gap:10px;align-items:flex-start;margin:0 0 10px;cursor:pointer}
#cc-options input{margin-top:3px;width:18px;height:18px;accent-color:#4f46e5}
#cc-options small{display:block;color:#64748b}
#cc-reopen{background:none;border:0;padding:0;font:inherit;color:inherit;text-decoration:underline;cursor:pointer}
@media (prefers-color-scheme:dark){
  #cc-banner{background:#0f172a;color:#e2e8f0;border-color:#1e293b}
  #cc-banner p{color:#94a3b8}
  #cc-prefs{color:#94a3b8}
  #cc-options{border-top-color:#1e293b}#cc-options small{color:#94a3b8}
}
@media (prefers-reduced-motion:reduce){#cc-banner{transition:none}}
</style>

<div id="cc-banner" role="dialog" aria-modal="false" aria-labelledby="cc-title" aria-describedby="cc-desc" hidden>
  <h2 id="cc-title">Cookies on this site</h2>
  <p id="cc-desc">We use cookies to run this site and, with your permission, to understand how it is used.
    Nothing optional is set until you choose.
    <a href="/cookie-policy">Read our cookie policy</a>.</p>
  <div id="cc-options">
    <label><input type="checkbox" checked disabled>
      <span>Essential<small>Needed for the site to work. Always on.</small></span></label>
    <label><input type="checkbox" id="cc-analytics">
      <span>Analytics<small>Counts visits so we can see what is used.</small></span></label>
    <label><input type="checkbox" id="cc-marketing">
      <span>Marketing<small>Measures advertising and allows targeted ads.</small></span></label>
  </div>
  <div id="cc-actions">
    <button type="button" id="cc-accept">Accept all</button>
    <button type="button" id="cc-reject">Reject all</button>
    <button type="button" id="cc-prefs">Choose</button>
  </div>
</div>

<script>
(function () {
  var KEY = "cc-consent-v1";
  var el = function (id) { return document.getElementById(id); };
  var banner = el("cc-banner");

  function read() {
    try { return JSON.parse(localStorage.getItem(KEY) || "null"); } catch (e) { return null; }
  }
  function write(state) {
    try { localStorage.setItem(KEY, JSON.stringify(state)); } catch (e) {}
  }

  // Google Consent Mode v2. Must run BEFORE the Google tag loads,
  // which is why this snippet goes in the head.
  window.dataLayer = window.dataLayer || [];
  function gtag() { window.dataLayer.push(arguments); }
  function signal(state) {
    gtag("consent", "update", {
      analytics_storage: state.analytics ? "granted" : "denied",
      ad_storage: state.marketing ? "granted" : "denied",
      ad_user_data: state.marketing ? "granted" : "denied",
      ad_personalization: state.marketing ? "granted" : "denied"
    });
  }
  gtag("consent", "default", {
    analytics_storage: "denied",
    ad_storage: "denied",
    ad_user_data: "denied",
    ad_personalization: "denied",
    wait_for_update: 500
  });

  // Turns every blocked script tag of a granted category into a real one.
  // Scripts are written as: <script type="text/plain" data-consent="analytics" src="...">
  function unblock(state) {
    var nodes = document.querySelectorAll("script[type='text/plain'][data-consent]");
    for (var i = 0; i < nodes.length; i++) {
      var node = nodes[i];
      var want = node.getAttribute("data-consent");
      if (!state[want]) continue;
      var live = document.createElement("script");
      for (var j = 0; j < node.attributes.length; j++) {
        var at = node.attributes[j];
        if (at.name !== "type" && at.name !== "data-consent") live.setAttribute(at.name, at.value);
      }
      live.text = node.text;
      node.parentNode.replaceChild(live, node);
    }
  }

  function apply(state) {
    write(state);
    signal(state);
    unblock(state);
    document.dispatchEvent(new CustomEvent("cc:consent", { detail: state }));
    hide();
  }

  function show() {
    banner.hidden = false;
    banner.querySelector("button").focus();
  }
  function hide() {
    banner.hidden = true;
  }

  el("cc-accept").addEventListener("click", function () {
    apply({ essential: true, analytics: true, marketing: true, at: Date.now() });
  });
  el("cc-reject").addEventListener("click", function () {
    apply({ essential: true, analytics: false, marketing: false, at: Date.now() });
  });
  el("cc-prefs").addEventListener("click", function () {
    var panel = el("cc-options");
    if (!panel.classList.contains("cc-open")) {
      panel.classList.add("cc-open");
      this.textContent = "Save choices";
      return;
    }
    apply({
      essential: true,
      analytics: el("cc-analytics").checked,
      marketing: el("cc-marketing").checked,
      at: Date.now()
    });
  });

  // Withdrawing consent has to be as easy as giving it, so this
  // reopens the banner from anywhere: <button id="cc-reopen">Cookie settings</button>
  var reopen = el("cc-reopen");
  if (reopen) reopen.addEventListener("click", show);

  var saved = read();
  // Global Privacy Control: a browser-level opt-out that US state law
  // requires you to honour. Treated as a rejection, recorded so the
  // banner does not then ask a question it has already answered.
  if (!saved && (navigator.globalPrivacyControl === true)) {
    apply({ essential: true, analytics: false, marketing: false, gpc: true, at: Date.now() });
    return;
  }
  if (saved) {
    signal(saved);
    unblock(saved);
    if (el("cc-analytics")) el("cc-analytics").checked = !!saved.analytics;
    if (el("cc-marketing")) el("cc-marketing").checked = !!saved.marketing;
  } else {
    show();
  }
})();
</script>

How to install it

1. Copy the block above into your page. The style and script can go in the head; the markup goes just before the closing body tag. On WordPress, a "header and footer scripts" plugin is the usual place; on Shopify it is theme.liquid.

2. Find every tracking script on your site - analytics, pixels, chat widgets, heatmaps.

3. Change each one from type="text/javascript" to type="text/plain" and add data-consent="analytics" or data-consent="marketing". That is what holds them back until someone agrees; a script you forget to tag will keep loading regardless of what the banner says.

4. Leave the Google tag itself in place and untagged. Consent Mode signals handle it: the tag loads, but it stores nothing until the consent update grants it.

5. Add a button with id="cc-reopen" to your footer, labelled something like "Cookie settings". Consent must be as easy to withdraw as it was to give, and that button is how.

6. Test it. Open a private window with developer tools on the Application tab, load the site, and look at Cookies before you click anything. If a tracker has already written one, it is not tagged properly.

What a blocked script looks like

<!-- BEFORE - runs immediately, sets cookies before anyone agrees -->
<script src="https://example-analytics.com/tag.js"></script>

<!-- AFTER - held back until consent for its category exists -->
<script type="text/plain" data-consent="analytics"
        src="https://example-analytics.com/tag.js"></script>

<!-- Inline scripts work the same way -->
<script type="text/plain" data-consent="marketing">
  /* pixel code here */
</script>

Reacting to a choice in your own code

// Fires every time a decision is made or restored on load.
document.addEventListener("cc:consent", function (e) {
  if (e.detail.analytics) {
    // start something that needs analytics consent
  }
});

// Read the stored decision anywhere:
var consent = JSON.parse(localStorage.getItem("cc-consent-v1") || "null");

What this banner does and does not do

What it does

  • Sets nothing before a choice. Tagged scripts stay inert until someone accepts, which is what the UK and EU rules require and what most free snippets get wrong.
  • Gives Reject the same weight as Accept. Same size, same prominence, one click. A greyed-out or hidden reject option is a dark pattern that has attracted fines.
  • Remembers the decision in localStorage under a versioned key, so changing the key re-asks everyone when your cookies change.
  • Works with a keyboard and a screen reader. It is a labelled dialog, focus moves into it, and the controls are real buttons.
  • Honours Global Privacy Control. Browsers that send the signal are treated as having rejected, without being asked - which is what California and several other states require.
  • Sends Google Consent Mode v2 signals , so Google Analytics and Google Ads behave correctly for EEA and UK visitors instead of silently dropping them.

What it does not do

  • It does not keep a server-side record of who consented and when. If your regulator or your DPO expects an audit trail, you need to post the decision to your own endpoint - the cc:consent event is where to do it.
  • It does not scan your site for trackers. Anything you do not tag keeps loading.
  • It does not write your cookie policy. The banner links to it; you still need the page.

Aus einem Template erzeugt. Keine Rechtsberatung - lies es, bevor du es veröffentlichst oder unterschreibst.

Andere Dokumente, die du erzeugen kannst

Die meisten Sites brauchen mehr als eines. Eine Datenschutzerklärung ohne AGB oder AGB ohne Rückerstattungsrichtlinie lässt die offensichtliche Lücke.

Privacy PolicyA privacy policy written from what your site actually does - GDPR and CCPA sections included only where they apply.Terms and ConditionsTerms of service built around what you actually sell - goods, subscription, downloads or services.Cookie PolicyA cookie policy with a real table - each cookie named, with its purpose and how long it lasts.Refund and Return PolicyA refund policy customers can follow and payment processors accept - windows, exclusions and statutory rights in plain words.Website DisclaimerA disclaimer that names the actual risk your site carries, plus affiliate and sponsorship disclosures.Accessibility StatementA WCAG accessibility statement that states what you actually meet, names known issues, and gives people a route to report problems.Non-Disclosure AgreementA mutual or one-way NDA with a real purpose clause, standard carve-outs and a defined term.Freelance ContractAn independent contractor agreement that pins down scope, revisions, IP ownership and what happens when payment is late.Data Processing AgreementA GDPR Article 28 processor agreement with the eight mandatory clauses and a filled-in processing schedule.W-9 FormFills a substitute Form W-9 in your browser - your TIN is never uploaded, stored or sent anywhere.1099-NEC Contractor SummaryPrepares a 1099-NEC recipient statement and a payer summary - with a straight answer about what you can and cannot print yourself.Shipping PolicyA shipping policy Shopify and Amazon sellers can publish - origin, times, tracking, duties and who pays.DSAR Form GeneratorA data-delete and access request page you can host - GDPR and CCPA wording, no upload, no signup.

Über dieses Tool

Beantworte eine Handvoll Fragen, und der Banner baut sich von selbst. Er ist für Entwickler und Website-Betreiber gedacht, die einen funktionierenden Einwilligungsmechanismus brauchen statt einer weiteren Richtlinienseite – und die zwanzig Minuten lohnen sich am selben Tag, an dem du Analytics oder ein Werbepixel einbaust, nicht danach. Das ist das einzige Tool in dieser Reihe, das Code statt Text ausgibt, denn eine Cookie-Richtlinie beschreibt, was du setzt, während ein Banner genau das verhindert. Die meisten kostenlosen Snippets setzen erst das Cookie und zeigen dann den Hinweis – genau das Verhalten, das die ePrivacy-Richtlinie verbietet. Der Fragebogen ist keine Dekoration: Teile erscheinen und verschwinden je nach deinen Antworten, deshalb bekommen zwei Personen auf dieser Seite inhaltlich verschiedene Banner und nicht denselben Text mit anderem Namen. Hinweis: Die Bedienung ist auf Deutsch, die Texte im erzeugten Banner-Code sind jedoch auf Englisch – passe sie für eine deutschsprachige Website im Code an. Alles läuft in deinem Browser. Was du eingibst, wird nie hochgeladen, nie gespeichert und ist weg, sobald du den Tab schließt.

So verwendest du dieses Tool

  1. Das Banner einrichtenTrag den Websitenamen, den Link zu deiner Cookie-Richtlinie und das benötigte Einwilligungsmodell ein.
  2. Die Kategorien wählenWähle die angebotenen Kategorien Statistik und Marketing, alle standardmäßig aus.
  3. Einbauen und Skripte umstellenFüge den Code in deine Website ein und kennzeichne jedes Tracking-Skript neu, damit das Banner es bis zur Einwilligung zurückhält.

Was einen Cookie-Banner rechtskonform macht

Britische und EU-Aufsichtsbehörden sind sich in einigen Punkten einig: Nicht notwendige Cookies dürfen nicht laden, bevor der Besucher zustimmt, Ablehnen muss so einfach sein wie Akzeptieren, vorausgewählte Kästchen gelten nicht als Einwilligung, und man muss seine Entscheidung später ändern können. Ein Banner mit nur einem „OK“-Button oder einer Ablehnen-Option zwei Bildschirme tief erfüllt diesen Standard nicht.

Der Banner von dieser Seite hält markierte Skripte zurück, bis der Besucher wählt, bietet Akzeptieren und Ablehnen gleichwertig an und speichert die Entscheidung, damit nicht auf jeder Seite erneut gefragt wird. Was er nicht kann: Skripte blockieren, die du nicht markiert hast – deshalb gehört ein Test mit den Entwicklertools des Browsers dazu.

Warum es nutzen

  • Buttons zum Akzeptieren und Ablehnen in gleicher Gewichtung, wie es britische und EU-Vorgaben erwarten.
  • Kategorie-Schalter für Analyse und Marketing, standardmäßig aus.
  • Hält markierte Skripte bis zur Einwilligung zurück und lädt dann nur die gewählten Kategorien.
  • HTML, CSS und JavaScript zum Kopieren, ohne externen Dienst oder Monatsgebühr.

Häufige Anwendungen

  • Eine kleine Firmenwebsite mit Google Analytics und Besuchern aus Großbritannien oder der EU.
  • Ein Shop mit Remarketing-Tags von Meta oder Google Ads.
  • Eine kostenpflichtige Consent-Plattform ersetzen, wenn die Website nur wenige Tags hat.
  • Ein Entwickler, der für ein Kundenprojekt einen schlanken Banner braucht.

Tipps für bessere Ergebnisse

  • Teste mit offenen Entwicklertools: Vor dem Klick auf Akzeptieren darf kein Tracking-Cookie erscheinen.
  • Gib Ablehnen dieselbe Größe und Farbe wie Akzeptieren – das erwarten deutsche Datenschutzbehörden und Gerichte als gleichwertige Wahl.
  • Verlinke das Banner mit einer Cookie-Richtlinie, die dieselben Kategorienamen nutzt.

Fehler, die du vermeiden solltest

  • Das Banner einbauen, die Tracking-Skripte aber nicht umstellen, sodass Pixel vor der Einwilligung weiterlaufen.
  • Ablehnen hinter einem Einstellungsbildschirm verstecken, während Akzeptieren auf der ersten Ebene steht.
  • Vergessen, neue Skripte dem Banner hinzuzufügen, wenn du später ein weiteres Tool installierst.

Häufig gestellte Fragen

US-Recht verlangt für Cookies in der Regel keine vorherige Einwilligung, manche bundesstaatlichen Datenschutzgesetze verlangen aber eine Widerspruchsmöglichkeit beim Verkauf oder Teilen von Daten für gezielte Werbung. Kommen Besucher aus Großbritannien oder der EU – also auch aus Deutschland –, ist ein Banner mit vorheriger Einwilligung die sichere Wahl.

Ändere den Skripttyp auf text/plain und füge ein data-Attribut mit der Kategorie hinzu; der Banner stellt es nach der Einwilligung zurück und führt es aus. Inline-Skripte und über einen Tag Manager geladene Tags brauchen dieselbe Behandlung.

Ja – Besucher, die ablehnen, werden nicht gezählt. Der Google Consent Mode kann einen Teil der fehlenden Daten modellieren, aber rechne mit niedrigeren Zahlen als vor dem Banner.

Nein. Das Tool setzt einen Entwurf aus Standardbausteinen zusammen, und jede Seite sagt das über der Vorschau. Die höchsten Cookie-Bußgelder in der EU gab es nicht für fehlende Banner, sondern für Banner, bei denen Ablehnen schwerer war als Akzeptieren oder bei denen Tracker unabhängig von der Antwort liefen.

Grob gesagt Entwickler und Website-Betreiber, die einen funktionierenden Einwilligungsmechanismus brauchen statt einer weiteren Richtlinienseite. Der beste Zeitpunkt ist der Tag, an dem du Analytics oder ein Werbepixel einbaust, nicht danach.

Den Banner einzubauen und die Tracking-Skripte unverändert zu lassen. Der Banner blockiert von allein nichts – jedes Skript muss umgekennzeichnet werden, damit der Blocker es zurückhalten kann, und ein nicht markiertes Pixel feuert weiter, während der Banner höflich um Erlaubnis bittet.

Die meisten brauchen außerdem eine Cookie-Richtlinie und eine Datenschutzerklärung. Sie decken ab, was der Banner nicht abdeckt.

Related guides