AdBlock, one of the most hateful tool to all the bloggers and webmasters around the world as it is keep getting bigger and acquiring more users every single day. As per a statistical report published by PageFair Limited on September 9 2014, there are about 144 million active adblocking software users around the world. The usage of AdBlockers on internet has been grew nearly 70% between June 2013 – June 2014. It has been seen that the AdBlock usage growth is highest for Google Chrome (world’s most popular internet browser) and adblock growth driven by Google Chrome is nearly doubled in last one year. It has also been seen that AdBlock usage is mostly driven by young internet users. Almost 41% of 18 – 29 years old people are using adblock right now on their browser and this usage is on a high rise.

So, I hope you can clearly see that in near future when almost 80% – 90% of your website or blog readers will be visiting your site by installing AdBlock on their browser. Now this brings us to the most important question –

How should we monetize our websites and blogs then? Without monetization the Open Source concept is dead.

This is very much true. Some internet users think that website owners put advertisements on their site to be rich, but in reality they do it to fund their website instead. Some, who does support AdBlock concept, argue that it’s better to put a “Donation” button than monetize sites with ads. But again in real life, very few people actually donate for the works bloggers do every day. People like free stuffs but not supporting the authors.

What’s the future then?

Well, as we see the exceptional growth of AdBlocker usage, it clearly shows that in near future most blogger won’t be able to afford the domain, hosting and other website maintenance cost and in the end they starts losing interest in it and stop blogging. As a result, the whole internet community is going to run out of fresh open source free content. Just like newspapers, people have to pay monthly fees to subscribe to blogs and to read their posts. Here is an awesome presentation by PageFair about the massive increase of AdBlock usage in past year.

What about AdBlock alternative?

As I said earlier on my other post about how adsense account gets blocked by misuse of adblock alternative content that if you ask your readers to disable AdBlock for your site that is actually a violation of AdSense policies. And as we all know that they are very strict about it, so they will disable your AdSense account anytime they want, without paying you any money at all. I’ve also mentioned on the article that the smartest way to show AdBlock alternative content is by saying nothing related to ad and by showing Affiliate Ads for AdBlock enabled users.

So how to show affiliate ads as AdBlock alternative?

Well, if you surf on the web, you will see that many bloggers has shared some code snippet to do that trick. But the trick which is mostly available on the web is not the right way to do it mostly because it manipulate the provided Adsense code, which is again aginst Google Adsense policy. Also the mostly available code snippet on the web will only work for Asynchronous version of Adsense code, not for the synchronous version of it. This was really annoying so I wrote my own code from the scratch with a very different implementation approach which I’m going to share below in this post. This code snippet is written by using jQuery and if you are a WordPress user, you don’t have to add jQuery separately as WordPress already comes with jQuery library preloaded.

