Hi Isaac,
I am going to answer some questions and hopefully it will help you.
First to see what the request should look like with all of the options either use the api explorer (you do not need to input username and password to see default structure, simply select api Report and Method Queue ) or you could use swagger (Notice in Example Value you should see full structure of request). Right so not all fields are required to do a request and I will try to give example a bit later on.
How do i build multi-segment api requests
Ok so I think one of the solution would be to use inline segmentation
Another solution would be to apply filtering in the elements themselves:
Check reportDescriptionElement and reportDescriptionSearchType
(notice the element searches: this will allow you to create multiple searches, so first level would be type and and inside searches the different ones like not).
How do I build multi-metric api requests
You will need to specify different metric ids. (I do not know why you example works)
{
"reportDescription":{
"reportSuiteID":"reportSuiteId",
"dateFrom":"YYYY-MM-DD",
"dateTo":"YYYY-MM-DD",
"metrics":[
{
"id":"uniquevisitors"
},
{
"id":"event27"
},
{
"id":"event28"
},
{
"id":"event29"
},
{
"id":"event30"
},
{
"id":"event31"
},
{
"id":"event32"
},
{
"id":"cm2566_5adf02ff7245ec54ba3e7317"
},
{
"id":"cm2566_5adf01f90d38c21db0b2ba88"
},
{
"id":"cm2566_5adf037102f60c51b92c5d5f"
},
{
"id":"cm2566_5adf03a57a877de82a990a97"
},
{
"id":"cm2566_5adf04051d84534d9a98e6d9"
},
{
"id":"cm2566_5adf0424366e5b4688b4c62d"
},
{
"id":"cm2566_5adf046155bf155cfbf0af5e"
},
{
"id":"cm2566_5a4ba8b31d84536d599b3a99"
}
],
"segments":[
{
"id":"s2566_598b2c8b0d38c26a449bf986"
},
{
"id":"s2566_59c37616dd0ab15248d5a6bd"
},
{
"id":"s2566_59c4dfa9de89edf2ca867650"
},
{
"id":"s2566_597b01f70d38c20a175cd5d0"
}
],
"currentData":"true",
"elementDataEncoding":"utf8"
}
}
Notice that in the request above I specified default metrics (eventx) but also calculated metrics (cmXXXXX).
You will also notice that I used stacking segments as well.
How do i build multi-dimension api requests
I did not work with target data much so I won't be able to provide any insight target wise.
Having said that I think if you want to extract data where a dimension can be X or Y or Z then use one this solution:
- Segments: create either one segment with OR condition or multiple segments that you can stack up as above.
- Use elements filtering to filter only for value X, Y, Z
- Use inline segmentation as above.
If you want to get more than one dimension in the report then you will need to define more than one element.
{
"reportDescription":{
"reportSuiteID":"rsid",
"dateFrom":"YYYY-MM-DD",
"dateTo":"YYYY-MM-DD",
"metrics":[
{
"id":"uniquevisitors"
},
{
"id":"event27"
},
{
"id":"event28"
},
{
"id":"event29"
},
{
"id":"event30"
},
{
"id":"event31"
},
{
"id":"event32"
},
{
"id":"cm2566_5adf02ff7245ec54ba3e7317"
},
{
"id":"cm2566_5adf01f90d38c21db0b2ba88"
},
{
"id":"cm2566_5adf037102f60c51b92c5d5f"
},
{
"id":"cm2566_5adf03a57a877de82a990a97"
},
{
"id":"cm2566_5adf04051d84534d9a98e6d9"
},
{
"id":"cm2566_5adf0424366e5b4688b4c62d"
},
{
"id":"cm2566_5adf046155bf155cfbf0af5e"
}
],
"elements":[
{
"id":"evar9",
"top":"200",
"search":{
"type":"not",
"keywords":"FILTER1"
}
},
{
"id":"evar37",
"top":"200",
"search":{
"type":"or",
"keywords":"FILTER2"
}
},
{
"id":"evar7",
"top":"200"
}
],
"segments":[
{
"id":"s2566_598b2c8b0d38c26a449bf986"
},
{
"id":"s2566_59c37616dd0ab15248d5a6bd"
},
{
"id":"s2566_59c4dfa9de89edf2ca867650"
},
{
"id":"s2566_597b01f70d38c20a175cd5d0"
}
],
"currentData":"true",
"expedite":true,
"elementDataEncoding":"utf8"
}
}
One more thing, there is an API to create segments as well on fly, so you could always use this API before calling the Reporting API to do dynamic segmentation. I have a project internally when we run a ruby script to update a set of segments before the analysis workspace scheduled report run each week which allows us to not update the segments manually each week.
That is all from me.
Best regards.
Alexis Cazes