targetingLogic

Target campaign placement on the site using a logical expression.

Request format

https://adfox.yandex.com/api/v1
  ? object=campaign
  & action=targetWebsite
  & actionObject=targetingLogic
  & objectID=<integer>
  & siteID=<integer>
  & isRedefined=<integer>
  & isEnabled=<integer>
  & [blocks=<json>]

objectID*

ID of the object that the action is performed on.

siteID*

Site ID.

isRedefined*

Redefine targeting.

Acceptable values:

  • 0: Inherit targeting settings from a higher level. Level hierarchy from top to bottom:

    • Campaign.
    • Campaign on the site.
    • Campaign in the site section.
    • Campaign on the placement.
    • Banner.
  • 1: Cancel targeting settings at higher levels and use the settings of the current level.

isEnabled*

Enable logical targeting.

Acceptable values:

  • 0: Disabled. The blocks parameter is optional.
  • 1: Enabled. The blocks parameter is required.

blocks

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 the not 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 the logic_and and logic_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:

* Required

Response format

<response>
<status>
  <code>{integer}</code>
</status>
</response>

Response parameters

code

Request processing status. For the key, see Error handling.

Sample request and response

Request:

https://adfox.yandex.com/api/v1?object=campaign&action=targetWebsite&actionObject=targetingLogic&objectID=474205&isRedefined=1&siteID=123&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: