Topic on Project:Support desk

Jump to navigation Jump to search

Easiest way to add Adsence for Mediawiki

13 (talkcontribs)

Hi, I have a mediawiki project (1.31) with Vector skin. What is the easiest way to add Adsence to my project? I'd like to have text ads in the left sidebar.

AhmadF.Cheema (talkcontribs) (talkcontribs)

Ahmad, thank you.

I read these links. But the extension is marked as not maintained. Is it still working? (talkcontribs)

The Google AdSense extension seems to be not working. I installed it, but it doesn't put in the head the script needed to activate account. When I open page's code I don't see anything related to adsence. But the extension itself is installed as I see in version.

Fokebox (talkcontribs)

I use Extension that inserts script b/n <head>. And adsense automatically inserted to all pages. (talkcontribs)

Fokebox, thank you. Which extension are you using? Did you face problems with adsense account approval? I've inserted their script in the head of every page and got rejected on the "no content" basis. I suppose that this is because of the script in wikimedia service pages, that relly do not have much content.

Fokebox (talkcontribs)

No I don't have such problems while I have a content at my wiki website.

I use this extension: Extension:HeadScript

Than I use automaticaly added adsense block script (auto ads):

So when you create any new wikipage google ads adsense block automaticaly (talkcontribs)

So you got accepted to adsense with you wiki website and script on all the pages? You didn't have adsense account approved through some other website?

Fokebox (talkcontribs)

I have registered account some years ago and it was approved by other website, that does not exist any more and now I use this account for my couple wiki projects, works fine (talkcontribs)
AhmadF.Cheema (talkcontribs)
TiltedCerebellum (talkcontribs)

I searched high and low for an option to get the intial approval code in the head tags where it states it is need for first approval (not even posting the ads yet) but couldn't find one. Yes, there are other methods (better methods) for placing the actual ads, but if Adsense doesn't see the initial approval code in the header they disregard it (apparently). No I don't have ads on my site yet, and yes I know there's a better way to the ad placement part once approved. I just needed something quick and dirty for initial approval, then I could swap to a recommended solution. Putting this in LocalSetting.php appears to work for first approval:

# Assign my functions to hook
$wgHooks['BeforePageDisplay'][] ='onBeforePageDisplay';

function onBeforePageDisplay( OutputPage &$out, Skin &$skin )
    $script = '<script data-ad-client="ca-pub-XXXXXXXXXXXXXXXX" async src=""></script>';
    $out->addHeadItem("wowhead script", $script);
    return true;


After approval, removing that code and just using hooks to properly place the ads where I need them since they don't need to live in the head tags at all :)

Fokebox (talkcontribs)

I use automatic adding of ads to my wikis. All you need is just to add a special code provided by google b/n head tags

Reply to "Easiest way to add Adsence for Mediawiki"