@mattab opened this Issue on February 22nd 2019 Member

It would be valuable to be able to create segments made of other segments. The idea is that when creating a segment, there would be a new set of segments which would let you reuse any other existing segment.

For example you could have a segment Contacted us and create another segment Contacted us (Newsletter) which would say "Campaign Source is newsletter AND Visit match segment Contacted us'. So you can reuse another segment and not duplicate the logic. And it is now possible to select "Visit match segment XYZ" for any existing segment.

Why is it valuable?

There are use cases where it's not possible to create one segment that matches all conditions we need.

  • For example to define a segment where a visitor IP is within a set of IP ranges. See faq https://matomo.org/faq/how-to/faq_21018/ - one can write visitIp>=147.28.0.0 AND visitIp<=147.28.255.255 but you can't write multiple such statements separated by OR combination, because the OR takes precedence (see https://developer.matomo.org/api-reference/reporting-api-segmentation#combine-segments-with-and-and-or-expressions ). It's simply impossible currently to create a segment like this and combine multiple conditions. But it would be great to be able to create a segment "Visit match segment RangeX OR Visit match segment RangeY OR Visit match segment RangeZ".
  • There are several various use cases around reusing segments and minimising duplication of segment definitions across multiple segments. For example: Let's say you have an existing segments isolating a sub folder of your site ("Page URL contains /sub-folder/) and another existing one to only see 404s and 500s (Custom dimension Page code is 400 or Custom dimension page code is 500), could you apply both at the same time instead of creating a new one that has both sets of conditions?
@fredvd commented on June 9th 2022

This issue is IMHO one of the examples that demonstrate a drawback of 'plugin financed' open source business models:

It's frustrating that for any organisation small or large with multiple ip ranges in their internal networks they can't create a segment that filters out that internal traffic. this issue is from 2019, it's 2022 now. This is a very valid use case and allthough I really want to promote the use of Matomo at our customers and in our community (Plone) it is gaps like these that don't get addressed in 3 years that make me doubt.

I know part of the reason why this is issue is not made a priority and/or addressed, because it is in the documention and FAQ's: please buy our commercial Custom Reports plugin that has a better and/or rules UI without this limitation.

@fredvd commented on June 9th 2022

For others searching for a solution and finding this issue because they want to create a segment with multiple ip ranges to compare traffic sources or see if 'internal' traffic is significant, you can do the following:

Create a segment for each internal ip range and then in the drop down for segments there squarish (open book?) icon left of the edit icon that allows you to compare segments. You can add multiple segments to see them in one graph for for example visitors and pages views and then you can check if the traffic is significant.

segment drop downcompare multiple segments
@sgiehl commented on June 9th 2022 Member

@fredvd Even the custom reports plugin wouldn't allow you to combine multiple IP ranges into one segment, but you could create segmented reports for each ip range.

Powered by GitHub Issue Mirror