Jump to content

Topic on Extension talk:Google AdSense/Archive 2

what it the main concept of side bar ad.

2
2001:8F8:1E23:DE9:28:C70:94FF:F3EF (talkcontribs)

what about having this extension to be extended more, there is no point of having a small add displayed at side bar, people wanted an extension to generate some income in order to cover running cost, having one tiny small ad displayed at side bar will bring no value, in addition, you are only adding more page load time by loading google stuff for one ad!!!!!

still i can see many wikis running ads, and their Ads are showing on top, bottom, and even in article it self, the question here, why there is no explanation about this, how to do it and get it done in a proper way.

if you googled wordpress adsense plugin, you will get tons of them, i'm not comparing wordpress with mediawiki, but both of them are php, but they know how to market them self, and get more people on board.

TiltedCerebellum (talkcontribs)

In-page Google Adsense (GA) auto-ads probably work just fine, or they may be embedding them manually from manually created ads, that's what we initially did. After initial activation, for manual ads, adsense code can be added to a Widget which allows code to be inserted into a wiki, then the widget embedded in the site notice for example. Though an easier way is to enable the code in the site's header via a hook, then to turn on and configure auto-ads. If people want precise locations, then they are looking at cobbling together hooks and/or extensions (I assume this is what the extension is for because getting sidebar stuff to show up can be tricky) or editing skin files. Though skin file edits will be wiped out when the skin is updated which is not ideal, so keeping a copy of the edited file for reference is a good idea.

Since different skins use different code (made by different people and not by the makers of MediaWiki), they probably can't make a universal extension that just "works" out of the box for everywhere, the code is too different from skin to skin for some things. It is what it is.

For auto-ads or initial GA approval where they ask you to put code in your site's header, the following hook can be put in the LocalSettings.php (with the appropriate parts changed):

# 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;

};

Lots of people use hooks to get ads where they want, the sidebar is the trickier part sometimes when it refuses to show.

This is an example of a footer hook used to insert a controlled-size (manually created) ad (though it could be rewritten to show an responsive or automatically resizing manual ad if someone doesn't want to use auto-ads):

$wgHooks['SkinAfterContent'][] = function(&$data, $skin) {
	    $data = '<div class="gas-bottom">';
	    $data .= '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>';
		$data .= '<ins class="adsbygoogle gas-bottom-first"
            style="display:table; width:728px; height:90px; margin:1em auto; clear:both;"
            data-ad-client="ca-pub-XXXXXXXXXXXXXXXX"
            data-ad-slot="XXXXXXXXXX"></ins>';
		$data .= '<script>
        (adsbygoogle = window.adsbygoogle || []).push({});
        </script>';
		$data .= '</div>';
        return true;
};
## -- Adsense footer end -- ##

We extend through hooks, which are used to write extensions, or to write small bits of code yourself to extend MediaWiki functionality.

Reply to "what it the main concept of side bar ad."