I use MediaWiki version 1.32.0 with PHP 7.1.30 (cgi-fcgi) and MySQL 5.6.40-84.0-log.
I try to add Adsense advertisements to the site's header, sidebar and footer.

At first I considered the Widgets extension but then decided to find an extension-free way.

I used the following code but Google Adsense test seems not to recognize it (a general error is given that "Google couldn't recognize your ads").
In LocalSettings.php I putted:

$wgHooks['SiteNoticeAfter'][] = function(&$siteNotice, $skin) {
    $siteNotice .= <<< EOT
<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
(adsbygoogle = window.adsbygoogle || []).push({});
    return true;

Instead the **************** is my pub_code.

What is likely to go wrong?

1 Answer 1


I had to add the basic script that allows my web site to communicate with the Adsense API to the <head> tag of my website by a nested <script> HTML tag.

After doing so I was asked to wait 3 days for site review, though one might not need that in the future.

Your Answer

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