Skip to content

The only Privacy solution for WordPress you can truly trust.

How to install Google AdSense in compliance with GDPR

Attention: Pro Features
This type of Cookie is supported only in the Pro and Reseller versions of My Agile Privacy. Purchase your license and gain access to the entire database of pre-inserted cookies, constantly updated by the experts at My Agile Privacy.
>> Click here and find the plan that suits you best.
Google AdSense code

This post talks about:

Google AdSense enables you to monetize your website traffic by displaying ads from Google’s advertising network.
These ads are personalized based on user interests, which means you must obtain explicit user consent before activating such scripts.

Learn how to install GDPR-compliant Google AdSense on your website using My Agile Privacy®.

Solution 1 – Automatic Scan

Take advantage of the advanced “Cookie Shield” feature, which can automatically detect Google AdSense.
Set the Shield to “Learning” mode, browse your site’s pages, and the plugin will configure everything for you.
Alternatively, manual configuration is available.

Solution 2 – Manual Configuration

Part 1 – Your Google AdSense Code

After signing up for Google AdSense, you will receive a JavaScript code to insert on your site.
The code will look something like this:
Google AdSense code

Part 2 – Adding the Google AdSense Cookie in My Agile Privacy®

In your WordPress admin area, go to My Agile Privacy® → Cookie List from the left menu.
Here you’ll find a list of cookies imported during plugin installation, all initially set to draft.
Publish only the cookies relevant to your website.
cookie list
The cookie list includes columns such as:

  • Cookie Name: the name of the cookie.
  • Is Necessary: shows if the cookie is essential for your site to function properly. If rejecting the cookie breaks your site, it’s essential; this is pre-filled for each cookie.
  • Auto Update: indicates if the cookie reference text is updated automatically for GDPR compliance. If set to “yes,” the plugin keeps everything up to date.
  • Installation Type: indicates the method to include the cookie. This varies depending on your setup and is explained in the guides.

To add the Google AdSense cookie, find the entry named “Google AdSense (Google Inc.)” and click on it.
On the detail page, you’ll find a pre-filled informational message and two blank fields for entering your code.
This message will appear in your cookie policy and will be kept up to date automatically if “Allow Automatic Update” is enabled.
Just below, select the “Type of Installation” (JavaScript and Noscript, or Raw).
Pick “Raw Code” from the dropdown, and a field called “raw html code” will appear.

Part 3 – Entering Your Google AdSense Code

Simply copy your Google AdSense code and paste it directly into the “Raw Html Code” field.
entering the raw code
Don’t forget to save and publish the cookie by clicking the blue “Publish” button in the upper right corner.

Final Step – Verifying Proper Operation

To confirm that Google AdSense is working correctly, check the ads displayed through your Google AdSense control panel.
Ads will only be shown after the user has given explicit consent for the Google AdSense cookie.
Users can provide consent by clicking “I agree” on the cookie acceptance bar or by enabling the cookie under “Customize” in the My Agile Privacy® cookie bar.

Beware of Penalties

For publishers using AdSense, Google requires a certified CMP integrated with the IAB TCF to serve personalized ads in the European Economic Area, the UK and Switzerland; without it, that traffic receives only limited or non-personalized ads. Find out more here.