Add Content Targeting to Demand Tag
SDK
import springserve as ss
tag = ss.demand_tags.get(30424)
# The content targeting on a demand tag object is a list of dictionaries.
## Include the macro you want to target, allow/block list, values or list, ...
## ...targeted values or parameter list ids, and whether or not the param is required.
content_targeting = [
{
"macro_param": "{{CONTENT_TITLE}}",
"list_type": "white_list",
"source_type": "values",
"targeted_values": ["Breaking Bad"],
"param_required": False
},
{
"macro_param": "{{CONTENT_GENRE}}",
"list_type": "black_list",
"source_type": "list",
"parameter_list_ids": [46],
"param_required": False
},
{
"macro_param": "{{CONTENT_EPISODE}}",
"list_type": "white_list_partial_match",
"source_type": "values",
"targeted_values": ["1", "2"],
"param_required": True
},
{
"macro_param": "{{LANGUAGE}}",
"list_type": "black_list_partial_match",
"source_type": "values",
"targeted_values": ["es"],
"param_required": False
}
]
tag.targeted_macros = content_targeting
if tag.ok:
resp = tag.save()
if not resp.ok:
print(resp.error)
REST API
PUT /api/v0/demand_tags/<id>
Headers
Content-Type application/json Authorization "yourAuthToken"
Body (example)
curl -X PUT \
'https://console.springserve.com/api/v0/demand_tags/1226067' \
--header 'Accept: application/json' \
--header 'Authorization: authtokenhere' \
--header 'Content-Type: application/json' \
--data-raw '{
"targeted_macros_enabled": true,
"targeted_macros": [
{
"macro_param": "{{CONTENT_GENRE}}",
"list_type": "white_list",
"source_type": "list",
"parameter_list_ids": [46],
"param_required": false
},
{
"macro_param": "{{RATING}}",
"list_type": "black_list",
"source_type": "values",
"targeted_values": [
"r",
"tv-ma"
],
"param_required": false
}
]
}'
, multiple selections available,