browser - How can I tell if a web client is blocking advertisements?


Translate

What is the best way to record statistics on the number of visitors visiting my site that have set their browser to block ads?


All Answers
  • Translate

    Since programs like AdBlock actually never request the advert, you would have to look the server logs to see if the same user accessed a webpage but didn't access an advert. This is assuming the advert is on the same server.

    If your adverts are on a separate server, then I would suggest it's impossible to do so.

    The best way to stop users from blocking adverts, is to have inline text adverts which are generated by the server and dished up inside your html.


  • Translate

    Add the user id to the request for the ad:

    <img src="./ads/viagra.jpg?{user.id}"/>
    

    that way you can check what ads are seen by which users.


  • Translate

    You need to think about the different ways that ads are blocked. The first thing to look at is whether they are running noscript, so you could add a script that would check for that.

    The next thing is to see if they are blocking flash, a small movie should do that.

    If you look at the adblock site, there is some indication of how it does blocking:
    How does element hiding work?

    If you look further down that page, you will see that conventional chrome probing will not work, so you need to try and parse the altered DOM.


  • Translate

    AdBlock forum says this is used to detect AdBlock. After some tweaking you could use this to gather some statistics.

    setTimeout("detect_abp()", 10000);
    var isFF = (navigator.userAgent.indexOf("Firefox") > -1) ? true : false,
        hasABP = false;
    
    function detect_abp() {
      if(isFF) {
        if(Components.interfaces.nsIAdblockPlus != undefined) {
          hasABP = true;
        } else {
          var AbpImage = document.createElement("img");
          AbpImage.id = "abp_detector";
          AbpImage.src = "/textlink-ads.jpg";
          AbpImage.style.width = "0";
          AbpImage.style.height = "0";
          AbpImage.style.top = "-1000px";
          AbpImage.style.left = "-1000px";
          document.body.appendChild(AbpImage);
          hasABP = (document.getElementById("abp_detector").style.display == "none");
    
          var e = document.getElementsByTagName("iframe");
          for (var i = 0; i < e.length; i++) {
            if(e[i].clientHeight == 0) {
              hasABP = true;
            }
          }
          if(hasABP == true) {
            history.go(1);
            location = "http://www.tweaktown.com/supportus.html";
            window.location(location);
          }
        }
      }
    }
    

  • Translate

    I suppose you could compare the ad prints with the page views on your website (which you can get from your analytics software).