How to display an image banner if adblockers block adsense ad

Blocking ads using Ad blocking softwares or using browser extensions is growing at high speed. Adblock and Adblock plus etc are examples. Users may enjoy the website content without getting any popup ads or annoying ads, but it is a pain point for publishers who rely on Google adsense or other online website monetizing programs. When adsense ad is blocked by ad blockers, empty space will be displayed in that space.

As a website publisher, you can promote your site by displaying it’s content (an image or text) in place of blocked adsense ad or you can ask the audience to whitelist your site in Ad blocker settings or you can display Facebook like button or twitter widget etc.

Below are the steps

1. Copy the below code

________________________________________________

<script>

window.onload =function(){

setTimeout(function(){

var ad = document.querySelector(“ins.adsbygoogle”);

if(ad && ad.innerHTML.replace(/\s/g,“”).length ==0){

ad.style.cssText =‘display:block !important’;

ad.innerHTML =‘Your custom HTML messages goes here’;

}

},2000);// The ad blocker check is performed 2 seconds (2000 ms) after the page load

};</script>

_________________________________________________________

2. Goto your blogger dashboard -> Layout

3. Click on Add a Gadget

4. Click HTML/JavaScript gadget

5. Paste the code into the above gadget content

6. If you want to replace the blocked adsense ad space with an image banner, replace

ad.innerHTML =‘Your custom HTML messages goes here’;

with

ad.innerHTML = ‘<a href=”Enter site link here” > <img src=”Enter image URL here” alt=”image description”  width = ” Enter width” height = ” Enter hieght of image” /></a>’;

Enter the image info in above line of the code and save the widget. See below example

ad.innerHTML = ‘<a href=”https://gethowstuff.com/display-image-adsense-ad-blocked/” ><img src=”https://lh4.googleusercontent.com/-7jLT7oN9vvc/U_i3uz0TDlI/AAAAAAAAZik/kCTz3srHvfM/w426-h355/white-list-site-adblock.jpg” width=”300″ height=”250″ /></a>’;

7. You can replace the blocked ad space with a link, Facebook like button,twitter widget etc.

Notes:

1. Only the first adsense ad on the site will be replaced with alternate content

2. It works only for Google adsense ads

3. You can also use above code in wordpress or any other platform

4. There is no violation of Adsense policy by doing above trick

Source: Amit agarwal- labnol.org

About the Author

SRINI S

A passionate blogger. Love to share solutions and best practices on wordpress hosting, issues and fixes, excel VBA macros and other apps

Leave a Reply

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