Neweb / Free tools / Cookie Consent Banner Generator

Cookie Banner Generator.

A cookie banner asks visitors before your site sets analytics or advertising cookies, with reject as easy as accept. Pick a consent style, colour and wording, and this tool produces a small self-contained HTML, CSS and JavaScript snippet with Accept, Reject and Settings buttons, Google Consent Mode v2, a re-ask period and a footer link to change the choice, free and with no third-party script.

1. Head code: paste in <head>, before your Google tag
2. Banner code: paste just before </body>

The banner stores the choice in localStorage and dispatches a "cookie-consent" event with the value "all", "essential", "custom" or "optout"; window.nwCookieConsent says which categories (analytics, marketing) were allowed. With Consent Mode on, it also sends Google the matching consent update. The banner itself is not legal compliance; your cookie policy and tag behaviour must match.

Need a website to publish this on? Neweb builds one in about 90 seconds.

Start free
Embed this tool on your website

Add the cookie consent banner generator to your own site or blog for free. Paste this code into any HTML block (WordPress, Wix, Squarespace, Webflow or plain HTML). It runs in the visitor's browser, nothing they type is sent to Neweb, and the frame resizes itself to fit.

Preview the embed
What this tool does

Cookie Consent Banner Generator is a free online tool from Neweb (neweb.ai) for small businesses, with no sign-up. A cookie banner asks visitors before your site sets analytics or advertising cookies, with reject as easy as accept. Pick a consent style, colour and wording, and this tool produces a small self-contained HTML, CSS and JavaScript snippet with Accept, Reject and Settings buttons, Google Consent Mode v2, a re-ask period and a footer link to change the choice, free and with no third-party script.

CostFree, no account, no sign-up
Built forsmall businesses, freelancers and sole proprietors
Made byNeweb, the AI website builder and online presence manager (free plan; paid plans from $9/month billed yearly)

Facts checked October 2026.

Sample output

What you'll get.

A real example of what this tool produces. Run it above with your own inputs.

Bottom bar: "We use cookies to make this site work and, with your consent, to understand how it is used." · Reject non-essential · Accept all
About 1.5 KB of inline CSS, HTML and JavaScript; no external requests.
Stores the choice in localStorage and dispatches a cookie-consent event
Your analytics tag listens for "all" before loading; "essential" or "optout" means it stays off.
Sample output. Generate your own snippet above.

If your website sets analytics, advertising or social-media cookies for visitors in the EU or UK, the ePrivacy rules and the GDPR require you to ask first and to make saying no as easy as saying yes. California's CCPA and CPRA take a different approach, requiring a clear "Do Not Sell or Share My Personal Information" option where personal data is shared for advertising. Most small-business sites meet these rules with a heavy consent-management script that slows the page, phones home and costs a monthly fee.

This generator produces the lightweight alternative: a self-contained snippet of about 1.5 kilobytes with the banner markup, its styles and a few lines of JavaScript. Choose an accept-and-reject style for GDPR and UK GDPR, a notice with a do-not-sell link for CCPA, or a notice-only banner if you set no non-essential cookies at all. The GDPR style adds a Settings panel where visitors switch analytics and marketing cookies on or off separately. Set your colour, light or dark theme, position (bottom bar, top bar or corner card), wording and how often to ask again, link to your privacy or cookie policy, and copy the code.

Google Consent Mode v2 built in

If you use Google Analytics or Google Ads, the generator also writes a short head snippet that sets Google Consent Mode v2 defaults (analytics_storage, ad_storage, ad_user_data and ad_personalization set to denied for the GDPR style) before your Google tag loads. When the visitor chooses, the banner sends Google the matching consent update: analytics granted only if they allowed analytics, the three advertising signals granted only if they allowed marketing. Returning visitors' stored choices are sent on every page load.

The snippet remembers the visitor's choice in their browser and fires a cookie-consent event with the value chosen, so you can load Google Analytics, Meta Pixel or any other tag only after an "all" answer. The banner is a mechanism, not compliance by itself: your tags must genuinely stay off until consent, and your privacy policy must describe the cookies. The tool is free and comes from Neweb, the AI website builder for small businesses (free plan, paid plans from $9/month billed yearly, $19 month-to-month).

How to use the cookie consent banner generator

  1. Enter your site name and the URL of your privacy or cookie policy; the banner links to it with "Learn more".

  2. Choose the consent style: Accept / Reject for GDPR and UK GDPR audiences, the CCPA notice with a do-not-sell link for California, or notice-only if you use essential cookies alone.

  3. Pick a position, an accent colour that matches your brand and a light or dark theme, and edit the banner text if needed.

  4. Choose how often to ask again (6 or 12 months) and whether to add Google Consent Mode v2.

  5. Click Generate snippet to see a working preview and the code, then copy the head code (only with Consent Mode) and the banner code.

  6. Paste the head code inside <head> above your Google tag, the banner code just before the closing </body> tag on every page (or in your theme footer), and the Cookie settings link in your footer. Load other analytics and marketing tags only when the cookie-consent event says they were allowed.

Why this matters for your business

Regulators now check for a real reject button. Data protection authorities in France, Germany, Ireland, the Netherlands and the UK have all published guidance or fined companies for banners that offer "accept" prominently and bury "reject" behind settings. A banner with both options side by side, which is what this generator produces, is the expected baseline.

