Adobe Analytics 2.0 API endpoint to get report suite events, props, and evars

蓝咒 提交于 2020-02-06 08:05:15

问题


I'm having a hard time finding a way in the 2.0 API that I can get a list of Evars, Props and Events for a given report suite. The 1.4 version has the reportSuite.getEvents() endpoint and similar for Evars and Props.

Please let me know if there is a way to get the same data using the 2.0 API endpoints.


回答1:


The API v2.0 github docs aren't terribly useful, but the Swagger UI is a bit more helpful, showing endpoints and parameters you can push to them, and you can interact with it (logging in with your oauth creds) and see requests/responses.

The two API endpoints in particular you want are metrics and dimensions. There are a number of options you can specify, but to just get a dump of them all, the full endpoint URL for those would be:

https://analytics.adobe.io/api/[client id]/[endpoint]?rsid=[report suite id]

Where:

[client id] - The client id for your company. This should be the same value as the legacy username:companyid (the companyid part) from v1.3/v1.4 API shared secret credentials, with the exception that it is suffixed with "0", e.g. if your old username:companyid was "crayonviolent:foocompany", the [client id] would be "foocompany0", because..reasons? I'm not sure what that's about, but it is what it is.

[endpoint] - Value should be "metrics" to get the events, and dimensions to get the props and eVars. So you will need to make 2 API endpoint requests.

[rsid] - The report suite id you want to get the list of events/props/eVars from.

Example:

https://analytics.adobe.io/api/foocompany0/metrics?rsid=fooglobal

One thing to note about the responses: they aren't like the v1.3 or v1.4 methods where you query for a list of only those specific things. It will return a json array of objects for every single event and dimension respectively, even the native ones, calculated metrics, classifications for a given dimension, etc. AFAIK there is no baked in way to filter the API query (that's in any documentation I can find, anyways..), so you will have to loop through the array and select the relevant ones yourself.

I don't know what language you are using, but here is a javascript example for what I basically do:

var i, l, v, data = { prop:[], evar: [], events:[] };

// dimensionsList - the JSON object returned from dimensions API call
// for each dimension in the list..
for (i=0,l=dimensionsList.length;i<l;i++) {
  // The .id property shows the dimension id to eval
  if ( dimensionsList[i].id ) {
    // the ones we care about are e.g. "variables/prop1" or "variables/evar1"
    // note that if you have classifications on a prop or eVar, there are entries 
    // that look like e.g. "variables/prop1.1" so regex is written to ignore those
    v = (''+dimensionsList[i].id).match(/^variables\/(prop|evar)[0-9]+$/);
    // if id matches what we're looking for, push it to our data.prop or data.evar array
    v && v[1] && data[v[1]].push(dimensionsList[i]);
  }
}
// metricsList - the JSON object returned from metrics API call
// basically same song and dance as above, but for events. 
for (var i=0,l=metricsList.length;i<l;i++) {
  if ( metricsList[i].id ) {
    // events ids look like e.g. "metrics/event1"
    var v = (''+metricsList[i].id).match(/^metrics\/event[0-9]+$/);
    v && data.events.push(metricsList[i]);
  }
}

And then the result data object will have data.prop,data.evar, and data.events, each an array of the respective props/evars/events.

Example object entry for an data.events[n]:

{
    "id": "metrics/event1",
    "title": "(e1) Some event",
    "name": "(e1) Some event",
    "type": "int",
    "extraTitleInfo": "event1",
    "category": "Conversion",
    "support": ["oberon", "dataWarehouse"],
    "allocation": true,
    "precision": 0,
    "calculated": false,
    "segmentable": true,
    "supportsDataGovernance": true,
    "polarity": "positive"
}

Example object entry for an data.evar[n]:

{
    "id": "variables/evar1",
    "title": "(v1) Some eVar",
    "name": "(v1) Some eVar",
    "type": "string",
    "category": "Conversion",
    "support": ["oberon", "dataWarehouse"],
    "pathable": false,
    "extraTitleInfo": "evar1",
    "segmentable": true,
    "reportable": ["oberon"],
    "supportsDataGovernance": true
}

Example object entry for a data.prop[n]:

{
    "id": "variables/prop1",
    "title": "(c1) Some prop",
    "name": "(c1) Some prop",
    "type": "string",
    "category": "Content",
    "support": ["oberon", "dataWarehouse"],
    "pathable": true,
    "extraTitleInfo": "prop1",
    "segmentable": true,
    "reportable": ["oberon"],
    "supportsDataGovernance": true
}


来源:https://stackoverflow.com/questions/58443424/adobe-analytics-2-0-api-endpoint-to-get-report-suite-events-props-and-evars

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!