Page 1 of 2

Cannot get Google AdSense to work

Posted: August 20th, 2009, 10:13 pm
by ned4spd8874
Hello, I am new to MediaWiki and am still struggling with a few things. The main thing I am trying to do right now is add Google AdSense ads to my page. I have installed the extension, but it doesn't seem to be working. The one thing that confused me was the "unitid" part. I guess I just don't understand it.

I only want one ad on my page. It's a verticle skyscraper type ad. I put in the id, but the ad still doesn't show. I'm not sure what I'm doing wrong. Can someone please help me?

Code: Select all

$ADSENSE_UNITS = array(
	// Text and image ads - 728x90
	'C01' => array('unitID' => 'xxx', 'width' => '728', 'height' => '90', 'position' => 'none'),
	// Text and image ads - 728x90
	'C02' => array('unitID' => 'xxx', 'width' => '728', 'height' => '90', 'position' => 'none'),
	// Text and image ads - 728x90
	'C03' => array('unitID' => 'xxx', 'width' => '728', 'height' => '90', 'position' => 'none'),
	// Text ads - 728x90
	'C04' => array('unitID' => 'xxx', 'width' => '728', 'height' => '90', 'position' => 'none'),
	// Ad links - 728x90
	'C05' => array('unitID' => 'xxx', 'width' => '728', 'height' => '90', 'position' => 'none'),
	// Text and image ads - 234x60
	'C06' => array('unitID' => 'xxx', 'width' => '234', 'height' => '60', 'position' => 'none'),
	// Text and image ads - 120x600
	'C07' => array('unitID' => 'WATC', 'width' => '120', 'height' => '600', 'position' => 'none'),
	// Search your domain - 400x29
	'S01' => array('unitID' => 'xxx', 'width' => '400', 'height' => '29', 'position' => 'none'),
	// Search web - 400x29
	'S02' => array('unitID' => 'xxx', 'width' => '400', 'height' => '29', 'position' => 'none'),
	// Video Unit - Auto - 488x485
	'V01' => array('unitID' => 'xxx', 'width' => '488', 'height' => '485', 'position' => 'none'),
	// Video Unit - Entertainment - 488x485
	'V02' => array('unitID' => 'xxx', 'width' => '488', 'height' => '485', 'position' => 'none'),
	// Video Unit - Sports - 488x485
	'V03' => array('unitID' => 'xxx', 'width' => '488', 'height' => '485', 'position' => 'none'),
);

Re: Cannot get Google AdSense to work

Posted: August 21st, 2009, 8:49 pm
by Paul
You need to setup Unit ID in Google fist, how? Go to google to check it out how it works.

Re: Cannot get Google AdSense to work

Posted: August 21st, 2009, 10:28 pm
by ned4spd8874
Paul wrote:You need to setup Unit ID in Google fist, how? Go to google to check it out how it works.
I already did. I don't think I quite understand where to put it in the file.

Re: Cannot get Google AdSense to work

Posted: August 22nd, 2009, 11:22 am
by mgudelis
Hi, I'm also having the same problem/challenge, is there any guide with regard to this we can read? Thanks

Re: Cannot get Google AdSense to work

Posted: August 23rd, 2009, 9:12 am
by Paul
OK, then in your Google Adsense screen, you should be able to find your Publisher ID.

The Unit ID is the ID if you create a Ads unit, please see my instruction at page http://paulgu.com/wiki/Google_AdSense, release "xxx" with your unit ID, use the right size according to your ads unit, you can remove other item in the array that you don't need.

If you only have one unit id, then it will like:

Code: Select all

$ADSENSE_UNITS = array(
   // Text and image ads - 728x90
   'C01' => array('unitID' => '123456', 'width' => '728', 'height' => '90', 'position' => 'none')
);

Re: Cannot get Google AdSense to work

Posted: September 1st, 2009, 3:47 pm
by editor
Have added the id to the adsense unit and it shows up blank in firefox and web page not found in IE. If I leave the unitID blank in the .php I then get an advert showing.

I have been using google adverts for some time and the old adverts used to have the ID in the code so it was simple to change, but now this is replaced by a google_ad_slot code. You can find the IDunit in the manage channels page on google ads.

Re: Cannot get Google AdSense to work

Posted: September 1st, 2009, 5:46 pm
by Paul
The google_ad_slot id is the Unit ID that you need to add in the $ADSENSE_UNITS array, the id will be automatically populated in the google_ad_slot id on the page.

Re: Cannot get Google AdSense to work

Posted: January 6th, 2010, 8:43 pm
by AAadvisor
Hello
I am also having problems with the adsense extension.

I have checked the intructions numerous times but no ads are displaying on my site. I have used adsense before successfully on other sites so must be something I am doing wrong.

I have included the code below:

$ADSENSE_UNITS = array(
// Text and image ads - 728x90
'C01' => array('unitID' => '0404134656', 'width' => '728', 'height' => '90', 'position' => 'none'),
);

Does the 'position' need to be defined?


I also wondered if the below code should have anything between the inverted commas such as the ID?

$ADSENSE_UNIT =''; // initialize

i am also not receiving any error messages and the site runs as normal but without any sign of adsense. Any help would be greatly appreciated.
Thank you.

Re: Cannot get Google AdSense to work

Posted: January 6th, 2010, 9:54 pm
by Paul
The unitID needs to be your Ads unit id, width and height need to match your ads, leave position as default...

Then go to your wiki and activate it....

Re: Cannot get Google AdSense to work

Posted: January 7th, 2010, 1:45 pm
by AAadvisor
Thanks for your quick response. I believe i have included the correct unit Id (as in the example in my post). The width and height also matches the ad.
However when you say go to the wiki and activate it what do you mean?

Does this involve adding further code to one of the other php files?

I have already added the code to the localsettings.php file:
(include_once('extensions/GoogleAdSense/GoogleAdSense.php');)


This may be where I am going wrong.

Thanks again.