While checking your website’s stats you may have thought that, although my site has a good traffic but my ad revenue very low, why so?? Then you might have tried all the different positioning, color and format of ads to make them more attractive.

Actually the main problem is ,even you make changes to your ad formats to make it more visible and attractive, majority of the visitors do not want to see them. Most of the regular Internet users uses ad-blockers. Especially in case of FireFox, people use an add-on named – Ad-block plus [Even I am using it :p ].

Ad Blocker gets both positive and negative reactions.Majority of people love it, as it blocks all those unwanted ads .On the other hand the webmasters hate this add-on as it disables the source of income for ad supported websites.

Let’s see what we can do to block/redirect these vis….itors.
While searching for blocking scripts I came across two nice solutions

Both of them work very nicely but they are a bit complicated and only work with Adblock Plus on firefox.

Hence I  worked out a very simple JavaScript which redirect these kinds of visitors to some other webpage. This script uses code form Adblock Detection Script .

This script checks whether adsense ads were displayed on that page or not. If not, then it redirects the visitor to another page.You can create a warning page for such visitors but what I will recommend you to create a special “lite” version of your website for such visitors and ask them to disable their adblocker to browse the whole website.Please keep in mind blocking visitors means you may see a declination in your traffic but you may earn more revenue as you will make them disable their adblocker.

Here is the code of the script

<script type="text/javascript">
setTimeout('check_ads()', 100);
      function check_ads()
      var rnd = Math.random();
      if (rnd < 1)
      { // only execute the following if rnd < .2
      var blocked = false;
      var e = document.getElementsByTagName("iframe");
      for (var i = 0; i < e.length; i++)
      if ((e[i].src.indexOf("googlesyndication.com") > -1) &&
      (e[i].setAttribute && (e[i].style.visibility == "hidden" ||
      e[i].style.display == "none"))) blocked = true;
      if ((e.length == 0) || blocked)
      location = "http://www.YOURWEBSITE.COM/warningpage.html"; 
//enter the url of the page which contain the message for the
//blocked visitors.Alternatively you can create a lite website
//for them and ask them to disable their blocker who browse the
//full website.

If you are unable to see the whole code :
 Download the text file from here

To use this script simple copy paste the code blow, just above your </body> tag OR your Adsense ad code.

A working demo is available here


(Please disable your adblocker before continuing else you will directly land on the warning page).

The issues with this script are:

  • If the visitor use their browsers back button from the warning page then the script fails.
  • Only works with Adsense because it only checks the access of googlesyndication.com from the webpage. Although you can replace it for other advertisers
  • I have no idea whether Adsense allows these kinds of scripts or not.

Please do comment on this script. :)