What geo-targeting script are they using?

loophole

Registered Member
Joined
Apr 7, 2008
Messages
97
Reaction score
86
I'd like to set up a geotargeting script to insert country names in the sales letter based on IP address, like on
Code:
internetmilliondollars.com

Anybody knows what script that site is using?
 
If you just want a country, this is how I get ISO 2 letter country codes with php. ie US, UK, CA etc... Displaying full country names would require a little more coding to convert them.

-Get the php class for whois queries here:
Code:
http://sourceforge.net/projects/phpwhois/

-Download and decompress into your web root folder.

-Use something like this on your site:
PHP:
<?php
// Include PHPWhois libs
include('phpwhois/whois.main.php');
include('phpwhois/whois.ip.lib.php');
include('phpwhois/whois.ip.php');

// Figure out the client's IP
$ip = $_SERVER['REMOTE_ADDR'];

// Perform the IP whois query
$whois = new Whois();
$result = $whois->Lookup($ip,false);

$country_code = $result['regrinfo']['owner']['address']['country'];
echo $country_code;  // Will output 'CA', 'US' or wherever visitor is from
?>

I imagine full country names can also be obtained using mod_geoip for apache, but in my experience its not installed by default on most web hosts. Using mod_geoip is more accurate then the php only method above (you can get city and state I believe). Just goog mod_geoip for more info.

Hope it helps.
 
Grizzy,

I am no coding expert. I was thinking there's a simpler script I can install in same fashion as butterfly marke*ting or other membership/minisite scripts.

I'll check with you later on when I need to implement this.

Btw, do you have a site where you are using this script of yours?
 
Sorry i'm not to familiar with bfly marketing, but im sure you are right and there is a similar script out there. There is probably also a better way to do this in a different language.(or even in php?)

Actually I use this when I scan my proxies to get a country code, and not on a particular web site I own (but its the same principle).

If you want to use this I realize I forgot to add a little fix at the end needed to parse the country code from different structures of whois respones.

PHP:
<?php

// Include PHPWhois libs
include('phpwhois/whois.main.php');
include('phpwhois/whois.ip.lib.php');
include('phpwhois/whois.ip.php');

// Figure out the client's IP
$ip = $_SERVER['REMOTE_ADDR'];

// Perform the IP whois query
$whois = new Whois();
$result = $whois->Lookup($ip,false);

// Parse the country code
$country_code = $result['regrinfo']['owner']['address']['country'];
$country_code = $result['regrinfo']['owner']['address'];
if (strlen($country_code) != 2)
{
	$country_code = $result['regrinfo']['owner']['address']['country'];
	if (strlen($country_code) != 2)
	{
		$country_code = $result['regrinfo']['owner']['address'][1];
		if (strlen($country_code) != 2)
		{
			$country_code = $result['regrinfo']['owner']['address'][2];
			if (strlen($country_code) != 2)
			{
				$country_code = $result['regrinfo']['network']['country'];
			}
		}
	}
}

echo $country_code;  // Will output 'CA', 'US' or wherever visitor is from

?>

Hey just hit me up if you need help with it or have any problems at all.

Good luck.
 
maxmind offers a free geoip db. perhaps that could help?
 
yeah, go with the maxmind one. I can provide a full example of how to use the Binary format one if you need it.
 
I as just looking at the maxmind site, however I dont see where they offer the free DB. could you point me in the right direction.

Thanks
 
here you go:
Code:
http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/

that is the db, you'll hvae o figure out the code, though it isn't at all complicated to do so :)

Cheers!!
 
I as just looking at the maxmind site, however I dont see where they offer the free DB. could you point me in the right direction.

Thanks

If your doing this to try to increase conversions etc you should really look into the paid version of this database as it is far more accurate (take this from someone who has compared the 2 and owns it)
 
I was also looking for a geotargeting tool. In addition, to maxmind's free tool, I found this plugin for wordpress:
Code:
http://www.spoffle.com/technical/geotarget-wordpress-plugin/
 
If your doing this to try to increase conversions etc you should really look into the paid version of this database as it is far more accurate (take this from someone who has compared the 2 and owns it)

Although maxmind says that the free tool is inaccurate. Some long term users confirm that it was not accurate when geotargeting cities and towns. But reported that the free version was fine when geotargeting countries.
 
Back
Top