Search code examples
adobe-analytics

Adobe analytics API - Can you combine multiple segments in one report call?


I have a report in the Adobe Analytics UI which is segmented by 3 segments. I'm trying to mimic this report using the Adobe Analytics API (v2). I was able to successfully execute the report using the /report endpoint while applying a single segment with the globalFilters property. However I'm not seeing any indication that you can apply more then one segment per report.

Is there any way to execute a report with multiple segments via the API?

Here is the link to the report documentations

https://www.adobe.io/apis/experiencecloud/analytics/docs.html#!AdobeDocs/analytics-2.0-apis/master/reporting-guide.md

For reference, an example of the request data of a successful report with a single segment I was able to execute:

{"rsid": "{rsid}", 
"globalFilters": [{"dateRange": "2020-03-01T00:00:00.000/2020-03-25T23:59:59.999", "type": "dateRange"},
 {"type": "segment", "segmentId": "{segmentId}"}],
 "dimension": "variables/lasttouchchannel",
 "metricContainer": {"metrics": [{"columnId": "Cart Additions", "id": "metrics/visits"}], "metricFilters": []},
 "settings": {"limit": 250, "dimensionSort": "asc", "page": 0}}

Please let me know if more information is needed, Thanks in advance!


Solution

  • It turns out you can add multiple segments under global filters. Simply add them to the 'globalFilters' parameter.

    e.g.

    {"rsid": "{rsid}", 
    "globalFilters": [
    {"dateRange": "2020-03-01T00:00:00.000/2020-03-25T23:59:59.999", "type":"dateRange"},
     {"type": "segment", "segmentId": "{segmentId}"},  {"type": "segment", "segmentId": "{segmentId2}"}],
     "dimension": "variables/lasttouchchannel",
     "metricContainer": {"metrics": [{"columnId": "Cart Additions", "id": "metrics/visits"}], "metricFilters": []},
     "settings": {"limit": 250, "dimensionSort": "asc", "page": 0}}
    

    You can also add them under metricContainer.metricFilters[n] as suggested by Crayon Violent in the comments (thanks for the tips!), but I'm not sure if the results would be the same.

    Ultimately 'globalFilters' gave me the results I was looking for and that is the solution I want with.