skip to Main Content
AICP Plugin: The Best Approach To Protect Your Blog And Adsense From Invalid Clicks Activities

AICP Plugin: The Best Approach to Protect Your Blog and Adsense From Invalid Clicks Activities

Have you been a victim of Adsense account ban? Or you have not been getting an encouraging CPC due to clicks from certain countries? Am glad to let you know there is a solution to stop displaying ads to certain countries, this measure will not only stop ads from showing in those countries, it will also control the clicks on your ads thereby saving your account from invalid click activities and click bombing. In my post on how to prevent Adsense invalid click activity, I mentioned that there are some countries that engage in cyber click fraud and those countries are listed in the high-risk countries by online fraud guide

This is an advantage for those using WordPress, maybe in future, I will make a post on how to protect invalid click on Google Blogspot. If you are using WordPress, congratulations, as am going to show you how to protect your blog and Adsense account from click bombing and stop ads from showing in high-risk countries. One of the advantage WordPress has over every other CMS is the ability to make use of plugins for extra features to improve the standard of our blog, so we are going to make use of a plugin.

AdSense Invalid Click Protection (AICP) Plugin was developed by Saumya Majumder and currently, the plugin has over 2,000+ installs and it is compatible with the latest WordPress version 4.8.1 and you also need PHP version 5.3 and above to be able to use this plugin effectively. Follow the step by step instructions below to install, activate and setup the plugin.

This tutorial is going to be in two parts, part 1 is the installation, activation and setting up the plugin while the second part is the ad code implementation to protect adsense from invalid clicks. Are you ready? Let’s go.

Installation, Activation and Setting Up AICP

The first thing is to install and activate the plugin, it is available in the WordPress repository

1. On your WordPress Dashboard, Place you mouse on “PLUGINS” and click on “ADD NEW” from the flyout menu as seen on the image below

aicp plugin protect adsense from invalid clicks

2. On the next screen, type “AICP” on the keyword search bar at the top right of the page, the plugin “AdSense Invalid Click Protector (AICP)” will display. Click on “INSTALL” wait for few minutes for the installation to be done, once installed, the INSTALL NOW button will change to ACTIVATE, just click on “ACTIVATE”. Now the plugin has been installed and activated successfully and it is ready to use.

adsense invalid click protector

The plugin is ready, before I proceed to the setup, below are some of the benefit of the plugin

  • Set the number of clicks on your ads per IP
  • Automatically block any visitor that exceeds the click limit
  • Stop showing ads to some specific countries
  • Ability to see the stats of banned users and their IP
  • You can delete any banned user one after the other or in bulk
  • The plugin will display the stats of banned user from the Admin Dashboard

If you ask me, the developer of this plugin really did a good job to have came up with this. So, let us proceed to the setup

3. At the left side menu, locate “Adsense Invalid Click Protector”, place your mouse on it and click on “General Settings” to begin the setup for the plugin.

Adsense invalid click protector

4. On the plugin setup page, you will be able to set the click limit, block countries and others.

how to protect adsense from invalid clicks

Set the Ad Limit: You can set this to minimum of 1 or maximum of 3 clicks on your your ad unit

Click Counter Cookie Expiration Time: Set this to 3 hours, this control the cookie expiration time of the click counter

Set the Visitor Ban Duration: You can set this to 5-7 days, this is the number of days a banned user won’t see your ads, after the set days, ads will start showing to the user

Do you want use the IP-API PRO KEY: Check “No” if your site is having less than 10k Page views per day, for a high traffic site of 10K page views and above, you may consider purchasing the Paid Version of the IP-API to avoid 503 error because the free version only allows 150 requests per minutes while the paid version allows unlimited request.

Provide your IP-API PRO KEY: If you are using the paid version of IP-API, and you checked “yes” on the option above, then you have to provide your API key here

Do you want to block showing ads for some specific countries?: Now, if the aim of using this plugin is to stop displaying ads to some countries, then check “Yes” but if you don’t want to restrict any country, leave it checked at “No”

Banned Country List: To enter the list of the countries you want to restrict, you are going to enter each country ISO ALPHA-2 Country codes here separated by a comma (,). Click on this link to get the list of all countries ISO ALPHA-2 Country codes

For example, I want to block India and Russia only, am going to enter IN, RU which are the codes for India and Russia respectively.

After filling those fields, click on “Save Changes” and the plugin is ready to use. But this is not the final steps as we are going to display ads with PHP function and not the normal way of adding ad codes on our blog. Don’t be scared, I will try as much as possible to explain clearly so you won’t make any mistake. so let us proceed to the final part of the setup which is ad code implementation

AD Code Implementation and Integration

There are so many WordPress plugins that allow you to just insert your ad codes on your blog but in this case, it is not like that. We are going to show ads with either a PHP function or using the shortcode. But personally, am making use of the shortcode approach.

Using the PHP Function Approach

You need to do 2 simple things

Put this your adsense code in between this function if( aicp_can_see_ads() ) { /* return your ad code here */ } and secondly wrap the ad code within the div tag <div class=”aicp”>…your ad code goes here…</div> .. See full example below

