"Visitors in Real Time" widget reports wrong country of origin

Dear All,

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: is reported as Spain but is actually Panama. is reported as USA but is actually Thailand

Thanks for any help.

I’m experiencing the same thing:

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?

Yes that’s what I think too - but suspect that we cannot alter the database ourselves - or can we??? Maybe I need to take a closer look at the config of piwik.

This is the first response to this problem - I hope experienced piwikers will respond.



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.

Thank you for your assistance.

The Live widget doesn’t use the countries reported by GeoIP. This will be fixed when we integrate GeoIP into the core distribution.

OK - thank you so much.


Thanks – working for me now, too.

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!


This is answered in the FAQ link that Matthieu posted earlier. The visitor probably changed his/her browser language settings (e.g., from en-ca to en-gb).

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.

Thanks you.

please READ Troubleshooting - Analytics Platform - Matomo

If you want to improve the country detection accuracy in Piwik, please install the GeoIP plugin.

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:

location_browser_lang: it-it,it,en-us,en
location_country: it
location_continent: eur

location_geoip_continent: eur
location_geoip_country: es
location_geoip_city: Castellbisbal
location_geoip_latitude: 41,4667
location_geoip_longitude: 1,9667


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?

Thanks in advanced.

That’s a bug until we include GeoIP plugin in core and make the integration 100% perfect… Include GeoIP in core after improvements · Issue #1823 · matomo-org/matomo · GitHub

This thread is 3 years old and the GeoIP plugin appears to not have been integrated with Piwik’s core yet.

Are there still plans to do this in the future? Or has this feature/fix been abandoned?

Hello Matt.
When will be integrate the GeoIP functions, as you have told me in the september 2011?
Really is a problem.

Thanks you.


i use this with my website www.mytouristdestinations.info but What is the solution for fix in definitive way this problem?

The solution is integrate the right system in Piwik for get the right ip location.

I was able to get GeoIP working a bit more properly by installing geoip PECL first PHP: Installation - Manual

then modify the code in Common.php

      * 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);
                        return strtolower($country);

                if(empty($lang) || strlen($lang) < 2)
                        return 'xx';

                $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.

You can also get an even more accurate Country & City Database from here to enjoy top accuracy in detecting your visitors locations.

See also the documentation about Geolocation - Analytics Reports in Piwik.