Saurabh Web Solutions Subscribe

Type to search all tutorials and free downloads.

WordPress

How to Add a Cookie Consent Banner in WordPress (GDPR and AdSense Ready)

How to Add a Cookie Consent Banner in WordPress (GDPR and AdSense Ready) - cover image
On this page
  1. Step 1: List what sets cookies on your site
  2. Step 2: Using AdSense? Use Google's certified message
  3. Step 3: A consent plugin for everything else
  4. Step 4: Make the choice real
  5. Step 5: Test it
  6. Update your privacy policy

Analytics, advertising and many embeds set cookies. In the EU, UK and a growing number of other places, you generally need visitors' consent before setting non-essential cookies. A proper cookie consent banner gives visitors a real choice and blocks tracking until they agree. (This guide is practical guidance, not legal advice.)

Step 1: List what sets cookies on your site

  • Google Analytics, Meta Pixel or other tracking.
  • Advertising (Google AdSense, affiliate scripts).
  • Embeds such as YouTube, Google Maps and social widgets.
  • Essential cookies (login, cart) that do not need consent.

Step 2: Using AdSense? Use Google's certified message

For personalised ads to visitors in the EEA, UK and Switzerland, Google requires a Google-certified consent management platform. In AdSense, open Privacy & messaging and create the European regulations message (and the US state regulations message). It needs no plugin and works with your existing ad code.

For analytics and other scripts, a consent plugin such as Complianz, CookieYes or similar can:

  • Show the banner with Accept, Reject and Preferences options.
  • Block scripts until consent is given.
  • Support Google Consent Mode so Google tags respect the choice.
  • Generate a cookie policy listing the cookies used.

Avoid running two banners at once; if you use AdSense's message, configure the plugin so visitors are not asked twice where possible, following the plugin's guidance for Google CMP integration.

Step 4: Make the choice real

  • "Reject" should be as easy as "Accept".
  • No pre-ticked boxes for non-essential categories.
  • A link to change preferences later, for example in the footer.

Step 5: Test it

  1. Open the site in a private window and reject cookies.
  2. In the browser's developer tools, check that analytics and ad cookies are not set.
  3. Accept, and confirm tracking starts.

Update your privacy policy

Explain what you collect and why, list third parties such as Google, and link the policy in the banner and footer. Lazy-loading YouTube embeds until clicked also reduces cookies before consent.

Frequently asked questions

Do I need a cookie banner?

If you have visitors from the EU, UK or other regions with similar laws and you use non-essential cookies such as analytics or advertising, you generally need consent before setting them. Get legal advice for your specific situation.

I use AdSense. Which banner should I use?

Google requires a Google-certified consent management platform for personalised ads to visitors in the EEA, UK and Switzerland. AdSense's own Privacy & messaging tool provides one at no cost.

What is Google Consent Mode?

A way for Google tags such as Analytics and Ads to adjust their behaviour based on the visitor's consent choice. Many consent plugins support it.

Is a banner that only says 'we use cookies' enough?

Usually not where consent is required. Visitors need a real choice, including rejecting, and tracking should not run before they agree.