Geo-Targeting Script Installation Instructions For PHP Based Web Sites Automatically determine the country of the visitor to your web site then decide what content to display to that visitor! You can show an ad (or any content really) that is specific to their country! Imagine the possibilities...
If you currently do not have the Geo-Targeting Script, please visit: http://keithjameslock.com/wordpress-geo-targeting-script to obtain a copy, which will also have the manual to set it up on a Wordpress blog.
Important: This script requires that your server has php5 installed (most do) in order to run. There are instructions here to quickly self-upgrade to php5 if you are hosted with GoDaddy. Note: Feel free to use this script on unlimited web sites. You do not have permission to resell this script.
Disclaimer: The Geo-Targeting Script is provided as-is. Although the script has been tested and is working perfectly for us, we cannot be responsible for your voluntary use of this script. You are responsible for the outcome of using it. Please be sure you get your copy from the link above to be sure it has not been tampered with.
Page: 1/8 Geo-Targeting Script from KeithJamesLock.com
Table Of Contents • Script Files and Database Update Explanation (optional) • Step 1 – Uploading/Installing The Script • Step 2 - Displaying Unique Content For A Country
Page: 2/8 Geo-Targeting Script from KeithJamesLock.com
Script Files and Database Update Explanation Note: You may just skip to Step 1 if you wish. This section is optional. First and foremost you should have a copy of the script. If not, get the script here before you continue. Likely you would have already opened the zip file if you are reading these instructions. I'll assume that's the case. Below are the contents of the zip file. For the most part, you need not worry about these files. The database file is of the most importance. Contents Of Zip File geo Folder • PHP-GeoTargetingScriptInstructions.pdf – you are reading it • WP-GeoTargetingScriptInstructions.pdf – instructions for Wordpress • GeoIP.php • init.php GeoIP Folder • DMA.php • Location.php • GeoIP.dat – database which translates an IP Address into a country • DBUpdate.txt – open it to determine the verison of the database (GeoIP.dat) included with this script Database File The database file, GeoIP.dat, is the file that holds all of the IP Addresses and the corresponding country the IP Address belongs to. Although not 100% accurate (all AOL users show as coming from the U.S.), it is very close. Over 99% accurate in fact. The database updates come free from MaxMind.com. They are updated monthly. I only Page: 3/8 Geo-Targeting Script from KeithJamesLock.com
ever update mine every 6 months but it's entirely up to you. Just overwrite the GeoIP.dat file on your server when you choose to update and you will be in business. Important: Be sure to upload it in “Binary” mode (explained later). Downloading And Decompressing The Updated Database File When you decide to update your database (optional), follow the instructions below. The following instructions involve uploading files with an FTP client. If you do not have an FTP client, please download and install one before you continue. You can download FileZilla for free here: http://download.cnet.com/FileZilla/3000-2160_4-10308966.html 1) Get yourself a utility to that handles decompression of .gz compressed files. You may already have one. The utility you use for .zip files may also handle .gz files. If not, here's a link to a free one: http://download.cnet.com/WinRAR/30002250_4-10007677.html 2) Visit http://www.maxmind.com/app/geolitecountry and under the Binary Format section, click the link that says: “Download the latest GeoLite Country Binary Format” and download the file to your desktop. 3) Extract/decompress the file. If using WinRar (download link above) then rightclick the downloaded file (GeoIP.dat.gz) and click “Extract Here”. A file called GeoIP.dat will appear on the desktop. That is the latest database for the GeoTargeting script. 4) Now replace the database file included in the script files in the “GeoIP” folder. You may do this before uploading it to your server or after it is already uploaded. Note: You MUST upload the database file in BINARY mode. You may upload the other script files in Binary mode as well. Most FTP clients have the option to upload in binary mode. If using FileZilla, click on Transfer > Transfer Type > Binary. In general, it is safe to leave it on Binary mode for all future uploads. At least I haven't ran into issues. It's up to you.
Page: 4/8 Geo-Targeting Script from KeithJamesLock.com
Step 1 – Uploading/Installing The Script The following instructions involve uploading files with an FTP client. If you do not have an FTP client, please download and install one before you continue. You can download FileZilla for free here: http://download.cnet.com/FileZilla/3000-2160_4-10308966.html Note: You MUST upload the database file in BINARY mode. You may upload the other script files in Binary mode as well. Most FTP clients have the option to upload in binary mode. If using FileZilla, click on Transfer > Transfer Type > Binary. In general, it is safe to leave it on Binary mode for all future uploads. At least I haven't ran into issues. It's up to you. 1) Upload the entire “geo” folder (unzipped) into the root folder of your web site. Remember: BINARY MODE :) 2) If your sites uses include files (or shared borders) you will probably want to include the statement below into your header include file. It's difficult for me to guess where on your site it goes without knowing the structure. The statement will need to be added at the very top of any file/page that you want to use it. Using include files makes it so that you only have to add it to one file. Download the file(s) where you intend to place the code. Type in the following code exactly as is (this should work in most cases and on most servers): <?php include($_SERVER["DOCUMENT_ROOT"] . '/geo/init.php'); ?> 3) Save the file(s) and re-upload. 4) Check for errors by browsing to the page(s) that you have this line added to. Feel free to leave a comment on this post: http://keithjameslock.com/wordpress-geotargeting-script if you need help with these steps. At this point, when someone visits your site, the script will store the visitors 2-letter country abbreviation into a global variable called $COUNTRY. Some of the possible values for that variable include: EU for Europe, AU for Australia, CA for Canada, CN for China, GB for United Kingdom, HK for Hong Kong, IE for Ireland, IN for India, IT for Italy, JM for Jamaica, NZ for New Zealand, US for United States, etc. Page: 5/8 Geo-Targeting Script from KeithJamesLock.com
The 2-letter abbreviations aren't always obvious so I attempted to include the most popular above. You may look at the GeoIP.php file to find more. The file won't always open properly in all text editors. Don't save the file if you aren't sure what you are doing. There should be no reason to edit the file ever anyways.
Page: 6/8 Geo-Targeting Script from KeithJamesLock.com
Step 2 – Displaying Unique Content For A Country At this point your web site is aware of the country that your visitor is browsing from. The 2-letter country abbreviation can now be used in your code. Below I will describe a simple example of how this script can be used (with sample code)... A common use of the script is to show different ads in your pages based on the person's country. For example, say you are running an “acai berry” web site. You may have an offer/creative for the U.S. only which pays $37.00. You may also have another offer that caters to Canada, the U.S. and the U.K. which pays only $34.00. Before using this script, you may have opted for the second offer so you didn't miss out on the U.K. and Canadian traffic. However, the $3.00 extra you would get for the U.S. offer is very important to your bottom line, plus... what about all of the other countries visitors that may drop by? You can monetize that traffic as well with say... some Google AdSense. So, here's the power of this script in action... Let's say we want to display an “acai berry” ad that is 300x250 in size. Here's the code that we would use: <?php if ($COUNTRY == 'US') { ?> Add the HTML to display your 300x250 ad for your $37.00 U.S. offer here! <?php } elseif ($COUNTRY == 'GB' || $COUNTRY == 'CA') { ?> Add the HTML to display your 300x250 ad for your $34.00 U.K./Canada offer here! <?php } else { ?> Add your 300x250 Google AdSense script here to be seen by all other countries! <?php } ?>
Page: 7/8 Geo-Targeting Script from KeithJamesLock.com
Now, a unique ad should be running for each country. Good job! There are plenty of ways to use this script on your web site. Be creative. The sky is the limit! If you like this script, please tell a friend to pick up a copy for themselves here: http://keithjameslock.com/wordpress-geo-targeting-script
Page: 8/8 Geo-Targeting Script from KeithJamesLock.com