Build segments based on userID

Hi everyone!

My team wants to be able to use additional information that isn’t present in Matomo itself but in our own database to create segments in Matomo. The additional information tells us whether users belong to group A (for example customers) or B (for example sales representatives). We want to be able to get separate reports for the two groups.

Matomo is set up in such a way that Matomo’s userIDs are equal to the userIDs in the database that holds the additional information.

I can determine which users belong to group A and B but I am stuck trying to translate this knowledge in to a segment. I have tried making new segments through the API. The definitions I used for the segments are all basically one long string like “userId==1,userId==2,userId==3…” containing all users that belong to the segment. In other words, the definition of any of the segments would be ‘only include data if userId is 1 OR 2 OR 3 … etc.’.

This does not work because the url quickly becomes too long for the API to handle. Even when it doesn’t though (I’ve played with the idea of making segments for random samples of 600 users instead of including all users) Matomo creates the segment but then gives an error about asking for too much data in the UI.

Does anyone have any idea how I could get this to work?

All feedback would be appreciated!

Thanks!

The best way is to add some custom visit dimension in the page, containing the group the user belongs to…
It needs the Matomo JavaScript has knowledge of the user group…

1 Like

I’ll look in to the custom dimensions, thank you!

Problem is I’ll need IT for that… if there’s any other way I’d love to know