We’ve migrated our documentation to a new site, which means some URLs have changed.
Audience

/traffic/compare

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

siteId

String

No

The site to aggregate over. A more convenient alternative to siteIds, in the case of just one site.

siteIds

Array of String

No

The set of sites to aggregate over.

siteGroupId

String

No

The site group to aggregate over. A more convenient alternative to siteGroupIds, in the case of just one site group.

siteGroupIds

Array of String

No

The set of site groups to aggregate over.

start

Integer or String

No

The start time of the aggregation period specified according to

Traffic time specification

. The default value is one hour ago.

stop

Integer or String

No

The stop time of the aggregation period specified according to

Traffic time specification

. The default value is right now.

type

String

Yes

The type of data ('event', 'custom' or 'keyword), if not specified the data to be returned includes only the summary.

groups

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).

fields

Array of String

No

The metrics to aggregate. The available field names are listed

here

.

orderBy

String

No

The field to be used for item ordering within each group. See

/traffic/event

.

historyFields

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.

historyBuckets

Integer

No

The number of intervals for history aggregation. The time between start and stop will be divided into this many buckets or intervals. The default value is 10, the maximum value is 2160.

historyResolution

String

No

If defined, overrides historyBuckets and divides the time between start and stop into intervals of the given length. The acceptable values are "hour" and "minute". The resulting number of buckets has to be between 2 and 2160. The resolution "minute" is not supported for data older than 31 days.

filters

Array of Object

No

The filters to be applied. Filter syntax is documented

here

. Conjunctive semantics (and) are assumed for the top-level filters.

referenceFilters

Array of Object

No

The filters to be applied for reference data. Filter syntax is documented

here

. Conjunctive semantics (and) are assumed for the top-level filters.

count

Integer

No

The maximum number of items to return for each group. The default value is 10, the maximum value is 20.

Response

The response object has the following fields:

Name

Type

Description

start

Integer

The start time of the aggregation period in seconds, measured in

Unix time

.

stop

Integer

The stop time of the aggregation period in seconds, measured in

Unix time

.

data

Object

Contains the data summary aggregated according to 'filters'.

referenceData

Object

Contains the data summary aggregated according to 'referenceFilters'.

groups

Array of Object

The name of the group (if requested), e.g., 'url'.

Each group object contains three fields:

Name

Type

Description

group

String

The name of the item.

items

Array of Object

The top-items according to 'filters'.

Each item object contains three fields:

Name

Type

Description

item

String

The name of the item.

data

Object

Contains the data aggregated according to 'filters'.

referenceData

Object

Contains the data aggregated according to 'referenceFilters'.

Examples

Bash
$ 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
 }
]
Bash
$ 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
 }
}

Last updated: