0

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"
style="display:inline-block;width:728px;height:90x"
data-ad-client="ca-pub-****************"
data-ad-slot="6440411535"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
EOT;
    return true;
};

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

What is likely to go wrong?

0

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, privacy policy and cookie policy