04 - Reporting API - Aggregation and Advanced Filtering

Aggregation

With aggregation, you can regroup rows having the same value for a given column.

Process

  1. A computation field is attributed to each aggregation field (specified in the advancedFields parameters of the JSON). See table Aggregation criteria, which describes the link between a computation field and its associated aggregation fields.
  2. The metrics are then computed, and rows having the same values for all computation fields are regrouped together.
  3. The report is created, displaying the aggregation field specified in the JSON.

Duplicate rows

Computation fields are used to regroup rows. This makes sure that computation fields remain unique.
However, the aggregation fields may not be unique, which may lead to duplicate rows.
For instance, you may have multiple pages with the same name. Computing a metric solely based on a page name will regroup rows based on the page id. Thus, the report will have rows with the same page name.

In this situation, aggregating by page id AND page name will clarify why two rows have the same name, but are actually different.

Limitation

When specifying the output as being SQL, aggregation fields are limited to the list of computation fields instead.

A list of all Aggregation criteria and metrics is available here.

Advanced Filtering

Overview

You can filter the logs that will be used in the query. This is accomplished with an advanced criterion. These are simple filters on one criterion. They are grouped in a list called advanced criteria. In such a list, if any advanced criterion is not valid, the log will be filtered.

A list of all operators and filter criteria is available here.

Representation of an advanced criterion

An advanced criterion contains three pieces of information:

  1. A criterion, represented by its name or id
  2. An operator, represented by its name
  3. A list of values which will be used when applying the operator

JSON representation of an advanced criterion:

[
   {
      "criteria name":{
         "operator":"operator name",
         "values":[
            "first value",
            "second value"
         ]
      }
   }
]

Multiple criteria in an advanced criterion

When using multiple criteria in an advanced criterion, the resulting behavior will depend on which criteria are used.

Typically, the behavior will be the same as for multiple advanced criteria: they must all be valid to keep the log.

However, there are exceptions: for the following criteria, the log will be kept when only one of multiple criteria will be valid:

  • site and page
  • quovaCounrtyId, quovaStateId and quovaCityId

In other words:

  • multiple advanced criteria are AND-connected with each other
  • multiple criteria of an advanced criterion are usually AND-connected with each other; with the exception of
  • site and page, or quovaCounrtyId, quovaStateId and quovaCityId, which are OR-connected with each other

JSON example of advanced filtering

The following example requests the impression count

  • between 2016-03-07T15:29:20GMT and 2016-03-09T13:58:35GMT
  • where the os is greater than 11063
  • where either the page is 1000006963, or the site is 1000002726.
{
   "startDate":"2016-03-07T15:29:20",
   "endDate":"2016-03-09T13:58:35",
   "advancedfilter":[
      [
         {
            "OsId":{
               "operator":"gt",
               "values":[
                  "11063"
               ]
            }
         }
      ],
      [
         {
            "PageId":{
               "operator":"in",
               "values":[
                  "1000006963",
                  "1000006964"
               ]
            }
         },
         {
            "SiteId":{
               "operator":"in",
               "values":[
                  "1000002726"
               ]
            }
         }
      ]
   ],
   "fields":[
      {
         "InsertionName":{
         }
      },
      {
         "Impressions":{
         }
      }
   ],
   "outputParameters":{
      "outputDestination":"HDFS"
   }
}
Was this article helpful?
0 out of 0 found this helpful
Powered by Zendesk