Create Segment using AND clause

I tried to create a segment that includes sessions with pageviews for both URL1 and URL2.

I applied an initial “URL is URL1” condition and it was fine.
Then I added a second condition “URL is URL2” using the AND clause, but the output resulted in zero visitors.

Could this be a bug with the AND clause in segments?
Or have I misinterpreted how the AND clause should be applied?


You have to use OR condition, not AND

“URL is URL1” AND “URL is URL2” is TRUE only if both are true. But a user can’t vist both in the same time.

First, thank you for your prompt response.

I would like to clarify how AND/OR clauses work.

Does AND clause apply to actions within the same session (visit) or the same hit?
“Visiting both in the same time” implies that AND clause refers to the same hit.
My intention was to create a segment based on visits that include URL1 pageview and then URL2 pageview.

Regarding OR clause, the condition “URL is URL1” OR “URL is URL2” will include
visits with URL1 pageview + visits with URL2 pageview.
Won’t it?

Or am I missing something?

I think (but i don’t know for sure) that filter in segments apply to hit not to session (visit).

A filter in segment test a single action and, in a single action, the URL can only take on one value (A or B, not both). So, if you test with AND clause, the filter can never be satisfied.

You used “AND” clause assuming that check was at the session level, is it? That is, if in the same session user visit page A and visit page B, than, the “AND” clause is true. But in my experience, segments filters doesn’t work that way. They test only single action and, as I mentioned above, in the single action URL can only take on one value A or B.

In Google Analytics it seems to me that a segment like the one you would like could be made using the “sequens segment” but in Matomo i don’t know how to do it.

Sorry i can’t help you

Hi @SimoneF @JohnB

I think this depends on the type of dimension you segment on…If the dimension is a visit dimension (eg. user ID, date of visit, returning user, etc.) or if it is an action dimension (event name, url, etc).

Maybe a solution could be to use 2 new custom visit dimensions (eg called URL1 and URL2), not set by default.
If the user hits the URL1, then put some static value in the URL1 visit dimension, and if he hits the URL2, put some static value (can be the same or not as the one for URL1) in URL2. Now you can create a filter with the AND clause on URL1 and URL2