Third-party consent scripts cost speed. Many popular consent-management platforms add 100 to 300 kilobytes and several network requests before the page is interactive, which hurts Core Web Vitals and therefore search rankings. A 1.5 KB inline snippet has no measurable effect.

Consent is pointless if tags fire anyway. The most common failure in small-business audits is a banner that appears while Google Analytics has already loaded. The event this snippet dispatches makes it straightforward to gate tags properly.

Tips for better results

  • Only use the notice-only style if you really set no analytics or marketing cookies; a notice without a reject option is not valid consent in the EU or UK.
  • Gate your tags. In Google Tag Manager, create a custom event trigger for cookie-consent and fire analytics and marketing tags only when the event detail is "all".
  • Give visitors a way to change their mind: paste the generated "Cookie settings" link in your footer. It reopens the banner with the Settings panel showing their current choices.
  • Keep the banner text short and specific. Say what the cookies do, not "to improve your experience".
  • Match the accent colour to your site but keep the reject button equally visible; the generated styles give both buttons the same size.
  • Test in a private window to see the banner fresh, click each option and check in the browser network tab that analytics loads only after acceptance.

Example

A real-world walkthrough

Harbor Lane Studio, a web design business in Bristol, uses Google Analytics and an embedded Instagram feed on its site and serves UK and EU clients. The owner selects Accept / Reject, bottom bar, the studio's blue accent and the light theme, points the link at /privacy and keeps the default text.

She pastes the snippet into the theme footer and changes her Analytics tag to load inside a cookie-consent listener that checks for "all". A test in a private window shows the banner appearing with no analytics request until she clicks Accept all; clicking Reject non-essential hides the banner and the request never fires. The site's Lighthouse performance score is unchanged.

Frequently asked questions

Is this cookie banner GDPR compliant?

The banner provides the mechanism GDPR and the ePrivacy rules expect: clear information, a link to the policy, an accept option and an equally prominent reject option, with the choice remembered. Compliance also depends on what your site does with the answer. Non-essential cookies and tags must not be set until the visitor accepts, the policy must describe them, and visitors must be able to withdraw consent. The snippet makes those things possible but cannot enforce them; the generator is a tool, not legal advice.

How do I stop Google Analytics loading before consent?

Wrap the Analytics or Tag Manager code so it runs only inside the consent event. For example: document.addEventListener("cookie-consent", function(e){ if(e.detail === "all"){ /* insert the gtag or GTM snippet here */ } });. Because the banner also fires the event on later visits using the stored choice, returning visitors who accepted still get analytics without seeing the banner again. If you use Google Consent Mode, call gtag('consent','update', ...) from the same listener.

What is the difference between the GDPR and CCPA styles?

GDPR and UK GDPR require opt-in consent before non-essential cookies are set, so the GDPR style offers Accept all and Reject non-essential with equal prominence and sets nothing until the visitor chooses. The CCPA and CPRA work on an opt-out basis: cookies may be set but California residents must be offered a clear "Do Not Sell or Share My Personal Information" link, which the CCPA style provides, storing "optout" when clicked so you can disable advertising tags. If you serve both audiences, use the GDPR style; it satisfies the stricter rule.

Where is the visitor's choice stored, and for how long?

In the browser's localStorage under the key nw-cookie-consent, as a small record of the choice ("all", "essential", "custom" or "optout"), whether analytics and marketing were allowed, and when. The banner asks again after the period you choose, 6 or 12 months, or never. To make it reappear for everyone after you change your cookie policy, change the key name in the snippet.

What is Google Consent Mode v2 and do I need it?

Consent Mode is how a website tells Google tags whether a visitor allowed analytics and advertising cookies. Version 2 added two signals, ad_user_data and ad_personalization, alongside analytics_storage and ad_storage. If you use Google Analytics or Google Ads with visitors in the EEA or UK, add it: choose "Add Google Consent Mode v2", paste the head code above your Google tag, and the banner sends the visitor's choice to Google automatically.

Is there a free cookie banner without a subscription?

Yes, this one. The generated code is yours to paste into any site, with no account, no monthly fee, no page-view limit and no external script, so nothing loads from a third-party server. Paid consent platforms add things like automatic cookie scanning, consent logs and multi-language banners; if you need those, compare them, but a small business site with a few known tags usually does not.

Does the snippet work with WordPress, Shopify, Wix, Squarespace or Webflow?

Yes, anywhere you can add custom HTML to the page footer. On WordPress paste it into the theme's footer template or a header-and-footer plugin; Neweb sites, which run on WordPress, accept it the same way. Shopify has a theme.liquid file, Squarespace and Webflow have footer code injection settings, and Wix has a custom code section in site settings. The snippet uses no libraries, so there is nothing to conflict with existing scripts.

Can I customise the design further?

Yes. The generated CSS is plain and short; edit the colours, font, padding, border radius or position directly in the snippet. The only requirements are that the element keeps the id nw-cc and the buttons keep their data-cc attributes, which the JavaScript uses. The generated "Cookie settings" link calls nwCookieSettings(), which reopens the banner; you can attach that function to any button or menu item.

All industries →  ·  Pricing  ·  All free tools

Your entire online presence, on one subscription.

All industries and more. AI website builder, managed hosting and AI search optimization. Free to start; paid plans from $9/month billed yearly ($19 month-to-month) include a free domain for the first year.