I have a Wordpress site and have just installed a cookie banner to get consent. I have a few questions about this though, what do I do if somebody clicks "reject"? How do I stop showing them the Adsense on my website?

Does this need to be done through coding? I am aware Adsense have created a new code which needs to be added before all adverts which essentially says "check if this person is okay to receive adverts", so is that all I need to do?

I've searched a lot for this particular question but can't find an answer and I want to ensure I am GDPR compliant.

  • Do you need to "stop showing Adsense if they reject cookies"?
    – DocRoot
    Jun 12, 2018 at 14:28
  • Yes as the cookie policy and next year's EU law means I'm technically in the wrong for not doing so already.
    – Jade
    Jun 14, 2018 at 4:39

1 Answer 1


You can do this by loading your scripts using a simple if cookie check, e.g

  • Thanks, does this mean the banner can just say 'we use cookies' then run a script which checks? There's no interaction between the banner and the script? Is the above script correct if I were to c&p or do I need to do a but more googling?
    – Jade
    Jun 14, 2018 at 4:37
  • It means that PHP or JavaScript will check the ability to 'write a cookie' then if 'TRUE' then it loads the Adsense JavaScript. PHP is my preferred method and not you can't copy and paste, you need to write the code, use Stack Overflow as programming related questions are off-topic on Pro Webmasters. Jun 14, 2018 at 10:20
  • 1
    This assumes users have actively blocked cookies in their browser, which is not usually what happens when a user responds to a "cookie banner" on a website (as stated in the question). If the user has actually blocked cookies in the browser then there is no reason to block Adsense, since no third party cookies will be set anyway (the Adsense served will just not be "personalized"). GDPR isn't about blocking adverts/AdSense, it is about blocking non-essential cookies (that personalized adverts are dependent on). Non-personalized adverts can still be served with cookies disabled.
    – DocRoot
    Jun 15, 2018 at 0:09
  • "PHP is my preferred method" - although you can't determine whether cookies are writeable on the initial request using a PHP-only solution. However, whether cookies are physically writeable or not is not what the question is asking.
    – DocRoot
    Jun 15, 2018 at 1:36
  • @DocRoot that's true but I meant to say I prefer using PHP with JS, but the even better method which I've used lately is GTM. Jun 15, 2018 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.