Back to Blog
WordPress
Cookie Banner
GDPR
PIPEDA
Tutorial

How to Add a Cookie Banner to WordPress in 2025 (Step-by-Step Guide)

Written by Cookie Banner Team
11 min read min read
Start Building Today

Ready to add a cookie banner to your site?

Join 1,000+ Canadian businesses who trust our free cookie banner generator. No credit card required, unlimited banners, fully compliant with PIPEDA & CASL.

First 1,000 accounts are free forever. No catches, no limits.

TL;DR (Too Long; Didn't Read)

Quick Summary:

  • Why: Using tracking tools? You legally need a cookie banner
  • Best Method: Cookie Banner Generator (unlimited, free, no plugins)
  • Time: 10 minutes to set up
  • Cost: First 1,000 accounts free forever
  • Compliance: GDPR, PIPEDA, CASL compliant

3 Quick Steps:

  1. Create free account
  2. Customize your banner (colors, text, position)
  3. Copy code → Paste in WordPress → Done!

If you're running a WordPress website and using Google Analytics, Facebook Pixel, or any tracking tools, you need a cookie consent banner. It's not just good practice — it's the law in many countries including Canada (PIPEDA/CASL), Europe (GDPR), and increasingly in US states.

What happens if you don't have one?

  • ❌ Legal fines (up to $10 million under CASL)
  • ❌ Loss of user trust
  • ❌ Potential lawsuits
  • ❌ SEO penalties from search engines

In this guide, I'll show you exactly how to add a compliant cookie banner to WordPress in under 10 minutes — no coding required.

What You'll Learn

  • ✅ The 3 best ways to add a cookie banner to WordPress
  • ✅ How to make it GDPR & PIPEDA compliant
  • ✅ Free vs. paid options (and which to choose)
  • ✅ Step-by-step installation with screenshots
  • ✅ How to customize it to match your brand

Best for: Anyone who wants unlimited cookie banners, full customization, and no monthly fees.

Pros:

  • ✅ No WordPress plugin required
  • ✅ Unlimited cookie banners
  • ✅ Fully branded (match your site's design)
  • ✅ GDPR, PIPEDA, and CASL compliant
  • ✅ Works with any WordPress theme
  • ✅ First 1,000 accounts free forever

Cons:

  • Requires copying and pasting code (takes 2 minutes)
  1. Go to Cookie Banner Generator
  2. Click "Get Started Free"
  3. Create your account (no credit card required)

Step 2: Customize Your Banner

Once you're in the dashboard:

  1. Choose your position (bottom bar, floating, modal, etc.)

  2. Match your brand colors — The builder lets you customize:

    • Background color
    • Text color
    • Button colors
    • Font styles
  3. Set your message — Use clear language like:

    "We use cookies to improve your experience and analyze our traffic. You can accept all or customize your preferences."

  4. Add your privacy policy link — Required for compliance

Step 3: Install on WordPress

After customizing your banner:

  1. Click "Get Code"
  2. Copy the generated code snippet
  3. In WordPress, go to Appearance → Theme File Editor
  4. Find header.php (or use a code injection plugin)
  5. Paste the code right before the closing </head> tag
  6. Click "Update File"

That's it! Your cookie banner is now live.

Step 4: Test Your Banner

Visit your website and verify:

  • ✅ Banner appears on page load
  • ✅ "Accept" button works
  • ✅ "Reject" button works
  • ✅ Preferences panel opens
  • ✅ Cookies only load AFTER consent

Prefer not to edit theme files? Use a plugin like Insert Headers and Footers or WPCode to inject the code without touching your theme.

Method 2: Using a WordPress Plugin

Best for: Users who prefer WordPress plugins and don't mind limitations.

1. CookieYes (Freemium)

  • Free version: Basic banner, limited customization
  • Paid: $10-$120/year depending on pageviews
  • Pros: Easy setup, works in dashboard
  • Cons: Limited styling, per-site pricing, bloated

2. Complianz (Freemium)

  • Free version: Basic compliance
  • Paid: €59-€299/year
  • Pros: Strong compliance focus
  • Cons: Complex setup, expensive for multiple sites

3. Cookie Notice & Compliance (Freemium)

  • Free version: Simple banner only
  • Paid: Starts at $49/year
  • Pros: Lightweight
  • Cons: Limited features in free version
  1. Log into your WordPress dashboard
  2. Go to Plugins → Add New
  3. Search for "cookie banner" or "cookie consent"
  4. Click Install Now on your chosen plugin
  5. Click Activate
  6. Follow the plugin's setup wizard
  7. Customize colors, text, and behavior
  8. Save and test

⚠️ Plugin Drawbacks:

  • Most charge per-site or per-pageview
  • Can slow down your WordPress site
  • Limited customization in free versions
  • Need to update/maintain plugins

Method 3: Manual HTML/CSS Implementation (Advanced)

Best for: Developers who want full control.

Pros:

  • ✅ Complete customization
  • ✅ No third-party dependencies
  • ✅ Lightweight

Cons:

  • ❌ Requires coding knowledge
  • ❌ Must manually ensure compliance
  • ❌ Time-consuming to build
  • ❌ Hard to maintain

If you're a developer, you can build your own cookie banner using:

  • HTML for structure
  • CSS for styling
  • JavaScript for functionality
  • Local storage to remember user choices

Not recommended unless you have legal + technical expertise.

1. Block Cookies Until Consent

Your cookie banner MUST prevent tracking cookies from loading until the user accepts them.

Bad:

<!-- Google Analytics loads immediately -->
<script src="gtag.js"></script>

Good:

// Only loads after user clicks "Accept"
if (userConsent === true) {
  loadGoogleAnalytics();
}

Most cookie banner tools (including Cookie Banner Generator) handle this automatically.

2. Provide Granular Choices

Users must be able to:

  • ✅ Accept all cookies
  • ✅ Reject non-essential cookies
  • ✅ Choose specific cookie categories

Categories typically include:

  • Strictly Necessary (always allowed)
  • Functional (preferences, language)
  • Analytics (Google Analytics, Hotjar)
  • Marketing (Facebook Pixel, Google Ads)

3. Use Clear, Plain Language

Avoid legal jargon. Use simple, human-friendly language:

Bad: "By virtue of your continued navigation, you hereby consent to..." Good: "We use cookies to improve your experience. You can accept all or customize your preferences."

4. Make it Easy to Withdraw Consent

Add a footer link like:

  • "Cookie Settings"
  • "Manage Preferences"
  • "Privacy Choices"

Clicking this should reopen the cookie banner.

5. Link to Your Privacy Policy

Your cookie banner must link to a detailed privacy/cookie policy explaining:

  • What cookies you use
  • Why you use them
  • How long they last
  • How users can control them

Match Your Theme's Design

To make your cookie banner look native to your WordPress site:

  1. Use your theme's colors — Check your theme settings or CSS
  2. Match your fonts — Use the same font family
  3. Align with your brand — Use your logo colors
  4. Keep it consistent — Match button styles to your site's buttons

Divi:

  • Use Divi's built-in code injection
  • Match Divi's button styles
  • Use Divi's color palette

Elementor:

  • Add code via Elementor's custom code feature
  • Style to match Elementor's design system

Astra:

  • Use Astra's header/footer script injection
  • Match Astra's minimal design aesthetic

GeneratePress:

  • Use GP Hooks plugin for code injection
  • Match GeneratePress's clean styling

Some plugins show a banner that says "By continuing to browse, you consent..."

This is NOT compliant. Users must actively opt-in, not passively accept.

If Google Analytics loads before the user clicks "Accept," you're not compliant — even if you have a cookie banner.

Test this: Open your site in incognito mode with browser dev tools open. Check the Network tab. If you see tracking requests before clicking "Accept," you have a problem.

❌ Mistake #3: No Mobile Optimization

60%+ of traffic is mobile. Your cookie banner MUST work perfectly on mobile:

  • Easy to read
  • Easy to tap buttons (min 44px touch targets)
  • Doesn't block critical content
  • Responsive design

❌ Mistake #4: Ignoring Page Speed

Some cookie banner plugins are bloated and slow down your site.

Check your page speed before and after installing a cookie banner:

  • Use Google PageSpeed Insights
  • Aim for < 50KB additional weight
  • Ensure LCP doesn't increase significantly

A banner alone isn't enough. You need a dedicated Cookie Policy or Privacy Policy page that details:

  • What cookies you use (by name)
  • Why you use each one
  • How long they last
  • Third parties involved (Google, Facebook, etc.)
  • How users can opt-out

Use this checklist to ensure your setup is complete:

  • [ ] Cookie banner appears on first page load
  • [ ] Banner appears BEFORE any tracking cookies load
  • [ ] Users can "Accept All" easily
  • [ ] Users can "Reject" non-essential cookies
  • [ ] Granular category controls are available
  • [ ] Banner links to your privacy/cookie policy
  • [ ] Banner is mobile-responsive
  • [ ] Banner matches your WordPress theme design
  • [ ] Footer link to reopen cookie settings
  • [ ] Tested in multiple browsers
  • [ ] Tested on mobile devices
  • [ ] Page speed impact is minimal (< 0.3s to LCP)

Which Method Should You Choose?

Choose Cookie Banner Generator if:

  • ✅ You want unlimited banners across multiple sites
  • ✅ You want full design customization
  • ✅ You want to avoid monthly fees
  • ✅ You're okay with copying/pasting code

Choose a WordPress Plugin if:

  • ✅ You only have 1-2 sites
  • ✅ You want everything managed in WordPress dashboard
  • ✅ You don't mind paying per-site
  • ✅ You're okay with limited customization

Choose Manual Coding if:

  • ✅ You're a developer
  • ✅ You have legal expertise
  • ✅ You have time to maintain custom code

Next Steps

Ready to add a cookie banner to your WordPress site?

  1. Create your free account
  2. Customize your banner in 5 minutes
  3. Copy the code and paste it into WordPress
  4. You're done!

First 1,000 accounts are free forever.

Option 2: WordPress Plugin

  1. Go to Plugins → Add New in WordPress
  2. Search for "cookie consent" or "GDPR"
  3. Install and activate your chosen plugin
  4. Follow the setup wizard

Option 3: Manual Implementation

  1. Write HTML/CSS/JavaScript for your banner
  2. Integrate cookie blocking logic
  3. Test thoroughly
  4. Consult with a privacy lawyer

Frequently Asked Questions

If you use any tracking tools (Google Analytics, Facebook Pixel, etc.), yes. It's required under GDPR (Europe), PIPEDA/CASL (Canada), CCPA (California), and many other laws.

Yes, but free plugins often have limitations:

  • Basic design only
  • Limited to one domain
  • Branding/ads included
  • May not fully block cookies

For a truly unlimited, customizable solution, use Cookie Banner Generator.

Do I need to edit my WordPress theme files?

Option 1: Edit theme files (fastest) Option 2: Use a code injection plugin (safer for updates) Option 3: Use a WordPress cookie plugin (easiest)

It depends:

  • Well-coded banners: Add < 30KB, minimal impact
  • Bloated plugins: Can add 100KB+ and slow down your site

Always test your page speed before and after.

What if I use a page builder like Elementor?

Cookie banners work with ALL page builders:

  • Elementor
  • Divi
  • Beaver Builder
  • WPBakery
  • Oxygen

Just add the code to your theme header or use a code injection plugin.

  1. Open your site in incognito/private mode
  2. Open browser DevTools (F12)
  3. Go to Network tab
  4. Reload the page
  5. Check if Google Analytics/Facebook Pixel load before you click "Accept"

If they load immediately, your banner isn't blocking cookies properly.


Ready to make your WordPress site compliant? Get your free cookie banner →

Stay Updated on Privacy Law Changes

Get notified when Canadian privacy laws change and receive our latest compliance guides.

No spam. Unsubscribe anytime. We respect your privacy.

Key Takeaways

Compliance Requirements

PIPEDA and CASL require explicit consent for tracking cookies in Canada

Cookie Categories

Only strictly necessary cookies can be set without consent

Quebec Law 25

Stricter requirements for Quebec residents - opt-in required

Best Practices

Use clear language, provide granular controls, and keep records

Next Steps: Choose a cookie banner solution that's designed specifically for Canadian compliance, or build your own following the guidelines above.

Ready to add a cookie banner to your site?

Get your free, compliant cookie banner in minutes. No credit card required.

Create Your Banner

Related Articles

PIPEDA
Canada

PIPEDA Compliance Checklist 2025: Complete Guide for Canadian Websites

Comprehensive PIPEDA compliance checklist for Canadian businesses. Learn cookie consent requirements, privacy policy essentials, and how to avoid violations.

14 min read min readRead more
GDPR
Cookie Consent

GDPR Cookie Consent Requirements: Complete Compliance Guide 2025

Everything you need to know about GDPR cookie consent requirements. Learn what makes a cookie banner compliant, common mistakes, and how to avoid fines.

14 min read min readRead more
PIPEDA
Analytics

PIPEDA Compliance for Analytics and Advertising Pixels: What Canadian Websites Need to Know

Complete guide to PIPEDA compliance for Google Analytics, Facebook Pixel, and other tracking tools. Learn how to properly implement consent for analytics and advertising pixels in Canada.

13 min read min readRead more