Building a report involves several steps:
- Fetch available dimensions and metrics via the API.
- Apply filters progressively to narrow your data set.
- Issue a query combining filters, splitters (grouping dimensions), and metrics.
- Sort and analyze the results.
Example: Let's imagine you want to have the number of audio impressions in two cities: New York and Las Vegas, for some specific campaigns that run in those cities only on mobile devices, grouped by advertisers in a specified time interval. You will need to request the list of cities from the system with a filter query like this:
{
"id": "geoCity",
"interval": {
"from": "2018-10-01T00:00:00Z",
"to": "2018-10-19T23:59:59Z"
},
"limit": 20
}
From the response list, we select the two cities we are interested in and request a new filter for the campaign with the two cities as arguments.
The second request will look like this:
{
"id": "campaignName",
"filter": {
"type": "AND",
"fields": [{
"id": "geoCity",
"type": "IN",
"values": ["new york", "las vegas"]
}]
},
"interval": {
"from": "2018-10-01T00:00:00Z",
"to": "2018-10-19T23:59:59Z"
},
"limit": 20
}
From the response list, we select the campaign we are interested in and request a new filter:
{
"id": "deviceTypeLabel",
"filter": {
"type": "AND",
"fields": [{
"id": "geoCity",
"type": "IN",
"values": ["new york", "las vegas"]
}, {
"id": "campaignName",
"type": "IN",
"values": ["MyAwesomeCampaign(239)", "MyProfitableCampaign(240)"]
}]
},
"interval": {
"from": "2018-10-01T00:00:00Z",
"to": "2018-10-19T23:59:59Z"
},
"limit": 20
}
With all these results from the previous filters, we can then issue a query request like this:
{
"filter": [
{"id": "geoCity","values": ["new york", "las vegas"]},
{"id": "campaignName","values": ["MyAwesomeCampaign(239)", "MyProfitableCampaign(240)"]},
{"id": "deviceTypeLabel","values": ["mobile"]}
],
"splitters": [{"id": "advertiserName","limit": 5}],
"metrics": ["impressions"],
"interval": {
"from": "2018-10-01T00:00:00Z",
"to": "2018-10-19T23:59:59Z"
},
"sort": {
"id": "impressions",
"dir": "DESC"
}
}
This will return the impressions grouped by advertiser, descending by the number in the specified interval.