Open main menu

Extension talk:Google AdSense

About this board


/Archive (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) (talkcontribs)

You must write like this:

$wgGoogleAdSenseSlot = '69837836xx'; $wgGoogleAdSenseID = 'WikiSidebar'; (talkcontribs)

google adsense shwoing 400() error in consolen window

Reply to "Ads not showing"

This extension got my adsense account disabled

3 (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

Summary by Jkmartindale

It was a new AdSense item, so it took a few hours for it to start showing up. (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: Any suggestion? (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.

Dkpat (talkcontribs)

Just a report that the extension is sometimes loading the Ad below all the other page content in MediaWiki 1.26.2. If anyone has any idea why this might be, I would greatly appreciate the help! As far as I can analyze, I don't see a reason for this to suddenly have started occurring.

Reply to "Ad loading below page in 1.26"
Icerat (talkcontribs)

Anyone tried this extension with the responsive ad type?

Reply to "Responsive ads"
Sakshale (talkcontribs)

To comply with Google's usage requirements, you need to change the portlet's label from "google adsense" to "Advertisements". A discussion of the issue, with two simple line changes, can be found on the google forums.

See: Mediawiki Extension:Google AdSense

Reply to "Change Portlet Label"
TraaBBIT (talkcontribs)

My page is:

I installed this extesnion and added this code to LocalSettings.php:


require_once "$IP/extensions/GoogleAdSense/GoogleAdSense.php";

$wgGoogleAdSenseClient = 'ca-pub-373458718679XXXX';

$wgGoogleAdSenseSlot = '8263716XXX';

$wgGoogleAdSenseID = 'Wiki Westeros 2';

// Width of the AdSense box, specified in your AdSense account

$wgGoogleAdSenseWidth = 120;

// Height of the AdSense box, specified in your AdSense account

$wgGoogleAdSenseHeight = 240;

// Source URL of the AdSense script

$wgGoogleAdSenseSrc = "";

// Show the AdSense box only for anonymous users

#$wgGoogleAdSenseAnonOnly = true;

#$wgGoogleAdSenseClient = 'replace this with the client name';

#$wgGoogleAdSenseSlot = 'replace this with the slot name';

#$wgGoogleAdSenseID = 'replace this with your ID';

But GoogleAdsense still doesn't show on my page.

Reply to "Google AdSense doesn't shows" (talkcontribs)

Install the plugin, changed the parameters to my designed advert and nothing appears on the wiki?

What steps am i missing? Do I need to put specific code into my sidebar?

This post was posted by, but signed as DG.

Reply to "Nothing appears"

How to make GoogleAdsense 2 display ads on content pages only

7 (talkcontribs)

Thanks for the Google AdSense 2 extension, it works great! However, I have a question you may have an answer to:

I would like ads to be shown only on pages in the NS_MAIN namespace. Can this be done in GoogleAdSense.php or in LocalSettings.php? If so, how?

According to Google's current AdSense Terms and Conditions ads should not display on non-content pages, which does not necessarily include various system or even search pages etc. If they are, the publisher may risk having their account terminated.... I guess this was something that Google introduced after you originally wrote the extension.

Thanks in advance for any advise!

Siebrand (talkcontribs)

There are no limitation options in the extension at the moment. What you can do is use robots.txt to block them from spidering parts of your wiki, and consequently, no ads will be placed on pages where the spider is blocked.

Alternatively, you can consider creating a patch that will only add the portlet on pages in $wgContentNamespaces. (talkcontribs)

Thanks for the tips. However, modifying robots.txt for this particular purpose alone sounds to me a less than an ideal solution. I'm not quire sure how to create a patch. However, adding the following in GoogleAdSense.class.php this seems to do the trick:

global $wgTitle;
                if ($wgTitle->getNamespace() != 0) {

                return $bar;
} (talkcontribs)

Does anyone know what the best way to achieve this would be now that $wgTitle has been deprecated in 1.19?

FloydlawsonMB (talkcontribs)

I was able to use the following in GoogleAdSense.class.php to replace $wgTitle:

	// Keeps blank pages from showing AdSense
       if ( $skin->getTitle()->getNamespace() != 0) {
           return $bar;

I hope that helps.

This post was posted by FloydlawsonMB, but signed as Floydlawson.

In Correct (talkcontribs)

HELP!! I do not know where to enter these codes. I have tried BOTH of them. Am I entering them in the wrong location in the GoogleAdsense.class.php file?! I am STILL getting ads on non content pages. What a dumb extension. It should ALREADY be able to display ads on the main article pages. Instead, it displays ads on ALL of them. This includes talk pages and history pages.

Zimbres (talkcontribs)

I read about this function and I think it could imput the Adsense in the body of the article. =========================

 $wgExtensionFunctions[] = "wfassExtension";
 function wfassExtension() {
 global $wgParser;
 $wgParser->setHook( "adsensesearch", "renderass" );
 function renderass( $input, $argv ) {
 $output = '
 <script type=\"text/javascript\"><!--
 google_ad_client = \"xxxxxxxxxxxxxx\";
 google_ad_width = 728;
 google_ad_height = 90;
 google_ad_format = \"728x90_as\";
 google_ad_type = \"text_image\";
 google_ad_channel =\"\";
 google_color_border = \"F7DBBC\";
 google_color_bg = \"F7DBBC\";
 google_color_link = \"60442D\";
 google_color_url = \"60442D\";
 google_color_text = \"60442D\";
 <script type=\"text/javascript\"
 return $output;

Anyone has any idea how to improve it?

Reply to "How to make GoogleAdsense 2 display ads on content pages only"
Return to "Google AdSense" page.