Prompted by revised privacy legislation, some websites that include Google AdSense want to allow visitors to control whether ads shown are personalised or not.

This module cannot do the work of ensuring you comply with all applicable privacy legislation, including GDPR, and it cannot ensure you comply with Google's User Consent Policy. What it does do is provide some of the technical tools you may need as you seek to implement an approach that you believe does comply.

As it stands, this module does four main things

1. Control whether your site will serve AdSense ads that are personalised or not personalised. You can choose to have non-personalised ads throughout. Alternatively, you can create a default behaviour, and allow visitors to your site to change to their own preference if they wish.

To that end, the module creates a page, accessed at /ad-options. This page will display a list of links to the privacy policies of all the third party ad networks you use. (You will need to enter the data for that list as a CSV. Google let you download such a CSV from your AdSense settings as applies to your account). It will display text of your choice above and below that list. If you've chosen to allow visitors to specify receiving (non-)personalised ads, it also contains a simple form so visitors can make their choice.

2. Optionally implement Google's "Auto Ads", aka Page Level Ads, respecting the choice you and visitors have made as to whether the resulting ads should be personalised.

3. Optionally create a block that can be displayed in any block region, containing an AdSense ad unit of your choice.

In the Drupal 7 version of the module, there is a single block that you can place in any theme region you wish (or disable if you don't want it). The slot ID of the ad unit for the block is set in the module settings page. You can also specify up to three different ad units to be shown in rotation, if you want to run your own A/B experiments (or for any other reason). Again, choices to personalise, or not, are respected.

In the Drupal 8 version of the module, you can place as many AdSense blocks as you wish, in different theme regions. Each block you place shows ads of only a single ad unit. The slot ID of the ad unit is set in the block's configuration page.

4. Optionally, you can disable any ads until a visitor gives their explicit consent. You can receive this consent through a checkbox on the ad-options page, through the banner produced by the EU Cookie Compliance module, or give visitors a choice of both those methods.

Dependencies

The Drupal 7 version of the module is dependent on the Advanced Aggregation module, so that the Google javascript snippet can be inserted with the required "async" attribute

If you want to use this method to obtain visitor consent for ads, you need the EU Cookie Compliance module.

Note: This module inserts its own AdSense code, and is not designed to be used in conjunction with other modules that also do this. If you use other modules to insert AdSense script into your site, there is no guarantee that the preferences of visitors to your site will be respected.

Support

I developed this module to use on my own sites, and then wanted to share it with the wider community in case it helps others. I'll do my best to fix any issues that may arise. Feature requests are more likely to be implemented if you can suggest a patch that gives the feature you're looking for.

Disclaimer

Disclaimer: This module comes without any warranty of any kind, including any warranty (implied or otherwise) as to its fitness for a particular purpose. In particular, whilst this module may help your website comply to privacy legislation in various jurisdictions, you and you alone are responsible for ensuring that your website complies with all necessary legislation.

Google and AdSense are trademarks of Google LLC.

Project information

Releases