Google Ads
How to authorize and deny custom ads based on the user consent
In its last version, Google Ads ask for consent in accordance with GDPR, and it's necessary to have this consent before launching the script.
In that case, it is necessary to add this script to your page :
1
<script type="text/javascript">
2
(adsbygoogle = window.adsbygoogle || []).pauseAdRequests = 1;
3
(_axcb = window._axcb || []).push(function(sdk) {
4
sdk.on('cookies:complete', function(choices) {
5
if (!choices['Google Ads']) {
6
window.adsbygoogle.requestNonPersonalizedAds = 1;
7
}
8
window.adsbygoogle.pauseAdRequests = 0;
9
});
10
});
11
</script>
Copied!
You will need to load this script preferably in the <head> section of your site, independently of Google Ads. As soon as the user will give his consent, the Google script will go back to its usual behavior and will send the ad requests to its servers.
This script is a simple adaptation of the documentation given by Google here at the following address : https://support.google.com/adsense/answer/9042142?hl=en&ref_topic=7670012
Last modified 8mo ago
Copy link