Google Ads Not Displaying

I’m seeing the following error when verifying why google ads are not displaying.

Refused to load the script 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js' because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'report-sample'

I’m not a coder or anything. I’ve tried some suggestions for adding meta tags for Content Security Policy but those seem to break the entire site even more.

Any suggestions? I’m using the default Light theme with a version 2.3.0.beta9 that is used on Digital Ocean marketplace.

Did you install Official Discourse Advertising Plugin not showing adsense ads or are you trying to create ads some other way?

I’ve tried both. I installed the official ads plugin and added my own google script code in the /head under customizations.

I just discovered the content_security_policy setting as well and disabled it, was still getting errors but that was with my script in the /head, disabling that now and trying with the plugin settings.

Seems the errors are gone. Do I have to create ad units to throw in the ad unit # or if I set these as responsive should they start loading by chance?

Ah, looks like it’s now loading some ads. I think I found the magic fix. :slight_smile:

For anyone who runs into the same issues, steps to get ads going seems to be:

  1. Disable content_security_policy
  2. Make sure the official Ad plugin is installed and active.
  3. Create ad unit’s for mobile and desktop to place in the ad settings for use.

Seems if you try doing meta http-equiv="Content-Security-Policy" in your head tags, it still complains about the policies if the security policy is enabled in the admin settings.

Note that you make your site vulnerable to hackers if you disable CSP entirely.

Yes.

In my case my own CSP in my head tags were being overwritten by the CSP being enabled.

Disable in admin settings, setup CSP in headers or configure your own within nginx, etc.

Я столкнулся с той же проблемой.

Довольно раздражает, что предлагается плагин для рекламы, но при этом в нём нет ни слова о настройке CSP. Похоже, вам остаётся только самостоятельно бродить по диким дебрям багов, верно?

Почему бы не написать пользователям в README плагина для рекламы: «Вам необходимо настроить CSP»?

Плагин для рекламы должен сам обрабатывать записи CSP для AdSense или соответствующей рекламной платформы.

Включение CSP по умолчанию — это относительно новая и важная функция безопасности, поэтому нам следует обновить нашу документацию.