Skip to content
Last updated

This example queries your most common cookies, filtered to only show cookies from the most recent page visit, sorted by page count.

This example groups by cookie name, cookie domain, and cookie party type, so you can get the aggregate counts of pages where each cookie was found. See the grouping documentation for more information.

Request

POST to https://api.observepoint.com/v3/reports/grid/cookies
{
  // Request 3 grouped columns, COOKIE_NAME, COOKIE_DOMAIN, and COOKIE_PARTY_TYPE,
  "columns": [
    {
      "columnId": "COOKIE_NAME",
      "groupBy": true
    },
    {
      "columnId": "COOKIE_DOMAIN",
      "groupBy": true
    },
    {
      "columnId": "COOKIE_PARTY_TYPE",
      "groupBy": true
    },
    // And one aggregated columne: the number of unique pages where each cookie was found
    {
      "aggregateFunction": "count_distinct",
      "aggregatedColumn": {
        "columnId": "FINAL_PAGE_URL"
      }
    }
  ],
  // (optional) Filter to only show the most recent audit run. This ensures you don't count old pages that may no longer exist.
  "filters": {
    "conditionMatchMode": "all",
    "conditions": [
      {
        "filteredColumn": {
          "columnId": "IS_MOST_RECENT_RUN"
        },
        "negated": false,
        "operator": "integer_in",
        "args": [1] // means "yes, the most recent audit run"
      }
    ]
  },
  "sortBy": [
    {
      // sort by unique page count, most common cookies on top
      "columnIndex": 3,
      "sortDesc": true
    }
  ],
  "page": 0,
  "size": 10000 // get the top 10,000 most common cookies
}

Example Response JSON

Grid API Response JSON
{
  "metadata": {
    "pagination": {
      "totalCount": 16312,
      "totalPageCount": 164,
      "pageSize": 100,
      "currentPageSize": 100,
      "currentPageNumber": 0
    },
  },
  "rows": [
    [
      "_cfuvid", // cookie name
      "medium.com", // cookie domain
      1, // enum value meaning 1st-party
      89336 // number of unique pages where this cookie was found
    ],
    [
      "uid", // cookie name
      "medium.com", // cookie domain
      1, // enum value meaning 1st-party
      89334 // number of unique pages where this cookie was found
    ],
    [
      "_s", // cookie name
      "app.link", // cookie domain
      2, // enum value meaning 3rd-party
      54936 // number of unique pages where this cookie was found
    ],
    ... // more rows omitted for brevity
}