getLastVisitsDetails with segments not returning expected data


#1

Hey all,

I’m working with the Live! API, specifically the getLastVisitsDetails function. I’d like to get select columns from this set of data over a period of a few years. I’ve read the documentation on this function and the segment function pretty thoroughly by now, but I’m getting some odd results and I can’t quite figure out what the deal is.

What I’m trying to do is get the list of visits that contain a certain Event Category over a given period of time. So, I’m using segmentation to limit my query to the event category I’m interested in. My query looks like this:

http://host/index.php?module=API&method=Live.getLastVisitsDetails&idSite=3&period=year&date=2016-01-01&format=xml&token_auth=myauthkey&filter_limit=100&segment=eventCategory==Media-Download

This returns 25 visits.

The problem is that I know (or have good reason to suspect) that there should be way more than 25 results. I would expect to hit the filter_limit of 100 rather readily. If I remove the segmentation, I do get 100 visits.

Another test was that if I remove the segmentation, but then search for the Media-Download action in the returning results, I get 29 results, not 25.

Something just seems off here and I’m hoping someone can guide me in the right direction.


#2

Hi everyone, just wondering if anyone has any ideas on this? Still having the problem and am stuck trying to figure out what might be the culprit


(Roddy A. Stegemann) #3

You do understand that this will likelly only read the data for the first day of 2016, do you not? The manual is misleading with regard to months, and I would not be surprised, if it were not also misleading with regard to years.

Roddy


(Lukas Winkler) #4

Hi,

I haven’t tested it, but I am pretty sure that &period=year&date=2016-01-01 returns the data of the full year in which 2016-01-01 is. Is there any reason for you to think otherwise or anything that could be improved in the docs?


(Roddy A. Stegemann) #5

To the best of my understanding Matomo reads backwards, not forwards in time. What is more, it reads according to the actual calendar dates, not the time elapsed.

If you want all of the information for 2016, then you should probably enter &period=year&date=2016-12-31

I only have data for this month and last month, and when I tried to discover last month’s data yesterday using &period=month&date=today nothing appeared, I was compelled to enter &period=year&date=today or &period=month&date=2018-05-31 in order to recover last month’s data.

The problem with the Matomo manual is that it is more focused on marketing than actual use, and in the end it probably does more to turn people away than to pull them in. Another important problem is terminology; the use of the words user and visitor is hopelessly confused. In the Matomo environment these are two very distinct kinds of people.

Roddy


(Stefan Giehl) #6

@Lukas is right. The period always selects “around” the given date. Some examples:

&period=month&date=2018-05-31 => whole month of May 2018
&period=week&date=2018-02-02 => week from 29 Jan to 4th Feb
&period=year&date=2018-12-31 => whole year 2018


(Roddy A. Stegemann) #7

Hi, Stefan!

Your examples are all backward looking as I suggested. In the original example provided by ddhahn the date parameter was used to look forward.

Roddy


(Stefan Giehl) #8

@Kiusau There is no “lookahead” or “backward”. The period is selected around the chosen date - no matter if the date is at the beginning, the end or somewhere in between.


#9

I didn’t understand this, so thank you!

It does seem odd that dates are referenced this way. It’s not how it’s written in the documentation, that’s for sure.


#10

OK after playing with this again after a little break, I can’t see what my problem was. I remember seeing the behavior that Roddy noted, but it doesn’t seem to behave like this any more.

This is very odd.