Search code examples
adobe-analytics

Report Filtering With Adobe Analytics API


I am queuing and getting a report through the API and javascript, but now I want to start filtering the report. I want the results that come back to apply only to the user (other filters are needed too) who is requesting the report. What is the best way to put a filter on the initial report queue?

The way I am doing it now is adding a selected element to the report description:

...

"elements": [
            { "id": "page" },{ "id": "evar23" , "selected": ["295424","306313"]}

...

But this only seems to apply to the breakdown section of the results, not the top level count that is returned. I would expect the top level count in the below example be 66, not 68:

...

"counts":[
        "68"
        ],
                "breakdown":[
                    {
                        "name":"306313",
                        "url":"",
                        "counts":[
                            "43"
                        ]
                    },
                    {
                        "name":"295424",
                        "url":"",
                        "counts":[
                            "23"
                        ]
                    }
                ]
            }

,...

I know I can just crawl through the breakdown array and total up what I need, but the more filters I apply the messier it becomes. All of a sudden I am three levels deep in a nested array, making sure that all 3 breakdown names match my conditions. There must be a better way to do this, any ideas? Many thanks.


Solution

  • Although there are some possible limitations to them that I am still working through, it seems that segments is what I need, not elements.

    "segments": [
    {
        "element": "evar23","selected": ["295424","306313"]
    }]
    

    https://marketing.adobe.com/developer/forum/reporting/report-filtering-with-api