How To Prevent Visitors from using AdBlock?


#1

I think my Blog viewers are using Ad-Bock to stop my Google Adsense Ads displayed on their browsers. My only monetization network is Adsense if they Bock my Ads I have no idea what to do

I want to know how to detect them and also want to know any further ideas to deal that kind of users

Thanks in advance Regards; SN basha


#2

You can’t stop the people , Who are using Ad-Block .
But instead of stopping them , Show a message where ever you placed the Adsense ads . The following code will help you to do that .

<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); 
  }; 
</script>

Replace the “Your custom Html messages goes here” With the message you want to display instep of the empty space where ever you Adsense ads fixed .


#3

@SNbasha The code provided by the @MUHSIN_MOHAMED_PC is used to detect whether the user uses an Ab-Block or not You can also this script it will integrate with Google analytics and it is easier to track the user


#4

you can use the following script to detect Adblock users and stop them from blocking the Ads

<script> 
  
  window.onload = function() { 
  
    // Delay to allow the async Google Ads to load
    setTimeout(function() { 
      
      // Get the first AdSense ad unit on the page
      var ad = document.querySelector("ins.adsbygoogle");
      
      // If the ads are not loaded, track the event
      if (ad && ad.innerHTML.replace(/\s/g, "").length == 0) {
 
        if (typeof ga !== 'undefined') {
 
            // Log an event in Universal Analytics
            // but without affecting overall bounce rate
            ga('send', 'event', 'Adblock', 'Yes', {'nonInteraction': 1}); 
 
        } else if (typeof _gaq !== 'undefined') {
 
            // Log a non-interactive event in old Google Analytics
            _gaq.push(['_trackEvent', 'Adblock', 'Yes', undefined, undefined, true]);
 
        }
      }
    }, 2000); // Run ad block detection 2 seconds after page load
  }; 
  
</script>


<script> 
  
  window.onload = function() { 
  
    // Delay to allow the async Google Ads to load
    setTimeout(function() { 
      
      // Get the first AdSense ad unit on the page
      var ad = document.querySelector("ins.adsbygoogle");
      
      // If the ads are not loaded, track the event
      if (ad && ad.innerHTML.replace(/\s/g, "").length == 0) {
 
        if (typeof ga !== 'undefined') {
 
            // Log an event in Universal Analytics
            // but without affecting overall bounce rate
            ga('send', 'event', 'Adblock', 'Yes', {'nonInteraction': 1}); 
 
        } else if (typeof _gaq !== 'undefined') {
 
            // Log a non-interactive event in old Google Analytics
            _gaq.push(['_trackEvent', 'Adblock', 'Yes', undefined, undefined, true]);
 
        }
      }
    }, 2000); // Run ad block detection 2 seconds after page load
  }; 
  
</script>

#5

@Rajkumar not workinking, i received an error that says Error parsing XML, line 16, column 15: The entity name must immediately follow the ‘&’ in the entity reference.

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


#6

You can solve this error. Try to upload this javascript code on an external host and then use script src to link it.


#8

Hi thanks for the script but its showing an error while placing before tag and when placed as a html widget its doesn’t work. Please help

Error parsing XML, line 4085, column 291: Open quote is expected for attribute “id” associated with an element type “i”.


#9

I think I also need this.

Other way is to tell your users to stop using browsers like uc mini and uc browser. UC mini doesn’t load JavaScript fine so ads won’t display while uc browser has ad blocker by default. The two browsers affects your Adsense earnings badly. I tried it on http://droidpost.com and everything changed.