Website DIY - tricks and solutions

A WordPress cookie notice that is only displayed to EU visitors.

Many websites will have received an email informing them of Google’s new Ads policy requiring sites using Adsense to obtain cookie consent from European “End Users” (visitors) to “comply” with EU Law. i.e. add a cookie bar to your pages.

An increasing number of sites are displaying these bars – I don’t feel empowered they are just an irritating distraction. If much of your audience is outside the EU you’ll want to spare them the annoyance and only display a cookie notice to Europeans.

Make your WordPress Site display a Cookie Law bar only to visitors located in the EU

If you are using a caching plugin read this first

1. Install the Cookie Notice and Category Country Aware WordPress (CCA) plugins.

The CCA plugin identifies your visitor’s location, and tells Cookie Notice when to display the EU Cookie Law bar. Cookie Notice displays your customized bar.

2. Configure Cookie Notice to display the bar with your choice of text and options in an appropriate style and position for your site.
Dashboard->Settings->Cookie Notice customise and save settings.

3. Set the CCA plugin to control Cookie Notice output.
Dashboard->Settings->Category Country Aware

(On first use of CCA plugin only: go to the “General” tab and check the “Intialize GeoIP” box and Save Settings. then:)

Open the “Countries” tab, scroll down, enable Cookie Notice check box and save settings. If you wish you can also edit the list of “EU country codes”.

*** Job Done***

4. A quick test to ensure its working:
Fig 1: Testing Cookie Notice Output

Just add or remove the country code for your location from the list of countries and save settings, and go to one of your posts. If the list includes your country code the bar will be displayed, otherwise it won’t. Don’t forget to change the list of counties back to its original setting.

If you are using a caching plugin

Using caching plugins other than Zen Cache and WP Super Cache?
Then you shouldn’t use this solution. Caching plugins do not usually work with server geo-location; they take a “snapshot” (cache) of a page when it is first visited and all subsequent visitors see the same snapshot. If the first visitor was from Germany then the snapshot will include the cookie bar and your visitor from US will be served this snapshot and also see the cookie bar.

Using Zen Cache or WP Super Cache:
If you are using ZenCche you can install the Country Caching extension whch makes it country (and EU) aware. There is also an extension to WP Supercache it will work but I’ve yet to modify it (next week?) to do the job efficiently for a group like the EU.

More about the CCA plugin

Yep I’m the author. Most of the sidebar content on this page is provided by CCA widgets, what is displayed depends upon the category of the page and where you are from (if you view my posts on Chinese Phablets you will see different sidebar content).
You can also have responsive ads within posts that only appear on small devices. and much much more. More on its capabilities in this post.

1 Comment

  1. Thank-you so much for this. My blog has mostly US visitors and a minority of EU visitors. I was looking for a solution to geo-target EU visitors, so as to comply with Google’s adsense policy. Yours worked perfectly.

Leave a Reply

Your comment will appear after its approved; usually within 12 hours but can be up to a week.
Your email address is optional and will not be published.

Copyright © 2015-2018  Means.Us.Com
This site recommends and is hosted by: Kualo Web Hosting.    
Theme: hemingway

Blog home  |  ↑ Top of Page ↑