API method Live.getLastVisitsDetails retrieves data for different dates when trying to retrieve data for previous day and idSite is set to "all"
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
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=2 request works fine and serverDate is only 2022-11-22.
idSite=1,2 also produces the same issue as
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=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=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
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.
@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
@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: