This API allows to compare the traffic based on two different sets of filters, which can be useful for A/B testing by for example using a two different custom parameter values. The operation issues several requests to /traffic and (either of the following) /traffic/event, /traffic/keyword or /traffic/custom. First, is uses the primary filter set (specified by the parameter 'filters') to aggregate a traffic summary and potentially a list of the most popular items. Then, it uses the items returned by the first part in combination with a reference filter set (specified by the parameter 'referenceFilters') to provide a baseline. The request and response are therefore somewhat similar to those specified in /traffic, /traffic/event, /traffic/keyword and /traffic/custom.
The user must be authenticated and have read permissions to the specified sites.
The time, field and filter selection restrictions are the same as for each particular type. See /traffic/event, /traffic/keyword or /traffic/custom.
This API is experimental and might be changed in future.
Request
The request object has the following fields:
|
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
String |
No |
The site to aggregate over. A more convenient alternative to |
|
|
Array of String |
No |
The set of sites to aggregate over. |
|
|
String |
No |
The site group to aggregate over. A more convenient alternative to |
|
|
Array of String |
No |
The set of site groups to aggregate over. |
|
|
Integer or String |
No |
The start time of the aggregation period specified according to Traffic time specification . The default value is one hour ago. |
|
|
Integer or String |
No |
The stop time of the aggregation period specified according to Traffic time specification . The default value is right now. |
|
|
String |
Yes |
The type of data ('event', 'custom' or 'keyword), if not specified the data to be returned includes only the summary. |
|
|
Array of String |
No |
The group name for the specified data type, see /traffic/event , /traffic/keyword or /traffic/custom . If specified, the result includes a list of top-itmes within according to the specified filters (see below). |
|
|
Array of String |
No |
The metrics to aggregate. The available field names are listed here . |
|
|
String |
No |
The field to be used for item ordering within each group. See /traffic/event . |
|
|
Array of String |
No |
The fields to aggregate a history for. Must be a subset of fields. Empty by default, i.e., no history data will be returned. Where fields will only return a single value for the full period, history will return an array of values for intervals within the period. Useful when creating tables or graphs. |
|
|
Integer |
No |
The number of intervals for history aggregation. The time between |
|
|
String |
No |
If defined, overrides |
|
|
Array of Object |
No |
The filters to be applied. Filter syntax is documented here . Conjunctive semantics ( |
|
|
Array of Object |
No |
The filters to be applied for reference data. Filter syntax is documented here . Conjunctive semantics ( |
|
|
Integer |
No |
The maximum number of items to return for each group. The default value is |
Response
The response object has the following fields:
|
Name |
Type |
Description |
|---|---|---|
|
|
Integer |
The start time of the aggregation period in seconds, measured in Unix time . |
|
|
Integer |
The stop time of the aggregation period in seconds, measured in Unix time . |
|
|
Object |
Contains the data summary aggregated according to ' |
|
|
Object |
Contains the data summary aggregated according to ' |
|
|
Array of Object |
The name of the group (if requested), e.g., ' |
Each group object contains three fields:
|
Name |
Type |
Description |
|---|---|---|
|
|
String |
The name of the item. |
|
|
Array of Object |
The top-items according to ' |
Each item object contains three fields:
|
Name |
Type |
Description |
|---|---|---|
|
|
String |
The name of the item. |
|
|
Object |
Contains the data aggregated according to ' |
|
|
Object |
Contains the data aggregated according to ' |
Examples
$ python cx.py /traffic/compare '{"siteId":"12345", "type":"event", "groups":["deviceType"], "fields":["events"], "filters":[{"type":"event","group":"referrerHost","item":"facebook.com"}]}'
{
"start": 1416306373,
"referenceData": {
"events": 547
},
"stop": 1416309973,
"groups": [
{
"items": [
{
"item": "Mobile",
"referenceData": {
"events": 324
},
"data": {
"events": 42
}
},
{
"item": "Desktop",
"referenceData": {
"events": 166
},
"data": {
"events": 28
}
},
{
"item": "Tablet",
"referenceData": {
"events": 57
},
"data": {
"events": 9
}
}
],
"group": "deviceType"
}
],
"data": {
"events": 79
}
]
$ python cx.py /traffic/compare '{"siteId":"12345", "type":"event", "groups":["city"], "filters":[{"type":"event","group":"deviceType","item":"Tablet"}], "referenceFilters":[{"type":"event","group":"deviceType","item":"Desktop"}], "count":3, "start":"-1d"}
{
"start": 1416223831,
"referenceData": {
"events": 4593
},
"stop": 1416310231,
"groups": [
{
"items": [
{
"item": "wuhan",
"referenceData": {
"events": 192
},
"data": {
"events": 77
}
},
{
"item": "london",
"referenceData": {
"events": 184
},
"data": {
"events": 61
}
},
{
"item": "cinisello balsamo",
"referenceData": {
"events": 95
},
"data": {
"events": 49
}
}
],
"group": "city"
}
],
"data": {
"events": 1783
}
}