Sorting

Overview

Sorting the results of a query enables you to ask different questions about your data. E.g. what are the top campaigns that perform best in terms of conversions. It would sort by conversions metric in descending order. When applying sorting, keep in mind:

  • Results can either be sorted by multiple dimensions or one metric.
  • When both dimensions and metrics are provided for sorting object, only metric sorting applies.
  • When no direction is provided, default asc value is used.
  • Supported direction values are asc (asceding) and desc (descending).
  • Sort only by dimensions or metric values that you have used in the query.
  • For metrics, ascending order stands for numerical increasing order (e.g. 100 -> 101 -> 102 etc.)
  • For dimensions, ascending order stands for alphabetical sorting (e.g. for country dimension, values will be sorted Denmark -> France -> Germany -> Italy etc.).

JSON Sample

Metric


        {
   "filter": { ... },
   "metrics": [ ... ],
   "paging": { ... },
   "sort": {
      "metric": { // query can be sorted by one metric in descending or ascending order
         "metric": "clicks",
         "direction": "desc"
      }
   }
}
    

Dimension


        {
   "filter": { ... },
   "metrics": [ ... ],
   "paging": { ... },
   "sort": {
      "dimensions": [ // alternatively, query can be sorted by multiple dimensions in descending or ascending order
         {
            "dimension": "campaign",
            "direction": "desc"
         },
         {
            "dimension": "lineItem",
            "direction": "asc"
         }
      ],
   }
}
    
Help

Still have questions?

If you can't find an answer to your question here, email our Support team