@albertski opened this Issue on December 1st 2021

Looking over the docs, it mentions to comma separate the segments to use an OR condition, but it isn't working. When I comma separate my two segments (segment=eventCategory==MyFirstEvent,eventCategory==MySecondEvent), I get no records. If I run them separately (segment=eventCategory==MyFirstEvent), I do get a response.

Sample API Call that has two segments that is not working

https://www.example.com/piwik/index.php?module=API&method=Events.getCategory&secondaryDimension=eventAction&flat=1&token_auth=mykey&format=json&widget=1&moduleToWidgetize=Events&actionToWidgetize=getCategory&idSite=1&period=week&date=2021-11-15&filter_sort_column=nb_events&disableLink=1&filter_sort_order=desc&segment=eventCategory==MyFirstEvent,eventCategory==MySecondEvent

If I call MyFirstEvent and MySecondEvent separately, it does work so it looks like the comma separation is not work.

Working (with only MyFirstEvent):

https://www.example.com/index.php?module=API&method=Events.getCategory&secondaryDimension=eventAction&flat=1&token_auth=mykey&format=json&widget=1&moduleToWidgetize=Events&actionToWidgetize=getCategory&idSite=1&period=week&date=2021-11-15&filter_sort_column=nb_events&disableLink=1&filter_sort_order=desc&segment=eventCategory==MyFirstEvent

Working (with only MySecondEvent):

https://www.example.com/iindex.php?module=API&method=Events.getCategory&secondaryDimension=eventAction&flat=1&token_auth=mykey&format=json&widget=1&moduleToWidgetize=Events&actionToWidgetize=getCategory&idSite=1&period=week&date=2021-11-15&filter_sort_column=nb_events&disableLink=1&filter_sort_order=desc&segment=eventCategory==MySecondEvent

Your Environment

  • Matomo Version: 4.6.1
  • PHP Version: PHP 7.4
  • MySQL version: 10.2.41-MariaDB-log
  • Browser: Chrome / Safari
  • Operating System: CentOS Linux release 7.9.2009 (Core)
@sgiehl commented on December 2nd 2021 Member

@albertski For me or combined segments work as expected. Maybe you need to escape the segment in the url like segment=eventCategory%3D%3DMyFirstEvent,eventCategory%3D%3DMySecondEvent. Also depending on your archiving setting new segments might need to be archived before they are showing data...

Btw. what are you actually trying to achieve? Using the eventCategory segment on the Events report, might not result in what you might possibly expect. The eventCategory segment will segment for all visitors that had an event action with that category. The Event reports may therefor also include other event categories, which those segmented visitors had.

@albertski commented on December 2nd 2021

@sgiehl Say I have 10 events displaying but I only want two of them. I was using the segment to only display the two. Is that not a good approach? I also tried to escape the segment in the URL and it also does not work.

@sgiehl commented on December 2nd 2021 Member

Segments are actually good for "filtering" the data used to generate the report. So if you would like to see all events done by users using windows, or all countries users with tablets came from,.... But in your case it sound like you actually want to filter that specific report for certain values? In that case segments are actually a bad choice, because they take a lot time for calculation, which would actually be unneeded. You can use the filter_pattern api parameter. See https://developer.matomo.org/api-reference/reporting-api

@heurteph-ei commented on December 22nd 2021

Issue still to be let opened?

This Issue was closed on December 22nd 2021
Powered by GitHub Issue Mirror