AdSense Invalid Click Protector Script for Blogger: The Complete Guide

If you're a blogger with an AdSense approved website, then you may have faced issues with Ad-limits due to invalid clicks. This can result in AdSense restricting the display of ads on your website for a limited time. Fortunately, there is a solution to control the number of clicks on AdSense ads by your visitors. In this article, we will introduce an AdSense invalid click protector script that you can use on your Blogger site to prevent invalid clicks and protect your AdSense account.




How does the code work?

The code shared in this article is designed to control clicks on Google AdSense ads by setting cookies in the visitor's browser with a value based on the number of times they have clicked on the ads. By doing so, the code helps to prevent invalid clicks and click bombing, which can lead to AdSense account suspension or termination.

The code works by adding JavaScript to your Blogger template. When a visitor clicks on an AdSense ad on your site, the code checks if the visitor has clicked on the ad more than the maximum allowed times (specified in the code). If the visitor has reached the maximum clicks, the code will execute a callback function that prevents the ads from showing up and displays a message to the visitor.

To set the maximum number of clicks and the timeout before the ads reappear, you can modify the values in the code. The code also allows you to customize the cookie key, ads selectors, and iframe selectors according to your site's needs.


The Complete Guide to Install the AdSense Invalid Click Protector Script

The AdSense invalid click protector script works by setting cookies in visitors' browsers. These cookies are set with values based on how many times a visitor clicks on ads. Here's the complete guide to installation of the code in detail:

Step 1: Login to Your Blogger Dashboard

First, you need to log in to your Blogger dashboard.

Step 2: Go to Theme

On your Blogger dashboard, click "Theme."

Step 3: Click the Next to Customize Button

Next, click the down arrow icon next to the "customize" button.

Step 4: Edit HTML

Click "Edit HTML," and you will be redirected to the HTML editing page.

Step 5: Paste the JavaScript Code

Find the code </head> and paste the following JavaScript code just above it:

<script>

  /*<![CDATA[*/

  /* Cookie functions */

  const Cookie = {

    get: (e) => { e = document.cookie.match(new RegExp("(?:^|; )" + e.replace(/([.$?*|{}()[\]\\/+^])/g, "$1") + "=([^;]*)")); return e ? decodeURIComponent(e[1]) : void 0 },

    set: (e, n, o = {}) => { o = { path: "/", ...o }, o.expires instanceof Date && (o.expires = o.expires.toUTCString()); let c = unescape(encodeURIComponent(e)) + "=" + unescape(encodeURIComponent(n)); for (var t in o) { c += "; " + t; var a = o[t]; !0 !== a && (c += "=" + a) } document.cookie = c },

    rem: (e) => { Cookie.set(e, "", { "max-age": -1 }) }

  }


  /* Anti bomb config */

  const antiBombSet = {

    timeOut: 3600, /* Timeout in seconds, when to ads appear after maximum clicks */

    maxClick: 3, /* No of maximum clicks */

    cookieKey: "MAX_CLICKED", /* Cookie key to set */

    adsSelectors: "ins.adsbygoogle", /* Ads selectors */

    iframeSelectors: "ins.adsbygoogle iframe", /* Ads iframe selectors */

    callback: () => {

      /* Runs only one time if/when clicked maximum times on ads */

      if (antiBombSet.executed === undefined) {

        antiBombSet.executed = !0;


        /* Prevent clicks on ads placement with pointer-events:none | You can also try display:none */

        if (document.getElementById("mxAds_stl") == null) {

          var stl = document.createElement("style");

          stl.id = "mxAds_stl";

          stl.innerHTML = (antiBombSet.adsSelectors || ".adsbygoogle") + "{pointer-events:none}";

          document.head.appendChild(stl);

        }


        /* Add your js below to execute if/when clicked maximum times on ads */

        /* console.warn("You have clicked the maximum times on ads. Don't click on ads if you don't want to support us."); */


      }

    }

  };


  if (Cookie.get(antiBombSet.cookieKey || "ADS_CLICK") != undefined && parseInt(Cookie.get(antiBombSet.cookieKey || "ADS_CLICK")) >= (antiBombSet.maxClick || 3)) {

    antiBombSet.callback()

  };

  /*]]>*/

</script>{codeBox}

Step 6: Paste the JavaScript Code

Now, search for the code </body> and paste the following JavaScript codes just above it.

<script>

  /*<![CDATA[*/

  ! function () {

    function n(e, o) {

      return null != (e = Cookie.get(e)) && parseInt(e) >= o

    }

    var l = antiBombSet.cookieKey || "ADS_CLICK",

      e = antiBombSet.adsSelectors || ".adsbygoogle",

      i = antiBombSet.timeOut || 7200,

      c = antiBombSet.maxClick || 3;

    0 < document.querySelectorAll(e).length && document.querySelectorAll(e).forEach(e => {

      e.addEventListener("click", function () {

        var e, o;

        n(l, c) ? antiBombSet.callback() : (e = l, null != (o = Cookie.get(e)) ? (o = parseInt(o) + 1, Cookie.set(e, o.toString(), {

          secure: !0,

          "max-age": i

        })) : Cookie.set(e, "1", {

          secure: !0,

          "max-age": i

        }))

      })

    }), window.addEventListener("blur", function () {

      n(l, c) && antiBombSet.callback();

      for (var e, o, t = document.querySelectorAll(antiBombSet.iframeSelectors || ".adsbygoogle iframe"), a = 0; a < t.length; a++) document.activeElement == t[a] && (n(l, c) ? antiBombSet.callback() : (e = l, null != (o = Cookie.get(e)) ? (o = parseInt(o) + 1, Cookie.set(e, o.toString(), {

        secure: !0,

        "max-age": i

      })) : Cookie.set(e, "1", {

        secure: !0,

        "max-age": i

      })))

    })

  }();

  /*]]>*/

</script>{codeBox}


Step 7: Save the template

Click on save icon to save "HTML" template.

Once the script is installed, it will start monitoring your AdSense ads for invalid clicks. If it detects any, it will automatically block them and prevent them from being registered on your AdSense account. This can help ensure that your account remains in good standing and that you continue to earn revenue from your ads.


Features

  • Prevents Invalid Clicks
  • Customizable Click Limits
  • Easy to Implement

Conclusion

 AdSense Invalid Click Protector is a useful script for bloggers who use Google AdSense on their websites. It helps prevent invalid clicks on ads, which can lead to account suspension or termination. The script works by detecting and blocking suspicious clicks, such as those originating from the same IP address or multiple clicks in a short period of time. By using this script, bloggers can protect their AdSense account and ensure that their ad revenue is not affected by fraudulent clicks. Installing the script on Blogger is easy and can be done with just a few simple steps. Overall, AdSense Invalid Click Protector is a valuable tool for any blogger who wants to maximize their AdSense earnings while maintaining the integrity of their account.

Post a Comment

0 Comments