Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google AdSense and AdBlock

I have Google AdSense ads on my site, and AdBlock blocks them, which is fine. When they are blocked, I would like to display alternate content. The problem is that when the ads are blocked, there are two things that can happen:

1) The ad is complete suppressed by AdBlock, the height and width of the AdSense ad are 0, and most of the AdSense code is not generated.

2) The AdSense ad content is blocked, but the height and width are set and the AdSense code is generated.

Option 1 is perfect because it allows me to check the height of the container, or for tags that AdSense renders, and show my alternate content if the height is 0, or if a specific AdSense tag doesn't exist. However, when option 2 occurs, I don't know what I can do to display my alternate content, and the AdSense ads take up their required height and width, but don't display any content, making my site look broken.

Has anyone else had any experience with this issue? My site is in .net 4.0 and I've only tested AdBlock in Chrome v12 so far.

like image 488
StronglyTyped Avatar asked Jul 18 '11 13:07

StronglyTyped


2 Answers

Sounds like you have option 1 covered (if height is 0, ajax in your own ads).

For option 2, isn't that add area blank or hidden?

So maybe something like this would work:

var adNode  = $('#Google_Ad_Container');

if ( adNode.is (':hidden')  ||  ! /\S/.test (adNode.text () ) )
{
    // Ajax in your ads here...
}
like image 140
Brock Adams Avatar answered Sep 21 '22 03:09

Brock Adams


Set a min-height/width and have the background of the box be an image / alt content (I assume it will be a message saying please whitelist us)

Set the image to no-repeat and background color to match the background of the image.

No matter the size of the box now, you'll have your message there.

I hope I made sense.

like image 34
Dorjan Avatar answered Sep 17 '22 03:09

Dorjan