31 October 2007

How to solve Adsense bug showing 6 Adsense blocks

Recently i have noticed that google adsense has got a little bug. Earlier we could post as many Adsense for Content Ad units on a single page but only first three ads were shown And rest of code used to hide itself, but from last one month or so first 6 Ads are showing up with first 3 showing ads and other three Ad blocks either remain blank or show Page not found Error.

Lot of bloggers like me don't have much control on how many Ads are shown on each page if we embed the ads in each post.

I am hopeful that this will be solved as soon as possible because such blank spaces on website make it look very bad.

I have read about adsense split testing on one of adsense tips pages, and have found that this is alright with adsense.

To overcome the current issue i have written a short solution, though i am still waiting for a thumbs up

from adsense team before we can use it on our websites.

All i am doing is replacing the Ad unit with link unit after first 3 Ad units.

I have given it a short test and it works fine.

First of all add the follwing code in your Head element.

<head>
<script type='text/javascript'>
var varstr = 0;
</script>
</head>

After that you have to use the follwing code in every Content Ad unit, make sure you copy paste the whole Ad code variables i have left out colour and channel variables for now.

<script type='text/javascript'>
varstr = varstr + 1;
if (varstr < 4){
google_ad_client = "your pub-id";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
}else
{
google_ad_client = "your pub-id";
google_ad_width = 200;
google_ad_height = 90;
google_ad_format = "200x90_0ads_al";
}
</script>

Tip : Replace all { signs with & lt; remove the space between & lt;
You can give it a short test but please do not use it untill its confirmed that adsense is not against such code variations. I will update you guys on this whenever adsense support team replies to my email.

Any questions? please post them in comments section.