Saurdo Adblock Counter
Version: 1
Created by: Jayd Saucedo (Saurdo - www.saurdo.com)
Date created: 08/24/10
License: GNU GENERAL PUBLIC LICENSE
Demo: http://www.saurdo.com/test/examples/adblock_counter/
Contact: me@saurdo.com or www.saurdo.com/contact

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.

Instructions:

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.

2. Add the script tag to the head section of your website's page. Make sure you have the proper path to the javascript file. You may choose to use a direct path if necessary (eg src="http://www.saurdo.com/files/adblocks/adblocks.js")

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.

5. The next line provides the path to the PHP file that will record your statistics for you. You do not need to set this if you plan to keep everything in the same directory as the page the script is embedded on. Even if the "adblocks.js" file and "adblocks.php" file are in the same directory, the javascript file won't be able to find the PHP file if the page the javascript file is on is in a different directory.

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