Create Filter (counting)

let storageId = 123
let filter = {
  name:"my first filter",
  type :"SEGMENT",
  dimension_indexes:[1], // add column index 1 (postal code in example) in the stats file
  column_filter:[ // filter on column value
    {
    column_index:1, // index 1, postal code in example
    values:["54","67","57","68"], // postal code must start with this values
    operator:"PREFIX" // indicate type of filter: EQUAL,PREFIX etc, see reference
    not:false // if true reverse the condition (here, must not start with selected values)
    }
  ]
  segment_filter:{
    segment: [{id:456}, {id:789}], // count for hash in segment 456 or 789
  }
}
fetch("https://gateway.sirdata.io/api/v1/public/customer/storage/"+storageId+"/filter?=", {
  "method": "POST",
  "headers": {
    "Content-Type": "application/json",
    "x-api-token": "XXXXX-XXXXX-XXXXX-XXXXX",
  },
  "body": JSON.stringify(filter)
})
.then(response => {
  console.log(response);
})
.catch(err => {
  console.error(err);
});

If response status code is 202 then proceed to get filter object each x seconds to check status until ERROR or OK

Get filter segments stats

Reference: https://openapi.sirdata.io/customer/#tag/filter/paths/~1customer~1storage~1{id}~1filter~1{filterId}~1counting/get

let storageId = 123;
let filterId = 456;

fetch("https://gateway.sirdata.io/api/v1/public/customer/storage/"+storageId+"/filter/"+filterId+"/counting?=", {
  "method": "GET",
  "headers": {
    "x-api-token": "XXXXX-XXXXX-XXXXX-XXXXX",
  },
})
.then(response => {
  console.log(response);
})
.catch(err => {
  console.error(err);
});

Example of CSV stats

segment_name,segment_id,count
Sirdata [Interest] Ecology & Environment,14,375921
Sirdata [Interest] Auto & Vehicles > Electric Cars,1293,88115
Sirdata [Intent] Life Events > Home Movers,578,52699
Sirdata [Inferred] Life Events > Home Movers,2381,51828
Sirdata [Intent] Auto & Vehicles > Electric Cars,599,38929

Last updated