Extension talk:Google AdSense/Archive 2

About this board

Archives 

/Archive

Can't get Adsense Extension to work.

7
Summary by WikiForMen

Google AdSense Scheme has changed!

At the moment:

"This extension is incompatible with MediaWiki 1.39 or any later release!"
Gomez Adams 67 (talkcontribs)

I can not get this to work at all. Brand new install of 1.35.

The Version page shows the extension installed and working. Here are my entries in the LocalSettings.php file:

$wgGoogleAdSenseClient = "ca-pub-xxxxxxxxxxxxxxxxxxxxx";

$wgGoogleAdSenseSlot = 'WikiSidebar';

$wgGoogleAdSenseWidth = 120;

$wgGoogleAdSenseHeight = 240;

$wgGoogleAdSenseSrc = '//pagead2.googlesyndication.com/pagead/show_ads.js';

$wgGoogleAdSenseID = 'none';

$wgGoogleAdSenseEncoding = "utf8";

$wgGoogleAdSenseLang = "en";


Absolutely nothing happens. I've tried the different skins installed and nothing shows up, not even the 'Adsense' title in the side bar.


Any help would be greatly appreciated.

WikiForMen (talkcontribs)

May be you configured your browser to block ads?!?? In this case absolutely nothing will happen. ;-) --WikiForMen (talk) 21:06, 17 May 2021 (UTC)

WikiForMen (talkcontribs)
Gomez Adams 67 (talkcontribs)

Of course my browser isn't set to block ads.

I tried your WimaAdvertising plugin and it works for top and bottom but not the sidebar. Is there any way to get rid of the "advertising" word and the black box outline? I'd rather just have the ads there without that.

Thanks!

WikiForMen (talkcontribs)

Using WimaAdvertising you should add AD1 into the MediaWiki:Sidebar! Please read the "Use" part! You can set your own CSS style specifications at $wgBannerTopStyle. --WikiForMen (talk) 11:09, 19 May 2021 (UTC)

Gomez Adams 67 (talkcontribs)

Thanks! I'm new to this and learning as I go. That did the trick!

WikiForMen (talkcontribs)

Undefined variable: GoogleAdSenseLang in GoogleAdSense.class.php

5
Summary by WikiForMen

Problem solved!

TheAlmightyGuru (talkcontribs)

I just upgraded to MediaWiki 1.35 and updated the Google AdSense to 1.35, but I keep getting this error multiple times, along with undefined variable for GoogleAdSenseEncoding.


I load the extension with the following code:

wfLoadExtension( 'GoogleAdSense' );

$wgGoogleAdSenseClient = 'pub-5737815xxxxxxxxx';

$wgGoogleAdSenseSlot = '1234xxxxxx';

$wgGoogleAdSenseID = 'myIdName';

$wgGoogleAdSenseWidth = 120;

$wgGoogleAdSenseHeight = 600;

$wgGoogleAdSenseSrc = '//pagead2.googlesyndication.com/pagead/show_ads.js';

$wgGoogleAdSenseAnonOnly = true;


I've tried setting values for the undefined variables in my LocalSettings.php, but it doesn't help. Any idea s?

WikiForMen (talkcontribs)

It is a bug! See here. This variables are misspelled on line 41-42 in file GoogleAdSense.class.php. --WikiForMen (talk) 05:43, 7 January 2021 (UTC)

TheAlmightyGuru (talkcontribs)

Thank you. I fixed the incorrect variable names, but I'm still not seeing the ads. I've changed the extension's status to unstable. Hopefully, someone will fix the bugs.

WikiForMen (talkcontribs)

Try Version 2.2b from extension WimaAdvertising. Should do the same but with better css integration in the sidebar and you can two ad units, additionally define its position in the MediaWiki:Sidebar file. --WikiForMen (talk) 02:54, 20 January 2021 (UTC)

WikiForMen (talkcontribs)
WikiForMen (talkcontribs)

This extention use hook SkinBuildSidebar to inject HTML into the sidebar.

"As of MediaWiki 1.39, injecting HTML is no longer supported with this hook. If you are looking to inject HTML, such as to put an ad in the sidebar, you must use Manual:Hooks/SkinAfterPortlet or similar."

The extentions has to be rewritten to support actual versions of mediawiki.

Reply to "Incompatibility"

Extension does not work on MediaWiki 1.37.

4
Costas Athan (talkcontribs)

I have a Mediawiki website, version 1.37, with the Timeless skin. I installed the Google Adsense extension yesterday and it appears listed as it should in Special:Version.


In the LocalSettings.php file I have added the following lines of code:

wfLoadExtension( 'GoogleAdSense' );

$wgGoogleAdSenseClient = 'ca-pub-xxxxxxxxxxxxxxxx';

$wgGoogleAdSenseSlot = 'xxxxxxxxxx';

$wgGoogleAdSenseSrc = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxxxx';


When I check the code of different Mediawiki's pages I don't see any Adsense code added, so obviously the extension does not work. Have I done something wrong or does the extension have an issue?

WikiForMen (talkcontribs)
Costas Athan (talkcontribs)

Thanks for the info. I will give it a try.

WikiForMen (talkcontribs)

Good luck. I haven't explicitly tested it with the Timeless skin. So I would be happy about a report. But using Hook SkinAfterPortlet, it should do the job.

After a test, I came to the conclusion that skin Timeless may not support hook SkinAfterPortlet.

Reply to "Extension does not work on MediaWiki 1.37."

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:"

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"
Return to "Google AdSense/Archive 2" page.