How To

How to Display Alternate Content to AdBlock Users

Written by Aman yadav

ADblock now block your earning from your blog but your visitor trust on your blog may white-list you on adblock plus but for that you need to remember your visitor to unblock your blog from adblock. But there is only one sided job you can’t do anything if they do not white-list you.So what to do for notice your visitor to unblock your site :

I have solution of this you can notice your visitor by different way’s like by text, image,popup instead of this google ad code.You can also use in wordpress website.

Master code for replacing ad space with alternate content

<script> 
  // Run after all the page elements have loaded
  window.onload = function(){ 
    // This will take care of asynchronous Google ads
    setTimeout(function() {     
      // We are targeting the first banner ad of AdSense
      var ad = document.querySelector("ins.adsbygoogle"); 
      // If the ad contains no innerHTML, ad blockers are at work
      if (ad && ad.innerHTML.replace(/\s/g, "").length == 0) {     
        // Since ad blocks hide ads using CSS too
        ad.style.cssText = 'display:block !important';         
        // You can put any text, image or even IFRAME tags here
        ad.innerHTML = '<img src="http://blog.liveurlifehere.com/wp-content/uploads/2015/01/adblock.jpg" width="300" height="250" />';      
      }      
    }, 2000); // The ad blocker check is performed 2 seconds after the page load 
  }; 
  
</script>

 Display text instead of google ad:

Text display may see to your visitor or may not it will depends on your website theme design . Below given code use to show text notice to adblock user.

ad.innerHTML = 'Advertisement help us to pay out internet bill ! Please allow to our website to display ads ';

  Display image instead of google ad:

This will be perfect solution for notice visitor to unblock website in adblock. Image you can use any like gif animated image, flash image ,swf files etc.This image show where google ads code already placed.

ad.innerHTML = '<img src="http://blog.liveurlifehere.com/wp-content/uploads/2015/01/adblock.jpg" width="300" height="250" />';

 

A2hosting
Uptime
Features
Support
Overall

Pros

  • Best Support
  • Low Price
  • 100% Uptime
  • Fast Speed Server

Cons

  • No Cons For this

About the author

Aman yadav

Article writer @ Liveurlifehere Blog : I am writing on Top trending article on web,technology-how to,entertainment,top n category post .I am always try to reach you diffrent & good quality content then ever.

1 Comment

Leave a Comment