Segment Targeting API

Segment Targeting API

 


 

To add a segment to demand or supply targeting you have to create a segment group and add the ids of the segments to the group.

Create a Segment Group

SDK

Use tab completion with SDK to auto-complete function names or show field options!

In [1]: import springserve In [2]: tag = springserve.demand_tags.get(30424) In [3]: new_segment_group = { "group": "2", "white_list": false, "segment_group_type": "segments", "segment_ids": [11111 ] } In [4]: tag.segments_groups.append(new_segment_group) tag.segment_targeting_enabled = True In [5]: tag.save() In [6]: tag.ok Out [5]: True

REST API

PUT /api/v0/demand_tags/<id>

Headers

Content-Type application/json Authorization "yourAuthToken"

Body (example)

{ "segment_targeting_enabled":true, "segment_groups": [{ "group": "2", "white_list": false, "segment_group_type": "segments", "segment_ids": [ 11111, 22222 ] }] }

 

Response

Status code 200

{   "id": 316932,   "account_id": 391,   "name": "test_tag",   "active": true,   "rate": "0.01",  …     "segment_groups": [ { "id": 855, "group": "2", "white_list": false, "segment_group_type": "segments", "segment_ids": [ 10009, 10018 ], "partner_segment_ids": [] } ],     "frequency_caps": [] }

 

Add a Segment Group

SDK

In [1]: tag = springserve.demand_tags.get(30424) In [2]: tag.segment_groups.append({ 'group':0, 'whitelist':False, 'segment_group_type': 'segments', 'segment_ids': [11111]}) In [3]: changed = tag.save() In [4]: changed.ok Out [4]: True

Edit a Segment Group

SDK

In [1]: tag = springserve.demand_tags.get(30424) In [2]: tag.segment_groups[0]['segment_ids'].append(10009) In [3]: changed = tag.save() In [4]: changed.ok Out [4]: True