How to get visits details (both past and present) for a userId

Hi all, new user here.

I am using the API to access visit data for some downstream analysis/visualization - Matomo is set up to use userId, and I can fetch data from when the userId is set and forward.

Here is what I’m trying to do:

Fetch a list of all visits (at the moment from Live.getLastVisitsDetails) for the set of visitors where userId, at some point, has been set to a specific value. In other words - all visits from before and after a userId is set for a specific user.

At the moment the only solution I have found is to call Live.getLastVisitsDetails on userId => parse the output for visitorId’s => make a request for each visitorId to Live.getLastVisitsDetails. But this is a quite heavy approach and requires additional logic downstream, so my question is if there is a better way that I’m not seeing at the moment.

So the questions:

It seems like a quite common thing to do, but I haven’t found a fitting function in the API, so I am looking for a way to create a query like the one described above using the exposed API?

If not - is there a way to extract the userId => visitorId mapping without fetching the entire Live.getLastVisitsDetails object?

1 Like

We are in the same boat. I am also looking for the same functionality in the API but has hit a brick wall. And for your question

I think you can you can use the Live.getVisitorProfile to retrieve visitorId , given you have a userId. See example in Postman