Powered by Blogger.

Add Links To Detect Adblock On Blogger Blog Using JavaScript



How to Add Links to Detect Adblock with JavaScript - If you want to know whether visitors on your blog blocking Google AdSense ads or not, you can do so by adding a JavaScript code. 

This JavaScript automatically detects if any of your site visitor using an Adblock extension enabled browser, Then it brings a special message to your blog visitor. This JavaScript code supports the new format of the data Asynchronous Responsive Google Adsense ads. 

The code is also quite light, so you do not have to worry if the code is going to weigh on the loading speed of your blog. For those who want to try please follow these steps:

Login to Blogger> Open Template Editor> Then add the following code before </ body>
<script type='text/javascript'>
//<![CDATA[
// Adblock Detected
window.onload=function(){setTimeout(function(){var e=document.querySelector("ins.adsbygoogle");e&&0==e.innerHTML.replace(/\s/g,"").length&&(e.style.cssText="color:rgba(0,0,0,0.5);font-weight:700;font-size:110%;padding:20px;margin:auto;text-align:center;text-decoration:none;display:block!important;background:rgba(0,0,0,0.02);border:1px solid rgba(0,0,0,0.08)",e.innerHTML="It seems that you block Google AdSense ads on your browser")},2e3)};
//]]>
</script>
There are two highlighted codes, one is the CSS of the Displaying message and the second one is the displaying message. You can modify these two codes according to your taste.

Save your template, then check your blog after enabling an Adblock extension to your browser and ensure that the code is going well.

That's it! I hope you like this Tip! Stay tuned for more blogger Widgets and Tips!

0 comments:

Post a Comment