I suggest using Google Analytics to your problem, but if you want to try yourself here is a starting point:
Take a look at this link http://www.geoplugin.net/php.gp, you get a full list of details about that ip address position, including latitude and longitude.
It is not that acurate but it works, and I use it. Here is a php script actually in use :
<?php
$ip_addr = $_SERVER['REMOTE_ADDR'];
$geoplugin = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip_addr) );
if ( is_numeric($geoplugin['geoplugin_latitude']) && is_numeric($geoplugin['geoplugin_longitude']) ) {
$lat = $geoplugin['geoplugin_latitude'];
$long = $geoplugin['geoplugin_longitude'];
}
echo $ip_addr.';'.$lat.';'.$long;
?>
You can see it working at http://whateverhappens.org/ip-addr/
And that a look at the Geoplugin website examples.