Create Filter (counting)
1
let storageId = 123
2
let filter = {
3
name:"my first filter",
4
type :"SEGMENT",
5
dimension_indexes:[1], // add column index 1 (postal code in example) in the stats file
6
column_filter:[ // filter on column value
7
{
8
column_index:1, // index 1, postal code in example
9
values:["54","67","57","68"], // postal code must start with this values
10
operator:"PREFIX" // indicate type of filter: EQUAL,PREFIX etc, see reference
11
not:false // if true reverse the condition (here, must not start with selected values)
12
}
13
]
14
segment_filter:{
15
segment: [{id:456}, {id:789}], // count for hash in segment 456 or 789
16
}
17
}
18
fetch("https://gateway.sirdata.io/api/v1/public/customer/storage/"+storageId+"/filter?=", {
19
"method": "POST",
20
"headers": {
21
"Content-Type": "application/json",
22
"x-api-token": "XXXXX-XXXXX-XXXXX-XXXXX",
23
},
24
"body": JSON.stringify(filter)
25
})
26
.then(response => {
27
console.log(response);
28
})
29
.catch(err => {
30
console.error(err);
31
});
Copied!
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

1
let storageId = 123;
2
let filterId = 456;
3
4
fetch("https://gateway.sirdata.io/api/v1/public/customer/storage/"+storageId+"/filter/"+filterId+"/counting?=", {
5
"method": "GET",
6
"headers": {
7
"x-api-token": "XXXXX-XXXXX-XXXXX-XXXXX",
8
},
9
})
10
.then(response => {
11
console.log(response);
12
})
13
.catch(err => {
14
console.error(err);
15
});
Copied!
Example of CSV stats
1
segment_name,segment_id,count
2
Sirdata [Interest] Ecology & Environment,14,375921
3
Sirdata [Interest] Auto & Vehicles > Electric Cars,1293,88115
4
Sirdata [Intent] Life Events > Home Movers,578,52699
5
Sirdata [Inferred] Life Events > Home Movers,2381,51828
6
Sirdata [Intent] Auto & Vehicles > Electric Cars,599,38929
7
Copied!
Copy link