I am new to piwik and really like it. I am experiencing a strange problem. The widget correctly identifies the IP address and the ISP but refers to the wrong country and displays the wrong flag (see below). I do not know which IPlocator is being used to report results, but I have checked the location of IP addresses using ip2location.com and the IP addresses seem to return the correct country.
I presume this problem has been encountered before and that there is a solution. A quick scan of the forums does not seem to identify a similar problem.
Now here are two results:
126.96.36.199 is reported as Spain but is actually Panama.
188.8.131.52 is reported as USA but is actually Thailand
70.28.245.* (Canada) is reported as USA
117.206.192.* (India) is reported as USA
59.99.212.* (India) is reported as USA
My guess is that the Live plugin is accessing a database to look these up, and that that particular database is not very accurate. So what would it take to point the Live plugin to a different database?
Thanks Matthieu. I have checked the link and done all that it says.
Now Visitors > Locations & Provider reports locations correctly.
On the DASHBOARD (front page of piwik) - the following widget still reports incorrect data (even for the latest connections):
Visitors in Real Time
and I am not sure that the Visitor Countries widget is returning the correct data yet.
In other words, Visitors > Log seems still to have the old data. Should I remove the log files in the piwik database (and perhaps piwik will re-create them)?
Also, I was not able to change data from old connections (despite following instructions accurately) but that is ok as the installation is very new.
I see you are going to make changes to the Live! wiget as far a visitor countries are concerned. (using Geo IP). But I had to mention this if it might help. Yesterday I had a visitor from a certain IP, and Visitor Live! said he comes from Canada (where I am from), he returned 10 minutes later and Live! said he is from the United Kingdom, same IP. Strange eh!
But if italian user go in Spain o USA and visit site, piwik show visitor from italy. This is wrong.
Show the right IP from spain or Usa but visitor is considered in base to the browser language. This make the statistics not real.
GeoIP installed and working (i have checked that wrote right info in the table piwik_log_visit).
still show wrong flag (i have italian browser but i am located in Spain. I can see IP and spanish IP).
In database i have:
Geoip Ip plugin is working perfeclty writing data in the table but the widget still show italian flag. Look like that is not reading from geoip info wrote in the table.
looking to Localization and ISP page, i can see Continent (GeoIP), Country (GeoIP), Provider but not show City(GeoIP) (in the table piwik_log_visit is present this info in the column “location_geoip_city”).
In the Dashboard i have added the only 2 widgets avaibles From GeoIP: “Visitor Country” and “Visitor Continents”, but in base to the info provided from GeoIP pulgins is missed a widget with “Visitor City”.
What is the solution for fix in definitive way this problem?
* Returns the visitor country based on the Browser 'accepted language'
* information, but provides a hook for geolocation via IP address.
* @param string $lang browser lang
* @param bool $enableLanguageToCountryGuess If set to true, some assumption will be made and detection guessed more often, but accuracy could be affected
* @param string $ip
* @return string 2 letter ISO code
static public function getCountry( $lang, $enableLanguageToCountryGuess, $ip )
$country = null;
Piwik_PostEvent('Common.getCountry', $country, $ip);
$ip = Piwik_IP::N2P($ip);
$country = geoip_country_code_by_name($ip);
if(empty($lang) || strlen($lang) < 2)
$validCountries = self::getCountriesList();
return self::extractCountryCodeFromBrowserLanguage($lang, $validCountries, $enableLanguageToCountryGuess);
Good news: GeoIP is now integrated in Piwik, enabling Accurate Visitors Geolocation in your Analytics reports. To enable GeoIP go to the Settings > Geolocation admin page, and follow the short instructions.