matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.89k stars 2.65k forks source link

Visitor maps not showing regions correctly in most countries #13347

Closed CGsama closed 4 years ago

CGsama commented 6 years ago

I use the city db for geoip(php), all fine when using wordwide view. However, it couldn't show on reguion and city map. But correct at realtime map. 5 ac r9qwjo91 un 6d 2o s37 x s73o3r0 yh5x0xamp o6a xx h 0_snnmz k4

sgiehl commented 6 years ago

Are you using GeoIP 2 or GeoIP (Legacy)? Our map currently does not support showing regions in all cases for GeoIP 2, as it was not yet updated to support the ISO regions.

CGsama commented 6 years ago

I'm using the GeoIP2(php). Thanks for clarifying that. And for my IP which in Canada, I can see the region map shows correct.

parruc commented 6 years ago

Same problem here: for Italy with GeoIP2 (php) I can see the cities correctly but all regions are marked as unknown.

sgiehl commented 6 years ago

For GeoIP2 it will still show regions correctly if the FIPS and ISO code for a region is the same. That applies for US, CA and some smaller countries. We are working on updated maps to fully support the ISO codes GeoIP2 is using...

mattab commented 5 years ago

Since the upgrade to Geoip2, most of countries regions are not displayed correctly in the Maps. Maybe we should consider disabling the feature of Region mapping on our maps, since it doesn't work mostly -> Moving into the milestone so we can take a decision.

Because It feels bad to have a non working feature it may be easiest to disable region mapping completely

or should we "partially disable region mapping" if it still work for some countries? @sgiehl

thinkof4 commented 5 years ago

Will this bug ever be fixed, I mean this is an one year old issue...

dfabreguette commented 5 years ago

Same bug here ! Any workaround ? Capture d’écran 2019-10-17 à 09 39 43

mirkomaty commented 4 years ago

@sgiehl, @mattab What exactly is the problem with fixing this bug? These are the data we get from the maxdb:

{ "city": { ... } }, "continent": { ... }, "country": { "geoname_id": 2921044, "is_in_european_union": true, "iso_code": "DE", "names": { "de": "Deutschland", "en": "Germany", "es": "Alemania", "fr": "Allemagne", "ja": "????????", "pt-BR": "Alemanha", "ru": "????????", "zh-CN": "??" } }, "location": { ... }, "postal": { ... }, "registered_country": { ... }, "subdivisions": [{ "geoname_id": 2951839, "iso_code": "BY", "names": { "de": "Bayern", "en": "Bavaria", "es": "Baviera", "fr": "Bavière", "ja": "??????", "pt-BR": "Baviera", "ru": "???????", "zh-CN": "????" } } ] }

As we can see, in subdivisions.iso_code an iso_code is provided. If your maps are based on FIPS codes, all you have to do is to provide a translation based on a file, which can be filled by the community. We are interested in the regions for Germany. The FIPS codes for Germany are

GM01_414_414_state_land_Baden-Wurttemberg__ GM02_414_414_statelandBayernBavaria GM03_414_414_state_land_Bremen GM04_414_414_statelandHamburg GM05_414_414_state_land_Hessen GM06_414_414_statelandNiedersachsen GM07_414_414_state_land_Nordrhein-Westfalen GM08_414_414_statelandRheinland-Pfalz GM09_414_414_state_land_Saarland GM10_414_414_statelandSchleswig-Holstein GM11_414_414_state_land_Brandenburg GM12_414_414_statelandMecklenburg-Vorpommern GM13_414_414_state_land_Sachsen GM14_414_414_statelandSachsen-Anhalt GM15_414_414_state_land_Thuringen GM16_414_414_statelandBerlin__

All we need is a file with entries like

GM02 BY

or

GM02_414_414_state_land_BayernBavaria BY

whatever format your map expects. The task for a workaround is to provide an iso code and get a FIPS code.

If you gave me a hint, where I can find the map code I could try to provide that workaround.

That's what we can do now in V3 and an iso based solution can be done without haste for V4.

sgiehl commented 4 years ago

The problem is, that there is no exact mapping from ISO to FIPS code. You can find a mapping from FIPS to ISO here: https://github.com/matomo-org/matomo/blob/3.x-dev/plugins/GeoIp2/data/regionMapping.php

But it's not possible to invert the mapping for most of the countries. But it should be possible for Germany

sgiehl commented 4 years ago

Most regions should be shown correctly again with next release. Closing this one in favor of #11929, as new maps should fix that finally