This script is designed to allow you to get an idea of how many people are blocking ads on your website using programs like adblock. The script will also replace any blocked ads with custom text, that way you can request that visitors whitelist your website. The script is released under the GNU general public license. You are free to redistribute it or use any of its code so long as you give credit where credit is due.
If you have any problems, suggestions, or comments please do not hesitate to email me. I am more than happy to help.
To view the recorded results you must navigate to the "adblocks.txt" file which will be in the same directory as the "adblocks.php" file. The first number is the amount of impressions, the second number is the amount of impressions that had adblock on. To get the percentage of impressions using adblock, divide the second number by the first.
1. The first thing you need to do is modify the webpage you plan to embed this script on. Wrap all the ads you wish to get statistics of in a div tag and give them all the same unique class name. View the "example.html" file for an example of this. Make sure that the ad script is the only thing inside the DIV tags and that all the DIV tags have the same class name. I recommend not using a name like "ads" because some adblockers tend to completely disable those divs, thus preventing the blocked message system from working.
3. Open the "adblocks.js" file in a regular text editor like notepad. On the first line set the "ads" variable to the same class name that you gave the DIV's in the first part of the instructions.
4. On the next line change the "msg" variable to the message that will display in the place of any ads that are being blocked. You may choose to make this blank if you don't want to use thsi feature.
If you choose to provide a direct URL path for the PHP file use 'http://"+document.location.hostname+' for the main part of your website's name. For example if the direct URL path to my php file was located at "http://www.saurdo.com/files/adblocks/adblocks.php". I would put "var php_url = 'http://'+document.location.hostname+'/files/adblocks/'"
6. Save everything, upload it, and test! If it just won't work then please contact me, not only will I probably get it to work for you, but you will be providing me with information that will help me make it easier for everyone else.
Thanks for downloading!
- Jayd Saucedo