How to install a cookie banner in WordPress - step by step
WordPress powers most of the web, and nearly every WordPress site runs analytics or ad pixels - which means it needs a GDPR-compliant cookie banner. Here is the shortest path: a ready-made CookieFox plugin that requires no theme editing and no functions.php hacking.
Why a plugin instead of a theme snippet?
A banner with tracker auto-blocking must be the first script in the <head> - only then can it block Google Analytics or Meta Pixel before they set cookies. A snippet pasted into the theme disappears with the next theme update, and one inserted by popular header plugins often lands too low. The CookieFox plugin hooks into wp_head at priority 0, so it always comes first.
Installation in 3 steps
- Download the plugin from your CookieFox panel: site details → the "Embed script" section → Download WordPress plugin. The ZIP already has your site key and the panel address baked in - there is nothing to configure.
- Upload it in WordPress: Plugins → Add New → Upload Plugin → pick the ZIP → Install → Activate.
- Done. The banner shows up immediately. You can view or change the key at any time under Settings → CookieFox.
No account yet? Create a free one, add your site and return to step 1 - the whole thing takes a few minutes.
What happens after activation?
- The plugin prints a single synchronous tag
<script src="https://panel/cmp/your-key.js">. Deliberately withoutasync/defer- those attributes break the "first in head" guarantee. - The banner renders in the visitor's language, with equal "Accept" and "Reject" buttons (a GDPR requirement).
- Analytics and marketing scripts stay blocked until consent, and the Google Consent Mode v2 signals are set automatically.
- Every decision lands in the consent register in your panel.
Watch out for optimization (cache) plugins
Tools like WP Rocket, LiteSpeed Cache or Autoptimize can move, merge and delay scripts (defer, "delay JS"). If they touch the banner script, auto-blocking stops working. Add the cmp/*.js URL to the JavaScript optimization exclusions - every one of these plugins has such a list in its settings.
Manual installation (the alternative)
Prefer no plugin? Paste the script tag from the panel (site details → "Embed script") as the first element of the <head> in your child theme. Just remember a theme update can overwrite the change - the plugin is simply more durable.
Running a shop too? See the PrestaShop guide.