This API extension allows to aggregate custom metrics from data associated with the DMP events.
-
This is an extension of /dmp/traffic, /dmp/traffic/event and /dmp/traffic/custom, see the corresponding documentation to enable DMP event feeding and APIs.Currently it is limited to numerical custom parameter data. The events fed to /dmp/push must override custom parameter specification to the following fields:
|
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
String |
Yes |
Parameter name, e.g., 'campaign', 'adspace' or 'creative'. |
|
|
String or Number |
Yes |
Parameter value, e.g. '"sale"', '0.32', '42'. The format must agree with the specified type, i.e., use "42" for string and 42 for number. |
|
|
String |
No |
Parameter type, e.g. 'number' or 'string'. Use number for items to be used as metrics, and string for items to be used in top-lists. |
Request
In addition to the parameters previously described for /dmp/traffic, /dmp/traffic/event and /dmp/traffic/custom, it is possible to specify a list of metrics to aggregate:
|
Name |
Type |
Required |
Description |
|---|---|---|---|
|
metrics |
Array of Object |
No |
Array of metrics to aggregate |
Each metric specification object contains the following fields:
|
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
String |
Yes |
Alias (name) of the metric. |
|
|
String |
Yes |
Type of the data to be used for this metric, currently is limited to ' |
|
|
String |
Yes |
Name of the data group to be used for this metric, currently limited to numerical values (strings will have no impact on the metric result). |
|
|
String |
Yes |
Operation type to be performed on the data, currently limited to ' |
|
|
Boolean |
No |
If yes, the result will contain historyData for the given metric according to historyResoultion/historyBuckets specified for this request. NOTE: history can be set to 'yes' only for **/dmp/traffic and not for /dmp/traffic/event or /dmp/traffic/custom.** |
Response
Consequently, in addition to data and historyData fields, the response will contain a list of aggregated metrics:
|
Name |
Type |
Description |
|---|---|---|
|
|
Array of Object |
Array of aggregated metrics |
Each metric result object contains the following fields:
|
Name |
Type |
Optional |
Description |
|---|---|---|---|
|
|
String |
No |
Alias (name) of the metric. |
|
|
Number |
No |
The aggregated number for this metric. |
|
|
Number |
Yes |
The aggregated history for this metric. Aggregated only when requested. |
Examples:
$ python cx.py /dmp/traffic '{"siteId":"1234", "start":"-10m", "metrics":[{"metric":"total", "type":"dmp-custom", "group":"value", "operation":"sum", "history":true}]}'
{
"metrics": [
{
"metric": "total",
"historyData": [
0.0,
0.0,
197.29999685287476,
288.99999809265137,
395.9000024795532,
282.2999975681305,
21.0,
0.0,
0.0,
0.0
],
"data": 1185.4999949932098
}
],
"start": 1425990250,
"stop": 1425990850,
"data": {
"events": 127
}
}
$ python cx.py /dmp/traffic/event '{"siteId":"1234", "start":"-10m", "metrics":[{"metric":"total", "type":"dmp-custom", "group":"value", "operation":"sum"}], "groups":["type"]}'
{
"start": 1425990310,
"stop": 1425990910,
"groups": [
{
"items": [
{
"metrics": [
{
"metric": "total",
"data": 0.0
}
],
"item": "conversion",
"data": {
"events": 75
}
},
{
"metrics": [
{
"metric": "total",
"data": 1406.8999979496002
}
],
"item": "impression",
"data": {
"events": 56
}
},
{
"metrics": [
{
"metric": "total",
"data": 164.60000038146973
}
],
"item": "click",
"data": {
"events": 5
}
}
],
"group": "type"
}
]
}