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.7k stars 2.62k forks source link

[Bug] Unique Visitors by Country are often overstated #21474

Open 9joshua opened 10 months ago

9joshua commented 10 months ago

What happened?

When exporting the Visitors -> Location -> Country table, the Unique Visitors metric is almost always greater that the actual number of Unique Visitors shown in Visitors -> Overview.

In the screenshot below the number of Unique Visitors shown on the map view agrees with the visitors overview total. However, adding the totals for each country shown on the map agrees with the Country table totals... image

This could be due to some visitors having dynamic IP addresses, which when changed, result in Maxmind not correctly identifying the same country on their next visit. However, when creating a segment report for a specific country there is still a discrepancy between Unique Visitors by Country and Unique Visitors in Visitors -> Overview... image

When using a segment by a specific country, any specific day shows the Unique Visitors by Country and the Unique Visitors in Visitors -> Overview agree. However, this is not the case with a country segment is not applied.

What should happen?

The Unique Visitors metric as exported in the Visitors -> Location -> Country table should at least agree with the sum of daily Unique Visitors shown when exporting the Visitors -> Overview -> Visits Overview chart when a single country is specified for a segment. Fixing this would likely improve related discrepancies when a segment is not applied.

How can this be reproduced?

  1. Create a country specific segment, i.e. "County is United States"
  2. Select a 'Month' period on the calendar.
  3. Export the data from the Visitors -> Location -> Country table
  4. Change the calendar to a date range including the same month in step 1 plus one day into the next month. This will force daily unique visitors to be shown in the Visitors -> Overview -> Visits Overview chart data export.
  5. Export the Visitors -> Overview -> Visits Overview chart data and delete the extra day added in step 4. This will leave you with, for example, a daily unique visitor value for each day of the selected month.
  6. Compare the totals between step 3 and step 5.

Matomo Version

Matomo 5

Matomo Patch or Minor Version

5.0

PHP Version

8.1

Server Operating System

NA

What browsers are you seeing the problem on?

No response

Computer Operating System

NA

Relevant log output

No response

Validations

heurteph-ei commented 10 months ago

@9joshua If a user comes twice a day, every day: Each day he will be counted as 1 uniquer visitor. Each month he will be counted as 1 unique visitor (if enable_processing_unique_visitors_month=1). But sum of unique visitors of each day will be 30 (or 28,29, 31 depending on the month ;-) ).

9joshua commented 10 months ago

Hi @heurteph-ei Thanks for replying. In this case I have compared the sum of daily unique visitors for both the Country report and the Visits Overview report (see screenshots).

heurteph-ei commented 10 months ago

Hi @9joshua Then are you comparing unique visitors per country vs. unique visitors globally? If a user uses VPN for example (or is border dweller), and is located in one country during a visit, and in another country for a second visit the same day, he will appears as unique in both countries...

sgiehl commented 10 months ago

This might be a matter of the actual calculation. Haven't looked at the code, but I think the the "global" unique visitor metric is the only metric that might be calculated "correct" for the whole month. The unique visitors metric within other reports might be simply summed up across periods.