Fairly new to the Adobe Analytics API and I'm not sure how to go about pulling together some data that I need.
We have a Dimension we've created, which I'll just call 'evar' for now. I need to end up, further down my program, being able to select a segment and get a random selection of 'evar' values from the last 7 days. What I think I need from the API then is a report that will give me either:
That way I could cache the result for seven days before needing a new call, and I could retrieve my random set from the full set cache.
The Segments API endpoint doesn't appear to give me what I need, only the list of Segments.
If there's a way to get the 'evar' values per segment, then I could actually retrieve the list of 'evar' values as needed and merge them into a cache.
For now though, I have no idea how I would list the 'evar' values and filter them by their related Segments.
Any help is greatly appreciated.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @EmmenNarwhal ,
To use v2.0 API, other than (multi-)breakdown reports you must specify only one dimension. In this case, each of your random eVars will need a separate request. Though you could have a single request with all segments applied to that eVar.
Steps:
First, you will need to run the Segment API to get the segment IDs and their friendly names, e.g:
{
"content":[
{
"id":"s300000022_591a105ce4b0fc8647cec9ae",
"name":"non-oberon segment",
"description":"non-oberon segment",
"rsid":"obue.analytics.spa",
"owner":{
"id":596983
}
}
],
"totalElements":6,
"firstPage":true,
"numberOfElements":6,
"totalPages":1,
"lastPage":true,
"sort":null,
"size":10,
"number":0
}
Using these stored segment IDs you can parameterize your Reporting API request either as a global filter or as a metric filter applied to each eVar. E.g. (viewing occurrences from an eVar with two segments applied):
{
"rsid":"[Enter RSID]",
"globalFilters":[
{
"type":"dateRange",
"dateRange":"2017-12-31T00:00:00.000/2018-01-06T23:59:59.999"
}
],
"metricContainer":{
"metrics":[
{
"columnId":"0",
"id":"metrics/occurrences",
"filters":[
"0"
]
},
{
"columnId":"1",
"id":"metrics/occurrences",
"filters":[
"1"
]
}
],
"metricFilters":[
{
"id":"0",
"type":"segment",
"segmentId":"[Enter Segment ID here]"
},
{
"id":"1",
"type":"segment",
"segmentId":"[Enter Another Segment ID here]"
}
]
},
"dimension":"variables/[Enter Random eVar]",
"settings":{
"dimensionSort":"asc"
}
}
Alternatively, if the eVars are not actually random, you could create events associated to each eVar occurance. Then, other than the Segment API request, you would just need a single Reporting API which returned these events as metrics.
Hi @EmmenNarwhal ,
To use v2.0 API, other than (multi-)breakdown reports you must specify only one dimension. In this case, each of your random eVars will need a separate request. Though you could have a single request with all segments applied to that eVar.
Steps:
First, you will need to run the Segment API to get the segment IDs and their friendly names, e.g:
{
"content":[
{
"id":"s300000022_591a105ce4b0fc8647cec9ae",
"name":"non-oberon segment",
"description":"non-oberon segment",
"rsid":"obue.analytics.spa",
"owner":{
"id":596983
}
}
],
"totalElements":6,
"firstPage":true,
"numberOfElements":6,
"totalPages":1,
"lastPage":true,
"sort":null,
"size":10,
"number":0
}
Using these stored segment IDs you can parameterize your Reporting API request either as a global filter or as a metric filter applied to each eVar. E.g. (viewing occurrences from an eVar with two segments applied):
{
"rsid":"[Enter RSID]",
"globalFilters":[
{
"type":"dateRange",
"dateRange":"2017-12-31T00:00:00.000/2018-01-06T23:59:59.999"
}
],
"metricContainer":{
"metrics":[
{
"columnId":"0",
"id":"metrics/occurrences",
"filters":[
"0"
]
},
{
"columnId":"1",
"id":"metrics/occurrences",
"filters":[
"1"
]
}
],
"metricFilters":[
{
"id":"0",
"type":"segment",
"segmentId":"[Enter Segment ID here]"
},
{
"id":"1",
"type":"segment",
"segmentId":"[Enter Another Segment ID here]"
}
]
},
"dimension":"variables/[Enter Random eVar]",
"settings":{
"dimensionSort":"asc"
}
}
Alternatively, if the eVars are not actually random, you could create events associated to each eVar occurance. Then, other than the Segment API request, you would just need a single Reporting API which returned these events as metrics.
Edit: @Jacob-DDdev beat me to a write up by an hour, forgot to refresh the pa
Old programmer trick, publicly air your struggles and, while you wait, you'll find an answer to your problem. Just make sure you share your answer rather than disappear into the void.
So, apparently what I was looking for was the Report endpoint in the analytics API documented here: https://adobedocs.github.io/analytics-2.0-apis/. I was being thrown of by needing a Metric for the request even though I really don't need it.
The request body I'm using is as follows:
{
"rsid": "<string>",
"dimension": "variables/evar",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2020-05-05T00:00:00/2020-05-11T23:59:59"
}
],
"settings": {
"limit": "10",
"page": "1",
"dimensionSort": "asc"
},
"metricContainer":{
"metrics":[
{
"columnId":"0",
"id":"metrics/pageviews"
}
]
},
"rowContainer": {
"rowFilters": [
{
"dimension": "evar",
"segmentId": "<string>"
}
],
"rows": [
{
"rowId": "evar"
}
]
}
}
Breaking this down:
That's all for the moment. It seems to get the right data in Swagger, hopefully someone will coem along with a better way if this isn't it.