Generate โ†“
Free ยท GDPR-friendly ยท One snippet

Free WordPress cookie banner

Customise a GDPR-friendly cookie banner, copy one snippet of code, and paste it into your site. No account, no monthly fee to start.

Paste it just before </body> on your site.

Live preview
Your code
Recommended next step
Putting your site live? Get hosting + a free domain.
Add your cookie banner, then launch with Hostinger โ€” affordable hosting with a free domain included.
Get hosting with Hostinger →

Why not a plugin

Consent plugins are the heaviest thing on many WordPress sites โ€” several of them load their own JavaScript, stylesheets and remote calls before your page renders. For a banner that shows one message and two buttons, that is a poor trade, and it slows the Core Web Vitals that affect your ranking.

A single self-contained snippet does the same job with no plugin to update, no subscription, and nothing calling a third party.

Where to paste it

The part everyone gets wrong

Adding the banner does not make you compliant. If Google Analytics, Meta Pixel or an advertising tag is already in your header, it fires on page load and sets its cookies before anyone clicks anything. The banner is then decoration over a breach.

Those scripts must be held back until consent is given. In practice that means moving them out of the header and firing them from the banner’s consent event instead.

If you use a caching plugin โ€” WP Rocket, W3 Total Cache, LiteSpeed โ€” purge the cache after adding the banner. Cached pages will otherwise serve the old version to most visitors for hours.

Checking it works

Open your site in a private window, then look at Application → Cookies in your browser’s developer tools before clicking anything. If you see analytics or advertising cookies already present, the banner is not doing its job. After clicking accept, they should appear; after declining, they should not.

Common questions

Do I need a plugin for a cookie banner in WordPress?

No. A single snippet pasted before the closing body tag does the same job without the loading cost of a consent plugin.

Where do I put cookie banner code in WordPress?

In footer.php just before the closing body tag, using a child theme โ€” or via a code snippets plugin set to run in the footer.

Why do cookies still appear after adding a banner?

Because scripts in your header fire on page load, before consent. They must be held back and triggered by the consent event instead.

Do I need to clear my cache?

Yes. Caching plugins will keep serving the pre-banner version of your pages until the cache is purged.