Topic on Extension talk:Google AdSense

Unmaintained but another option:

3
TiltedCerebellum (talkcontribs)

I searched high and low for an extension that worked for MW 1.33 a while back but couldn't find one. Finally landed on using hooks instead. Putting this in LocalSetting.php appears to work for first approval or-auto ads:

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

function onBeforePageDisplay( OutputPage &$out, Skin &$skin )
{
    $script = '<script data-ad-client="ca-pub-XXXXXXXXXXXXXXXX" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>';
    $out->addHeadItem("wowhead script", $script);
    return true;

};
Vapblack (talkcontribs)

how is it working? Does it only put ads on the sidebar, like the extension is supposed to?

TiltedCerebellum (talkcontribs)

The extension? I'm not sure anymore, I stopped using it. When I used it, it worked fine though. The code sample above was just adding the code to the header to get Google ads to recognize the code on the site and to get approval. After that we placed code in different places to achieve what we were after.

We additionally placed ads in the wiki site notice using a widget, then at the footer of each page using a hook, described in this:

https://www.mediawiki.org/w/index.php?title=Topic:Vs7flcolkyiqya4q&topic_showPostId=vszc744jazh6ppjh#flow-post-vszc744jazh6ppjh

Reply to "Unmaintained but another option:"