Extension talk:Google AdSense

Jump to navigation Jump to search

About this board

Archives 

/Archive

Unmaintained but another option:

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

};
Reply to "Unmaintained but another option:"

Position in MediaWiki:Sidebar

2
37.209.65.246 (talkcontribs)

Hi there,

how can I Change the Position in the MediaWiki:Sidebar. I would like to have the ads on top of my sidebar.

I tried some stuff like:

* googleadsense

* googleadsense-portletlabel

* Advertisements


I can't figure out how I can change it... with googleadsense-portletlabel I saw my changed Text "Sponsored Link"


Someone can help me with that?

cheers

Andreas

TiltedCerebellum (talkcontribs)

The extension is meant to insert it in a specific place, if you don't want to do that you might try using a hook instead of the extension. Manual:Hooks/SidebarBeforeOutput

Reply to "Position in MediaWiki:Sidebar"

Google keeps rejecting my site

2
Vapblack (talkcontribs)

Is there something specific I should be doing? I know I should be probably adding more info, but I don't know what.

TiltedCerebellum (talkcontribs)

That's what the extension page is for, to tell you how to use it. If something isn't working you need to be specific about what when you write on an extension's page or the extension maker can't help.

Extension:Google AdSense

Reply to "Google keeps rejecting my site"

Anyone else getting Error500?

3
185.209.178.78 (talkcontribs)

Anyone else getting Error 500? tried everything available in this site.

87.116.190.6 (talkcontribs)

I do. As soon as I enable line to load extension.

TiltedCerebellum (talkcontribs)

Are you making sure to use the correct extension version for your MW version?

Reply to "Anyone else getting Error500?"

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."
2601:86:300:A8BF:F942:3A0:1B72:CD9 (talkcontribs)

Hi,

The script should call the ad script asynchronously, per google recommendation:


<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

</ins>

<script>

(adsbygoogle = window.adsbygoogle || []).push({});

</script>

Reply to "Async"
77.102.194.175 (talkcontribs)

I believe I have set this up correctly however the ads are not showing on the site - In google chrome I only see the "google adsense" header and in internet explorer I see an error 400

My account has just been approved so the code must be there - My Local settings is as follows - Last 2 numbers of each number removed on here

#Google Adsense
require_once( "$IP/extensions/GoogleAdSense/GoogleAdSense.php" );
$wgGoogleAdSenseClient = 'pub-99264879323815xx';
$wgGoogleAdSenseSlot = 'WikiSidebar';
$wgGoogleAdSenseID = '69837836xx';

Is the problem here? Lordmwa (talk) 07:03, 1 June 2013 (UTC)

85.237.37.175 (talkcontribs)


You must write like this:

$wgGoogleAdSenseSlot = '69837836xx'; $wgGoogleAdSenseID = 'WikiSidebar';

103.251.48.13 (talkcontribs)

google adsense shwoing 400() error in consolen window

Itwan (talkcontribs)

.

Reply to "Ads not showing"

This extension got my adsense account disabled

3
12.53.161.4 (talkcontribs)

I have no idea what I did wrong other than use this extension. Hopefully future versions of this extension will adhere to the Google Adsense ToS so this doesn't happen to anyone else.

Gboyers (talkcontribs)

Did you click on the ads yourself? That seems to be the reason for a lot of suspensions.

Jkmartindale (talkcontribs)
Reply to "This extension got my adsense account disabled"
Summary by Jkmartindale

Updated on extension page

Tahongawaka (talkcontribs)

What file do I want to require_once?

Page not found in google AdSense box

2
Summary by Jkmartindale

It was a new AdSense item, so it took a few hours for it to start showing up.

87.12.108.30 (talkcontribs)

Hi, I have installed the extension on a wiki. My AdSense is new, so it is under review. The problem: in firefox I see the empty box, as expected. In internet explorer, or opera, I have an error message in the box. What kind of problem can this be? Mediawiki is version 1.19.3 PHP is: 5.2.6-1+lenny9 (apache2filter)

Page with all versions is here: http://www.vafud.com/wiki/Speciale:Versione Any suggestion?

87.12.108.30 (talkcontribs)

Never mind. After few hours it started working. Probably because it was a new adsense item. If you wish delete this discussion, or leave it for knowledge.