We all know how important Search Engine Optimization (SEO) is to an effective Search Engine Marketing (SEM) strategy. But wouldn’t it be nice if we could distill our efforts to specifics like geographical location, sure it would. Recently I was faced with an e-marketing dilemma that required the delivery of content to a specific Province in Western Canada, to an audience that only this messaging was applicable. Relevancy can be such a lonely place sometimes, oh well. The only way to shrug this one off is to employ “Geo Targeting” techniques to determine the geolocation of your website visitor to deliver content based on that visitor’s location.
First you’ll want to head over to MAXMIND and grab their GeoLite Legacy Downloadable Databases. Download and unpack the GeoLite City dat, you’ll need to include this file in the script for geo referencing. They are updated on the first Tuesday of each month. IP geolocation is inherently imprecise. Locations are often near the center of the population. Any location provided by a GeoIP database should not be used to identify a particular address or household.
Next you’ll want to download & unpack the PHP API for the database. You’ll need to include these three files geoip.inc, geoipcity.inc & geoipregionvars.php to ensure your script will run.
Now create a GeoIP PHP script like tweet-deals.php that will allow your Public IP Address (192.168.0.101) to echo a message that equals both a $_SERVER[‘REMOTE_ADDR’] and a GeoIP PHP Logical Operator like if($GEOIP_REGION_NAME[$record->country_code][$record->region] == ‘Ontario’) as a combined conditional statement. Remember to include all four of the aforementioned files above. Note: $_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server.
To get extra creative use PHP Logical Operators with $_SERVER[‘QUERY_STRING’] and PHP Comparison Operators against generated codes to echo Product Detail Pages (PDP) URLs.
Additionally, add JQuery to a PHP based form like tweet.php that appends an input field value to a “hidden” input field “URL” value (tweet-deals.php) that then utilizes PHP logic conditions using GeoIP to route users to content based on the algorithm.
See the demo in action, click on “Tweet” to get the deal!
BTW, if you live in Ontario Canada you’ll see “Get this Tweet deal now because it’s gonna fly south soon!“, but only if you enter the code “fuJXt7hQ” correctly. For everybody else…