targetingLogic
Target a campaign using a logical expression.
Request format
https://adfox.yandex.com/api/v1
? object=campaign
& action=target
& actionObject=targetingLogic
& objectID=<integer>
& isEnabled=<integer>
& [blocks=<json>]
|
ID of the object that the action is performed on. |
|
Enable logical targeting. Acceptable values:
|
|
A representation of a logical expression in the form of an n-dimensional tree mapped to a non-recursive (ID links instead of a full description of child nodes) JSON structure of the following type is used:
As you can see, the structure provides for versioning, and the sample representation reflects version 1. Further changes/extensions are to be included in subsequent versions. Every node of the first version has four fields:
|
* Required
Response format
<response>
<status>
<code>{integer}</code>
</status>
</response>
Response parameters
|
Request processing status. For the key, see Error handling. |
Sample request and response
Request:
https://adfox.yandex.com/api/v1?object=campaign&action=target&actionObject=targetingLogic&objectID=474205&isEnabled=1&blocks={"version":1,"nodes":[{"id":1,"type":1,"value":{"subnodes":[2,3]}},{"id":2,"type":3,"value":{"key":2,"values":[6382, 6399]},"invert":true},{"id":3,"type":3,"value":{"key":6,"values":[136699]}}]}
Response:
<response> <status> <code>0</code> </status> </response>
Other actions with the object
See more actions with the campaign
object:
- Add a campaign.
- Get a list of campaigns.
- Delete a campaign.
- Edit a campaign.
- Get a list of campaign banners.
- Place a campaign on a site, a site section, or a placement.
ID of the object that the action is performed on.
Enable logical targeting.
Acceptable values:
-
0
: Disabled. Theblocks
parameter is optional. -
1
: Enabled. Theblocks
parameter is required.
A representation of a logical expression in the form of an n-dimensional tree mapped to a non-recursive (ID links instead of a full description of child nodes) JSON structure of the following type is used:
{"version": 1,"nodes": [{"id": 1,"type": 2, "value": { "subnodes": [2, 5, 6] }}, {"id": 2,"type": 1, "value": { "subnodes": [3, 4] }}, {"id": 3,"type": 3, "value": { "key": 1, "values": [6, 7, 8] }}, {"id": 4,"type": 3, "value": { "key": 1, "values": [4, 5] }}, {"id": 5,"type": 3, "value": { "key": 2, "values": [1] }}, {"id": 6,"type": 3,"invert": true, "value": { "key": 2, "values": [2] }}]}{"version": 1,"nodes": [{"id": 1,"type": 2, "value": { "subnodes": [2, 5, 6] }}, {"id": 2,"type": 1, "value": { "subnodes": [3, 4] }}, {"id": 3,"type": 3, "value": { "key": 1, "values": [6, 7, 8] }}, {"id": 4,"type": 3, "value": { "key": 1, "values": [4, 5] }}, {"id": 5,"type": 3, "value": { "key": 2, "values": [1] }}, {"id": 6,"type": 3,"invert": true, "value": { "key": 2, "values": [2] }}]}
As you can see, the structure provides for versioning, and the sample representation reflects version 1. Further changes/extensions are to be included in subsequent versions.
Every node of the first version has four fields:
-
id
: A unique identifier of a node within a tree. The numbering always starts with 1, and the node with ID 1 is always the root. -
invert
: An inversion flag. The method for setting thenot
logic. It's applied to the result of calculating the entire node. If there are child nodes, all of them are calculated first. -
type
: The node content type ID.1
: The grouping AND node.2
: The grouping OR node.3
: The node for checking user fields (PUIDs). Nodes of thelogic_and
andlogic_or
types actually implement brackets in which all child nodes are combined by the operation.
-
value
: A JSON representation of the node content as a key and its values.key
: The user characteristic ID.values
: An array of user characteristic value IDs. For example, characteristic №1 with the following values:a (valueID=10), b (valueID=20), and c (valueID=30)
.{"key": 1, "values": [10,20,30]}
See also:- Get a list of values of user targeting characteristics.
Required