Segment ID when using API

Has anybody found/used a parameter for segment ID.

Let me try and explain; when a segment is saved with a name and operator conditions, then can that same segment be referenced via the API, as an example, &segmentid=X

I can see that when an API request is made instead of a User action within the UI, if the segment is the same then Matomo does recognise the match and will pick up pre-processed data if that segment, or by config, is set to pre-process that segment during archive.

But what if I want to add a search or additional operators along with the same API that previously matched the existing segment.

Does Matomo recognise the partial match and use the pre-processed and already segmented data or simply start a completely new custom segment request without reusing archived data?

The following:

Custom segment via API:
&segment=referrerType==search;referrerKeyword==Matomo

Could be:

Custom segment using pre-processes saved segment as start: &segmentid=5;referrerKeyword==analytics

The example above feels like this would take advantage of pre-processing, less overhead on live requests and reduce the request string which can help when using ETL programs with character limits.

Hopefully I have explained enough for anyone reading to understand.

Any advice or opposition theories would be welcome too. If this doesn’t currently exisit, I feel this would be a good feature to add to the list.

Solution example:

https://demo.matomo.org/?module=API&method=SegmentEditor.get&idSegment=4&idSite=7&format=html&token_auth=anonymous

1 Like