How to add a cookie banner to WordPress
A GDPR-friendly cookie banner for any WordPress site in about five minutes, with FrostBanner's free plan.
If your WordPress site uses Google Analytics, Meta Pixel, YouTube or Google Maps and has visitors from the EU, you need to ask before those load. FrostBanner is one line of code, so it works with any theme and page builder.
1. Create your banner
- Sign in to FrostBanner with Google, GitHub or your email.
- Add your website's domain.
- Pick a style, write your texts and paste the link to your cookie policy. The preview shows exactly what visitors will see.
- Open the Install tab and copy your line of code. It looks like this:
<script src="https://app.frostbanner.com/v1/fb.js" data-site="YOUR_SITE_ID"></script>
2. Add it to WordPress
The easiest way is the official FrostBanner plugin from the WordPress plugin directory.
- In WordPress, go to Plugins → Add New, search for FrostBanner, install and activate it.
- In the FrostBanner dashboard, open the Install tab and copy your site ID.
- In WordPress, go to Settings → FrostBanner, paste the site ID and click Save Changes.
- If you use a caching plugin, clear its cache.
Open your site in a private window. The banner should appear. Style, texts and language are changed in the FrostBanner dashboard, not in WordPress.
Prefer not to add a plugin? Paste your FrostBanner line into the header with the free WPCode plugin instead: Code Snippets → Header & Footer, paste the line at the very top of the Header field, above any analytics code, and click Save Changes. Use only one of the two methods, otherwise the banner loads twice.
3. Make tracking wait for consent
A banner on its own doesn't block anything. If you pasted Google Analytics into the Header field yourself, change:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
to:
<script type="text/plain" data-category="analytics" async
src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
Use analytics for statistics, marketing for ad pixels such as Meta Pixel, and functional for extras such as chat widgets. Do the same for the inline script that comes with each tag.
Google tags added by another plugin (for example Site Kit) can't be edited this way. FrostBanner still sends Google Consent Mode v2 with everything denied by default, and Google tags respect it — as long as FrostBanner loads first. Check by opening View page source: the FrostBanner line must appear above the Google tag.
4. Block YouTube videos and Google Maps
In the block editor, add a Custom HTML block instead of the YouTube embed block, and rename src to data-src:
<iframe width="560" height="315" data-category="marketing"
data-src="https://www.youtube-nocookie.com/embed/VIDEO_ID" allowfullscreen></iframe>
Until the visitor accepts, they see a small notice with an “Allow and show” button. Google Maps embeds work the same way.
5. Check it works
- Open your site in a private window and click Reject all. In the browser's developer tools (Network tab), Google Analytics requests should not appear.
- Reopen preferences with the small button, accept Analytics, and the requests should start.
- Your consent log in the FrostBanner dashboard shows each decision.
Things to know
- Remove any other cookie banner plugin first, so visitors don't see two banners.
- If you earn from Google AdSense with visitors from the EU, personalized ads need a Google-certified platform with IAB TCF. FrostBanner doesn't have it yet, so Google would show only non-personalized or limited ads.
- You still need a cookie policy page that lists the cookies your site uses.
Add your WordPress cookie banner now. The free plan covers one website, with no page or pageview limit.
WordPress is a trademark of the WordPress Foundation. FrostBanner is not affiliated with the WordPress Foundation or WPCode. WPCode steps are from WPCode's documentation, checked on 1 November 2026. FrostBanner does not give legal advice.