@Sonofendor opened this Issue on November 23rd 2022

API method Live.getLastVisitsDetails retrieves data for different dates when trying to retrieve data for previous day and idSite is set to "all"

Expected Behavior

When sending request to API like method=Live.getLastVisitsDetails&idSite=all&period=day&date=yesterday data retrieved from API should have one similar serverDate for all records (because server and all the visitors are in one timezone in my case). For example if I send this request today (2022-11-23) the serverDate should be 2022-11-22

Current Behavior

Currently such request retreives data whith three different serverDate values: today, yesterday and day before yesterday (for example on 2022-11-23 I recieved serverDate values 2022-11-21,2022-11-22,2022-11-23). If I change parameter to idSite=1 or idSite=2 request works fine and serverDate is only 2022-11-22. idSite=1,2 also produces the same issue as idSite=all.

Result does not depend on format - I tried csv, xml, json and original. All have same issue

Also I tried following combinations of parameters and all of them produces the same results:

  • &period=day&date=yesterday
  • &period=day&date=YYYY-MM-DD
  • &period=day&date=previous1
  • &period=range&date=YYYY-MM-DD,YYYY-MM-DD (where YYYY-MM-DD is one same date)


We have ETL proccess that requests data for previous day from Matomo API whith Live.getLastVisitsDetails method and loads it to Data Warehouse. When we had only one site everything was working fine. Couple of weeks ago we changed idSite=1 to idSite=all and then found out that data has complete duplicates for every day since when we changed that parameter. It turned out that API was sending some of the visits twice on different dates.

For our purposes we now have two ETL processes (one for idSite=1 and other for idSite=2) but it would much better if API would work as expected

Your Environment

  • Matomo Version: 4.10.1 (on-premise)
  • PHP Version: 8.0.22
  • MySQL version: 10.6.8-MariaDB-log
  • Additionally installed plugins: None
@bx80 commented on November 23rd 2022 Contributor

Hi @Sonofendor, thanks for the detailed report :+1:

When data is requested for a specific site then that site's timezone is used.
When data is requested for all sites then the default timezone set at Administration > Measurables > Settings > "Default timezone for new websites" is used. By default this is set to UTC.

Could you check if your default timezone is set to the correct timezone for your server? If it is set to UTC then changing it to your timezone may fix this issue.

@Sonofendor commented on November 23rd 2022

@bx80 I checked and default timezone was indeed different from server's timezone. After I switched it to match, request seems to be working fine. Thank you!

However is such a nuance mentioned anywhere in documentation? I didn't manage to find it

@bx80 commented on November 23rd 2022 Contributor

@Sonofendor Glad to hear that worked for you :smiley:

The documentation could definitely be improved here, "Default timezone for new websites" doesn't indicate that this timezone will also be used when requesting data for all sites. I'll create a new issue to improve the documentation / UI to make this clearer :+1:

This Issue was closed on November 23rd 2022
Powered by GitHub Issue Mirror