views:

322

answers:

7

I was recently visiting a site and noticed that the page had a section that said it noticed that I was using AdBlocking software and could I kindly turn it off to help support a small site like that. I was just wondering how you would do that? Would it be best done client-side or server-side?

+2  A: 

I guess there are several ways of doing it, but probably the easiest one would be to have some kind of background image, or text, that will be replaced when the ad is loaded. Thus, if the ad gets loaded, you see the ad. If the ad doesn't load, you see the text.

This example would be client side, done by either JavaScript or just plain CSS might even suffice.

There might be some server-side gimmicks that could do this too, but they would be unnecessarily elaborate and clunky. One method that springs to mind would include some kind of API with the advertiser that could be asked "did the user from IP such.and.such load any images?" and in that way get the answer. But I doubt there's such services - it would be much easier to do on the client side.

Henrik Paul
+2  A: 

You could do it on server side by pairing requests for html pages and for the acording ads (probably with some unique identifiers to each request ...) ... But this is just an idea, i've never tried it and never even seen it used.

cube
+3  A: 

I found this part in the code which seems to look like how they did it:

/*MOOTOOLS*/
window.addEvent('domready', function(){

$$('.cat-item').each(function(el) { 
    var fx = new Fx.Morph(el,{ duration:300, link:'cancel' }); 
     el.addEvents({ 
     'mouseenter': function() { fx.start({ 'padding-left': 25 }); }, 
     'mouseleave': function() { fx.start({ 'padding-left': 15 }); } 
     }); 
    });

    if ($$(".google-sense468")[0] && $$(".google-sense468")[0].clientHeight == 0 && $('block-warning')) $('block-warning').setStyle('display','block');

});
/*MOOTOOLS END*/
kennyisaheadbanger
+14  A: 

This is something that simply can't be done server side - there's zilch reason for person to knock on your door and say "Look at me, I have AdblockPlus!". When on the client side, adblock is actively trying to influence the page content, which is something you can see happen and see that they are using an adblocker.

Anyway, I happened to know that newgrounds.com is doing this too. (their new layout was screwed up for adblock plus users - as a response they made a contest for the best "if you're not going to help us through our ads, go and buy something in the store"-banner.

A quick look in the source of newgrounds told me they are doing this with some simple javascript. First in the document:

var user_is_leecher = true;

Next there is a external script tag: src=checkabp?thisistotrickabp=***adress of ad affilliate***

Now the joke: they simply trust adblock plus to filter that script out, as all that's in there is: user_is_leecher = false;

From there, they can do just about anything.

Jasper
That's rather cunning.
Rich Bradshaw
Funny thing is, I did not make any of these names up. They actually have user_is_a_leech (I just didn't pay anough attention when copying) and I accidentally forgot the .js in checkabp.js, but both checkabp and thisistotrickabp are literally in the code like that.
Jasper
A: 

I don't think there is an easy way to do this. What you can do is to create "trap". Make a php script listen to a very obvious url like yourdomain.com/ad.png. You can probably achieve this by url rewriting. If this page is loaded you can note this in a session variable and send back a 1x1 blank png.

On the next request you can see whether ad.png has been loaded. If it hasn't you can guess that the client is using some form of AdBlock software. Make sure you set the appropriate http headers to prevent clients from caching "ad.png".

This is the only server side approach I can think of at the moment and it has some flaws.

  • The png file can be cached regardless of the http headers
  • This will not work for the first http request
  • Some extra server load as browsers will keep hitting ad.png for each request
  • That the image gets loaded from the server is no guarantee for it actually being displayed
  • Probably more side effects that I haven't thought of

Please make a comment on this post if you decide to try it out.

Regarding a client side solution. This shouldn't be to difficult. You can create a tiny Javascript to run on page load complete. This script can check that the page contains the dom-nodes holding the ads. If you this when the page is loaded completely (not only the dom) you can check the width and height of your ad images. The most obvious drawback with this solution is that clients can disable javascripts.

Kimble
A: 

A few good answers here, so I'll just add this:

use some ad management system (You can write Your own). With that, track every ad that's being displayed (and make it obvious, like ads.php or showad.php or whatever). If that script is never called, the user is using SOME form of ad blocking software.

Be sure to handle each and every ad through that handler, though. Mod_Rewrite isn't required, it can be done using simple PHP.

Egon_Freeman
A: 

If you can detect it...

In the areas that say adsense would have been just put an image. Would it know to strip that out?

Surely it would not block a simple image tag. That would make most sites useless.

JM