What you have to do is to understand the exact positions where you need to make the changes in the given code and then copy the code and paste it in your site with your own affiliate ad codes. With this code snippet you can create your own affiliate ad stack and then show affiliate banner ads randomly for AdBlock enabled users. So, let’s get started.


  1. Go to your affiliate sites and copy the banner ad code you want to use.
  2. Paste the code into a notepad and copy the image url (src attribute of img tag) and open it in your browser. (e.g.
  3. Save the image in your computer with a random name (e.g. QtgYulk.jpg)
  4. Now upload the random named image file into your server (or media library of WP dashboard).
  5. Copy the newly uploaded file url and replace the existing url of your banner ad code (you’ve copied earlier) with the new uploaded url.
  6. Add <div class="ad-affiliate"> before placing your ad code copied from Adsense and at last close the div.
<div class="ad-affiliate"> <!-- Start the div affiliate -->

<!-- Your Adsense code starts here-->
<!-- Your Adsense code ends here-->


The above steps are must needed otherwise AdBlock is going to block your affiliate ads too, as AdBlock is a very sophisticated extension which block files if it has names with “ad” or any kind of ad size (300×250) embedded into it. So, now it’s time for the actual alternative code. Also without the div, the alternative content won’t gonna work. So, now its time to check the code.

The Magic Code (name given by me 😀 )

Do not share or showcase the above codes in any other blog post or website without prior permission from the author.

Why can’t people just disable AdBlock?

Well, web is not as beautiful as we think off it in our dreams. Most of websites on the web runs from copying content from other sites or sharing pirated contents and many other nasty stuffs. So these guys never gets approval from Adsense to show ads on their site and they end up showing garbage annoying animated, music or popup ads on their site just for few penny.

So, people get frustrated with these sites and install AdBlock globally. Most AdBlock users don’t even know how to whitelist a specific website or blog or domain on their adblocker. So, for the annoyingness of few ad agencies and webmasters, the whole web pays its price.

Is showing alternate content is a good idea?

Well, if you ask me as a professional experienced webmaster, I will say NO. It degrades user experience of your website. If a user already installed AdBlocker on his/her browser, then he/she definitely don’t wanna see any ads for sure. But with showing alternative affiliate ads you are technically blocking their freewill of using the web. Also even if you force these users to see affiliate banner ads on your content, they will rarely click on it and make a purchase. But still it is worth doing, even if the conversion probability is 1%, because you need to fund your website for various maintenance cost, server cost etc.

Doesn’t big corporate face losses due to this?

Companies like Google, Amazon, Microsoft uses their advertisement medium as their primary source of money for their business. Google AdWords is the system which bags most of the revenue Google earns every year. But hey, these are big corporates with billion dollars funding and recently Google, Microsoft, Amazon and Taboola are paying a hefty amount of money to Adblock Plus developer team to whitelist their websites by default in the Adblock plugin. So in future updates these website will still showing ads even if adblocker is installed and will keep earning billions of dollars, but for you and me, still the general rule applies.

Does this work for Adsense only?

Not at all. I’ve written this code with a very generalist approach so that it works with every kind of ad code. Whether it is adsense or any other ad agency, this ad code will work flawlessly without any issues. So, enjoy every bit of it regardless of what ad medium you use to monetize your website. 🙂 But make sure, the above code is made for banner ads only, not for any kind of annoying popup ads.

What about support?

As you see that this is a completely free blog post and I’m not selling anything to you, so please understand that there is no warranty or support involved in this. Tough I’ll try my best to reply as much comments as possible related to minor problem or issues. But any comment or request related to modifying or upgrading that code will not be entertained for free. Sorry guys. 🙁 But again, I’ll try my best to help as much people as I can 🙂


Tough showing AdBlock alternative content will technically degrade user experience in your site, but if you still want to show it for many possible reason, make sure you do it smartly and don’t make any mistakes. I will definitely suggest you to read how AdBlock alternative content can block your adsense account to know more about Google policies regarding AdBlock alternative content. Even if you get 1% conversion from these affiliate ad banners, it is still better than nothing. Isn’t it?


So what do you think about AdBlock usage increasing exponentially every year? Does AdBlock also affecting your business or blogs? Do you use any other type of AdBlock alternative? Did this article helped you? Let me know in the comment section below. I’ll love to read back from my readers.

Also from now on I’m going to release at least one article each week especially for bloggers and webmasters with news how tos, tips, reviews and more. So, if you have any special request for any topic, feel free to let me know in the comment section below.

You can also follow me on twitter @iSaumya or subscribe to my newsletter to always stay updated with my new posts. Also if you like my work, please give me a kudos for it.

Published by Saumya Majumder

Passionate, Hard Worker. Love to develop new things, Singing Songs, playing computer Action Games, tweaking with computer languages, Riding Bikes, Love long driving, love books, web & Photography. You can follow me on twitter @iSaumya


  1. Great post, thanks for sharing. 🙂

  2. Dude… U shared something very valuable, hope something a Good comes to u 🙂

  3. Thanks for sharing this solution. It really works like magic 😉

  4. sir,where to paste the Magic code please reply .thanks for the post.nice to have a video demonstration …if possible sir.thank you.

  5. I am not happy with the article because you are telling others about it and you are not implementing to your own site.

    • Sorry! I didn’t get you which one I’m not implementing on on own site? Everything I post here is been thoroughly tested and mostly implemented on my own site. I also show alternative affiliate ads for those users who have adblock enabled and I’ve shared the exact code that I use personally and written personally for my site. Anyways I still did not get why you are not happy and what I’m not using. 🙂 It would be great if you can share it in a bit detail manner 🙂

      • Yeah, he’s right I have an adblocker and you are not implementing it.

        Hey can you write an article on if I got banned from adsense due to invalid activity (totally not my fault) then how to write a good letter to get the removal of ban, please mail me if you do.

        thanks nice post I’ve saved it to my Pocket!!

        • That’s kind a wired. Because I’ve tested the script with AdBlock, AdBlock Plus, uBlock and for all of them, it seems working fine. I’ve no idea why you guys are not seeing this. You might consider refreshing your page.

  6. Overall good article, but this is something which isn’t feet into my mind – “But hey, these are big corporates with billion dollars funding and recently Google, Microsoft, Amazon and Taboola are paying a hefty amount of money to Adblock Plus developer team to whitelist their websites by default in the Adblock plugin. So in future updates these website will still showing ads even if adblocker is installed and will keep earning billions of dollars, but for you and me, still the general rule applies.” – If so, than all companies start making adBlocker plugins and start asking for money from Google, microsoft, amazon etc. etc. etc. isn’t it ?

    • Hi Sameer, you got this whole thing in a very wrong way. You see, the companies like Google microsoft are not paying Adblock to show Adsense ads to the adsense enabled sites, They are paying the money so that adblocker doesn’t block ads for their own sites. Like the ads on Google search pages, on youtube videos, within gmail – these ads, not the adsense publisher ads. 😉

  7. Hi,

    Very interesting post to pass through adblocker. I have a question, how can we manage with your code responsiveness, is there a way to show different Affiliate ads sizes depending of the size of the window like I already do with adsense?

    • yes, that is a really good question indeed, specially as we all uses adsense responsive ad code now. Adsense uses css media queries to show up responsive ad but that trick will not work with this code because you have to do everything on jQuery. So, instead what you have to do is you have to create array of different ad sizes and then check the screen size within jQuery and then based on that data you have to show up respective affiliate ads from respective ad array size. Sorry! As this is a free script can’t help you more with customizing, but I have already gave you everything you need to make it happen. 🙂

  8. I am wordpress user don’t know much about coding.
    To which file we have to add “The Magic Code “

    • Install a plugin named Insert Headers and Footers and then you can add that magic code to the section where it says script for footer. Just make sure you add <script> at the beginning of the code and </script> at the end.

      • Hi,
        i did exactly as you said and i have one problem. It’s working with an ad in the sidebar but it’s not working when i put the ad in the header (wordpress). I see only empty space in header with adblock enabled. Do you know how to fix it or where i might made a mistake?

        Thanks in advance for any help, great job!

        • That’s not possible mate, unless you did something wrong. Actually when I wrote this code I used to use this not only for my sidebar ad but for all ads within my post and every place else. It will work for all ad places unless you did some mistake. In that case it’s not possible for me to debug your code or to provide free support. Sorry man.

      • Might be a good idea to mention adding and in the body of this post. A lot of us dummies don’t know to do that.

        • Hi there, I don’t understand what are you asking for. Can you please explain a bit?

          • Sorry, my comments was edited by your system because it contained the word s-c-r-i-p-t. I was just saying that some of us noobs don’t know to add those tags to the beginning and end of code. I was wondering why it wasn’t working for me until I say you mention that in the comments section.

            Also, thank you for this awesome share :).

          • are you taking about adding the div or the jquery part?

          • If you look at your comment above to Anuj, all I was saying was that the advice you gave him is something I needed to make it work in my application. Adding those tags. I too was using something that does script for footer, just not WordPress. But it didn’t work until I added those tags.

  9. Hi,

    I’ve implemented your code on my websites and it works well with chrome & firefox. But with safari on Mac OS X or iOS or when on iOS it does not work well, in fact the affiliate ads are displayed even if no adblock is present. Have you tested it with safari or on iOS? Do you know what could be wrong or what can be done to make it work well on those browser/device?
    Thanks for your help,

  10. Really helpful, thanks for the post.

  11. Its really helpful please keep sharing…

  12. As ad-blockers are becoming more prominent, the solution suggested by Saumya sounds awesome!

    I see in the blog post that it is mentioned that donations is not a possible solution.

    But Adzcoin has recently come up with a solution along this lines. The difference is, the visitors keep earning free coins (adzcoin), which they can donate to the deserving publishers? Will this make a difference? I think so…

  13. Thanks for writing the script. I’m surprised that you have not implemented into your blog. Are you concerned with being banned from Google Adsense?

  14. Interesting solution.
    Do we need to put this so called magic code before closing tag? or it will work in footer as well?

    • As I’ve mentioned above, you can either put the code in the footer or add it in a JS file and then call that file. I think I’ve already explained how to add the code in-depth above.

      • I put the code in footer as it is starting from “var adArray = [];” before the closing body tag. Then wrapped the adsense ad code in the div you provided. But this didn’t work. The ad was appearning at the footer where I placed the code and not at the place where adsense ad needs to be replaced.

        Is the code starting with “var adArray = [];” needs to be wrapped in script?

        Definitely I am missing something. Can you help?

  15. Superb bro
    I m your regular visitor and I think I have found best adsense tips ever.
    Thankyou so much for providing such good stuff.

  16. Hi Saumya,

    Great piece of code. It surely helps.

    However, just wondering in terms of responsive design, how do I implement this to cater to different ad sizes for different browser sizes. Do you mind pointing out the most basic implementation on how I can include some kind of css media queries to solve this issue?

    Cheers and many thanks!


    • Hi Jhon, if you want to show different images for different screen size, for example if it is a PC, when show affiliate ad banners of 728X90 but if it is a phone then show 300X250. There is no easy css way to do this as everything hever is getting pushed by jQuery. So, what you have to do is, you have to create 2 array inside your jQuery. One for the 728X90 banners and one for 300X250 banner. Then within the jQuery code you can run a if statement for checking the screen width like this: if ($(window).width() > 748 ) then show up big affiliate banner or show up small affiliate banner. That is the only way.

    • Hi John,

      How to implemented these script?

  17. Hi,
    I’m really sorry that this is a bit technical. But if you have basic HTML and JS knowledge you will see how easy it is to implement, as I’ve already provided the entire code. It just needs to be connected with your content. If you show this to anyone with some basic HTMl and JS knowledge, he will definitely understand it. I’m really sorry that you didn’t understood it. But trust me I’ve already explained in an extremely easy manner, not sure how to explain it even further.

  18. How i du that if i use blogspot dude.

  19. Very good, as you do to put, this message in place of the ad, when the adblock is enabled in the navigated?

  20. Can my adsense can get banned because of showing affliate ads as alternative adblocker adsense ad just like you have shown? Is it any way against google policy?
    Is it 100% safe?


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe To My Newsletter

Subscribe To My Newsletter

Join my mailing list to get meaningful content, useful information, how-tos, tricks, tips for webmaster, bloggers and entrepreneurs to rise and profit in your online business.

You are almost there! Just check your Inbox to confirm the Subscription & you are all set.


By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.