Using Geotargeting

February 7th, 2008 by Richelo Killian ·

Before we get into using geotargeting, let’s quickly look at what it is 1st.

Geotargeting, or geographical targeting, is a way for a website to display content specific to a geographical location.

Whenever you visit any web site on the Internet, your IP address is logged. Your IP address is given to you by your Internet Service Provider (ISP). Each ISP is assigned a unique range of IP’s. Those IP’s are logged in a database which can be referenced, and thus, find out from which country you are from, and in the case of the larger countries like the US and the UK, even what state/county or even what city you are in!

Generally, smaller companies are not bothered with this information, as they believe it would be too difficult to use.

Well, hopefully in this article, I will show you how easy it is to use and drastically increase your online profits.

There are 2 ways you can use geotargeting on your site.

  1. Adevertising targeting. You see this on almost any big site you go to. Say for instance you visit www.yahoo.com, from the UK, you magically see adverts for the UK, even though Yahoo is based in the US. This part is REALLY easy, and there are tons of solutions you can use on your own site to show geotargeted adds. Our favourate and free one is: www.openads.org. Google AdWords also offers geotargeting. As advertising geotargeting is very well established, and discussed in so many places, this article will ignore this part.
  2. Site/content/page targeting. Just go to ask.com or google.com, and you will be presented with a version for your country. This is the main focus of this article. Not only how to do it, but, why to do it.

Geotargeting happens on the server, before the page is sent to the browser. When a user requests a page from the server, the server queries the user’s IP address against a database of worldwide IP addresses. The database identifies the country (sometimes even city!) of the user’s IP address, and then the server decides what to do.

 What can you use this for in your marketing efforts?

  • Serve language specific pages to specific parts of the world. Just remember that an English user might be traveling to Germany on business, but, would still like to see the English page, instead of the German one. Make it easy for the user to switch to a different language.
  • Maybe just change the language, or the style of the greeting to be regional.
  • Display completely different sales pages to different geographies, even down to city level.

If you are creative with geotargeting, you can drastically increase your sales, and/or, improve customer loyalty.

One fair warning if you are on shared hosting! These databases are quite big. Around 60K entries. Searching through that puts a fair load on your server, and I know of people who has had their shared hosting suspended for using this. Best is to use this only if you have a dedicated server.

Now, let’s look at some code!

I would recommend downloading the GeoIP Lite database from MaxMind because it is free and updated on a monthly basis.

Getting GeoIP data into your database is quite an easy process and only requires a single table. Then, when a visitor loads a page on your website, you can convert their IP address to a value in the database and match it up with what country they are in. Here is a PHP script you can use:

// connect to the database
$db = mysql_connect("localhost", "username", "password");
mysql_select_db("databasename", $db);

// get the user ip address and convert to an array
$ip = $_SERVER['REMOTE_ADDR'];
$ip_arr = explode(".", $ip);

// convert the ip address to an ip number
$ip_num = 16777216*$ip_arr[0] + 65536*$ip_arr[1] + 256*$ip_arr[2] + $ip_arr[3];

// get the country code
$result = mysql_query("SELECT country FROM geo_ip WHERE $ip_num BETWEEN begin_num AND end_num");
$row = mysql_fetch_array($result);
$country = $row['country'];

The “$country” variable will now contain the user’s country code (US, GB, CA, etc) which you can then use to determine what content to show or where to redirect them.

For a better explanation on how to use the database, read the official instructions.

What To Do With The Country Code

If you do any programming, you will have already figured out what you can do once you have the visitor’s country code. For those of you who are not familiar with a programming language, here is an example.

Lets say you have three pages set up. One page is specifically designed for United States visitors, one is for Canada visitors, and the last page is for all other visitors. You would use a simple “if-then” statement that checks the country code and sends the visitor to the correct page. Here is the PHP code for this example:

if ($country == 'US') { header('Location: /united_states.html'); }
else if ($country == 'CA') { header('Location: /canada.html'); }
else { header('Location: /other.html'); }

I hope this has given you some ideas of what can be done with geotargeting!

http://www.imnicamarketing.com/wp-content/plugins/sociofluid/images/digg_48.png http://www.imnicamarketing.com/wp-content/plugins/sociofluid/images/reddit_48.png http://www.imnicamarketing.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png http://www.imnicamarketing.com/wp-content/plugins/sociofluid/images/delicious_48.png http://www.imnicamarketing.com/wp-content/plugins/sociofluid/images/technorati_48.png http://www.imnicamarketing.com/wp-content/plugins/sociofluid/images/myspace_48.png http://www.imnicamarketing.com/wp-content/plugins/sociofluid/images/facebook_48.png http://www.imnicamarketing.com/wp-content/plugins/sociofluid/images/yahoobuzz_48.png http://www.imnicamarketing.com/wp-content/plugins/sociofluid/images/sphinn_48.png http://www.imnicamarketing.com/wp-content/plugins/sociofluid/images/twitter_48.png

Tags: , ,

3 Responses to “Using Geotargeting”

  1. I found your site on technorati and read a few of your other posts. Keep up the good work. I just added your RSS feed to my Google News Reader. Looking forward to reading more from you.

    Jason Rakowski

  2. Val says:

    Very informative and timely article Richard. Thank you!

Trackbacks/Pingbacks

  1. [...] Using Geotargeting… Read More [...]

Leave a Reply