Your SlideShare is downloading. ×
Php Geo Targeting Script Instructions
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Php Geo Targeting Script Instructions

2,652
views

Published on

This manual covers the simple steps needed for setting up the php based web site scripts to allow webmasters to show different ads based on the visitors country.

This manual covers the simple steps needed for setting up the php based web site scripts to allow webmasters to show different ads based on the visitors country.

Published in: Self Improvement, Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,652
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
23
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Geo-Targeting Script Installation Instructions For PHP Based Sites Page: 1 Copyright 2009-2010 © - Keith Lock – All Rights Reserved Geo-Targeting Script
  • 2. Geo-Targeting Script Installation Instructions For PHP Based Sites Page: 2 Geo-Targeting Script Installation Instructions For PHP Sites Published by: Keith Lock Windsor, Ontario, Canada http://keithjameslock.com Copyright © 2009-2010 – Keith Lock. All rights are reserved. No part of this report may be reproduced or transmitted in any form without the written permission of the author, except for the inclusion of brief quotations in a review. The geo-targeting script and accompanying manual is the intellectual property of Keith Lock. Purchasers of the geo- targeting script, either from keithjameslock.com or an authorized reseller, have the right to use the script in perpetuity on any site they own. However, the right to sell and distribute these scripts is retained by Keith Lock. Bottom line: you may not sell or distribute the script or the contents of this manual. Note: This e-book is optimized for viewing on a computer screen, but it is organized so you can also print it out and assemble it as a book. Since the text is optimized for screen viewing, the type is larger than that in usual printed books. Copyright 2009-2010 © - Keith Lock – All Rights Reserved Geo-Targeting Script
  • 3. Geo-Targeting Script Installation Instructions For PHP Based Sites Page: 3 First Things First 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 Wordpress. The 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. Copyright 2009-2010 © - Keith Lock – All Rights Reserved Geo-Targeting Script
  • 4. Geo-Targeting Script Installation Instructions For PHP Based Sites Page: 4 Disclaimer This guide has been written to provide information to help you install the geo- targeting script. Every effort has been made to make this report as complete and accurate as possible. However, there may be mistakes in typography or content. Also, this report contains information on editing php code for installing the geo-targeting script only up to the publishing date. Therefore, this report should be used as a guide – not as the ultimate source of editing php code. The purpose of this report is to point you in the right direction for getting the geo-targeting script working. The author and publisher does not warrant that the information contained in this report is fully complete and shall not be responsible for any errors or omissions. The author and publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by this report and the geo-targeting script. You and your staff are solely responsible for the voluntary use and installation of the geo-targeting script. If you do not wish to be bound by the above, please return the geo-targeting script for a full refund. Copyright 2009-2010 © - Keith Lock – All Rights Reserved Geo-Targeting Script
  • 5. Geo-Targeting Script Installation Instructions For PHP Based Sites Page: 5 Message From The Author I have been making a living online for several years building and selling niche web sites and blogs. As a long time user of the phpBay Pro Wordpress plugin to quickly insert eBay auctions into my niche sites (where I get paid to refer customers to eBay), I quickly found the need to automatically show auctions to customers of specific countries. I found a solution to accomplish that and developed the phpBay Pro Extended Manual to help other phpBay users achieve geo-targeting with phpBay, plus other advanced tasks. The issue that arose therafter was the inability to automatically show other types of ads or content (besides eBay auctions) to visitors of specific countries. So, I had a geo-targeting script developed to work for any type of content. Future plans include developing plugins, and offering the ability to target visitors based on city and state/province. Copyright 2009-2010 © - Keith Lock – All Rights Reserved Geo-Targeting Script
  • 6. Geo-Targeting Script Installation Instructions For PHP Based Sites Page: 6 Table Of Contents • Script Files and Database Update Explanation (optional) • Step 1 – Uploading/Installing The Script • Step 2 - Displaying Unique Content For A Specific Country Copyright 2009-2010 © - Keith Lock – All Rights Reserved Geo-Targeting Script
  • 7. Geo-Targeting Script Installation Instructions For PHP Based Sites Page: 7 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 Copyright 2009-2010 © - Keith Lock – All Rights Reserved Geo-Targeting Script
  • 8. Geo-Targeting Script Installation Instructions For PHP Based Sites Page: 8 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 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/3000- 2250_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 right- click 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 Geo- Targeting 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. Copyright 2009-2010 © - Keith Lock – All Rights Reserved Geo-Targeting Script
  • 9. Geo-Targeting Script Installation Instructions For PHP Based Sites Page: 9 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-geo- targeting-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. Copyright 2009-2010 © - Keith Lock – All Rights Reserved Geo-Targeting Script
  • 10. Geo-Targeting Script Installation Instructions For PHP Based Sites Page: 10 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. 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. Copyright 2009-2010 © - Keith Lock – All Rights Reserved Geo-Targeting Script
  • 11. Geo-Targeting Script Installation Instructions For PHP Based Sites Page: 11 Step 2 – Displaying Unique Content For A Specific 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! Copyright 2009-2010 © - Keith Lock – All Rights Reserved Geo-Targeting Script
  • 12. Geo-Targeting Script Installation Instructions For PHP Based Sites Page: 12 <?php } else { ?> Add your 300x250 Google AdSense script here to be seen by all other countries! <?php } ?> 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 Copyright 2009-2010 © - Keith Lock – All Rights Reserved Geo-Targeting Script