if( aicp_can_see_ads() )


<div class="aicp">

Enter your adsense code here



With that, you will enjoy the benefits of the AICP plugin

Using the Shortcode Approach

It is very easy to create a shortcode in WordPress, all you need to do is to go to the functions.php file of your theme or your child theme. You can see the function.php file of your theme by going to Appearance >>> Editor as shown on the image below

how to protect adsense from invalid clicks

On the editor page, you will see your theme css file by default, so check the right side, locate the functions.php file and click to perform the next step. As you can see from the image below, am using the newspaper child theme so I only have the functions.php and the style.css. Once you locate the file, click on it and wait for the file to load on the editor page

how to protect adsense from invalid clicks

Once functions.php file successfully loads, you are now ready to add the code for the shortcodes, please be very careful at this stage because any mistake can break your site totally, so I will urge you to copy the functions.php code somewhere like a backup before you make any changes to it in case anything went wrong so you can revert to restore your website.

On the functions.php page, scroll down to the last code on the file and add the code shown below

/* ----------------------------------------------------------------------------

Type the name of the ad unit here


add_shortcode( ' your_shortcode_name ', 'your_shortcode_function_name' );

function your_shortcode_function_name () {

if( aicp_can_see_ads() ) { // This part will show ads to your non-banned visitors

$adCode = '<div class="aicp">

Enter your ad code here

</div><!-- end of the aicp div -->';

return $adCode;

} else { // Anything within this part will be shown to your banned visitors or to the blocked country visitors

return '<div class="error">You have been blocked from seeing ads.</div>';



/* ----------------------------------------------------------------------------

End of code


NOTE: from the code above, you are to change your_shortcode_name to whatever you want also your_shortcode_function_name to whatever you want as well. But please note that your_shortcode_function_name has been mentioned twice so make sure you change it in both places. Also, remove the replace the word “Enter your ad code here” with your Adsense code.

So whatever you used to replace your_shortcode_name will now be your shortcode to use to display ads on your website. Continue reading after the image below

how to protect adsense from invalid clicks editing functions

Once you did that, save the changes and insert your shortcode anywhere you want to show the ad unit on your website. To display shortcode in WordPress, wrap the shortcode name like this [shortcode_name_goes_here]. For example, if you change the your_shortcode_name to “linkads”, you are going to display ads using this [linkads]. Note that, space is not allowed when replacing your_shortcode_name and your_shortcode_function_name, use “_” underscore symbol instead.

If done properly, it should llook like the code in the red square on the image below:

how to protect adsense from invalid clicks

That is how you are going to repeat that process for all the ad units you want to show on your website. Please note that you can only make use of one shortcode name and shortcode name function per each ad unit which means you can’t use the shortcode name and shortcode name function you used on the first ad unit for the second ad unit and others. For example, if I change the your_shortcode_name to links and your_shortcode_function_name to showad like I have on the image above, I won’t use the name “links” and “showad” on the code for another ad unit I want to add, else the new code won’t work.


The AdSense Invalid Click Protector Plugin will definitely help you to save your Google AdSense account from unusual invalid click activities and click bombings that might get you banned. I believe account disable will come to an end for you as this measure will secure your Adsense account by making sure invalid click activities does not occur on your website and also assist you to stop serving ads to high-risk countries thereby increasing your CPC as you will be displaying ads to relevant users.

If you have any questions or need assistance, feel free to drop your comment below and trust me, am going to respond to every comment. If you love this post, kindly share to your friends on Facebook and other social networks so they can also benefit from this.

This Post Has 13 Comments
    1. It doesn’t mean if you are a coder or not as the explanation is explanatory enough but if you need extra assistance, you can drop your mail for further assistance.. I will also update the page later with video content

  1. It seems Adsense Invalid Click Protect plugin has been updated and does not need inputing code into functions.php and wrapping the code around div tags.

    I used it last year on one of my blog but when i try using it on another blog, i did not see that option again.

    Is the option still compulsory?

    1. You have to paste that where you want the ad to display, it is best used with ad display plugin that supports php function such as Ad inserter and Ad Injection, they are all available on wordpress repository

  2. I have issue with the implementation of the code. Use of Ad inserter disturb the theme of my website. Either we can use the code without Ad inserter or ad injection….

      1. Hi,
        I have tried several times, Now I got success to implement the code perfectly. I adopted the {short Code method} while putting script in “function.php” . It is working when I implement short code in the body of post, but it is not working when i put “short code” in the widget area at the right side of post (WordPress script). It shows simple [short_code] only. When i use this code in the body of website then its show ads. Please help me in such a way that it may work correctly when i put this code in the widget area. Moreover, i want to describe one thing more that I am using “Quick Adsense Plugin” for implementation of Adsense code.
        Thanks & Regards.

        1. You need to check with the theme developer to be sure they allow use of shortcode inside widget. Hope this helps

Leave a Reply to Captain Cold Cancel comment reply

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

Back To Top