{"_id":"5a547d90c5ebc7001e175011","project":"5429beef1163360800ed31fa","version":{"_id":"5429beef1163360800ed31fd","__v":22,"project":"5429beef1163360800ed31fa","createdAt":"2014-09-29T20:19:59.904Z","releaseDate":"2014-09-29T20:19:59.904Z","categories":["5429beef1163360800ed31fe","55e74e1f5d36b32b002563fa","55e7500a73169617001f2e86","55e76b8196131b2f00bf4b72","55e89569cdbb8a350096df9c","55f8935eb089b71700a8364e","55f8a67d3bb4bb0d0022d093","55f9dbefc7ef770d00d9bf6d","5601c21a22ecf60d002b27b3","5601c21ff12aee0d001bb06e","5601c2256c7b610d00280db5","5601c22c22ecf60d002b27b4","5603738d0c78b00d0039af47","5626f70bfcbbc621004ebf52","566f7a1ae144ab0d00e9732f","566f85ca7820960d00c3b93d","56708ce43a32d20d00c45cbf","56708d436995210d003aad8e","5736471abe10a9200030732c","57a82c7aff9bd30e00a6f1c1","591b8500e3992319007190f4","5a3718305c66a60012d960ba"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"55f9dbefc7ef770d00d9bf6d","version":"5429beef1163360800ed31fd","__v":6,"pages":["55f9eec4c7ef770d00d9bf83","55f9fb8daba81f0d00a11566","5601ca6870694e0d00e3c66f","5601cb9b96e0f70d0044b0fd","56157d7af2d81d0d006c895f","5671d738c17bf90d00b95822"],"project":"5429beef1163360800ed31fa","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-09-16T21:15:27.664Z","from_sync":false,"order":4,"slug":"publisher-ui-setup","title":"Trafficking and Inventory"},"user":"59521bff71e9dd0015d8e05e","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2018-01-09T08:30:08.518Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":true,"order":32,"body":"With Key Value expressions, we’ve come up with more productive targeting solution with which  you can deliver campaigns on the basis of logical combination of keys and values.\n\n**Logical Operators supported - AND, OR, IS, IS NOT** \n[block:api-header]\n{\n  \"title\": \"Creation of Key Value Expression\"\n}\n[/block]\nKV Expression can be created under ‘Targeting’ tab for campaigns.\n[block:api-header]\n{\n  \"title\": \"a. Creation of new rule\"\n}\n[/block]\n1. From the dropdown, you can select any static key, dynamic key or segment.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/deb1a7c-Screen_Shot_2018-01-07_at_11.47.46.png\",\n        \"Screen Shot 2018-01-07 at 11.47.46.png\",\n        1826,\n        722,\n        \"#f4f4f4\"\n      ]\n    }\n  ]\n}\n[/block]\n2. Once a key is selected, ‘Add Rule’ button(+) is seen near the ‘Delete Group’ button. Click on it to add a rule.\n3. If the key selected is static, select any value from the dropdown.\n4. If the key selected is dynamic, enter the value in the text box.\n5. You can add multiple rules for a single key.\n6. Use ‘AND-OR Toggle’ for rule to switch between logical operators OR & AND in a rule.\n7. Use ‘Equality Toggle’(IS/IS-NOT toggle) to switch between IS and IN NOT.\n8. Use ‘Delete Rule’ button to delete the rule.\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/5f2991b-Screen_Shot_2018-01-07_at_13.06.30.png\",\n        \"Screen Shot 2018-01-07 at 13.06.30.png\",\n        1830,\n        694,\n        \"#f4f4f4\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"b. Creation of new group\"\n}\n[/block]\n1. Click on ‘Add Group’ button .\n2. Select a key, add rules.\n3. Use ‘AND-OR Toggle’ for group to switch between logical operators OR & AND.\n4. Use ‘Delete Group’ button to delete the group.\n5. Multiple groups can be added for an expression.\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/d6e6e50-Screen_Shot_2018-01-07_at_12.56.01.png\",\n        \"Screen Shot 2018-01-07 at 12.56.01.png\",\n        1790,\n        996,\n        \"#f4f4f4\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"c. Creation of new expression\"\n}\n[/block]\n1. Click on ‘+Expression’ button.\n2. Add groups and rules.\n3. Use ‘AND-OR Toggle’ for expression to switch between logical operators OR & AND.\n4. Deleting the last group deletes the expression.\n5. Multiple expressions can be added.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/79c8ec3-Screen_Shot_2018-01-07_at_13.43.44.png\",\n        \"Screen Shot 2018-01-07 at 13.43.44.png\",\n        1832,\n        1208,\n        \"#f3f3f3\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"d. Creation of Segment KV expression\"\n}\n[/block]\n1. Select Segment from the keys dropdown.\n2. Click on Add Rule button.\n3. All the live segments will be displayed in the dropdown.\n4. Select the segments and create expression.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/cbcb06d-Screen_Shot_2018-01-09_at_18.22.46.png\",\n        \"Screen Shot 2018-01-09 at 18.22.46.png\",\n        1972,\n        746,\n        \"#f5f5f5\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Expression Summary\"\n}\n[/block]\nShows the KV expression in user friendly terms.\n[block:api-header]\n{\n  \"title\": \"Raw Expression\"\n}\n[/block]\nShows the KV expression saved internally in the db.\nFor example for the raw expression **day=monday&day!=tuesday**, \nBelow API calls will serve ads,\n**ck_day=monday\nck_day=monday&ck_day=thursday** \n[block:api-header]\n{\n  \"title\": \"Logic\"\n}\n[/block]\n  * All live keys will be displayed in the dropdown.\n  * If the key is paused after the expression is created, the key will removed from KV expression on ‘Save’.\n  * Expressions without parentheses will be evaluated from Left to Right.\n  * Adding KV expression with characters other than regex [A-Za-z_0-9-]+ from backend, won’t load the campaign on UI.\n  * We don’t support key with duplicate values in it.\n  * Open (non-parenthesized) rules can't be joined with parenthesized expressions.\n  * Maximum KV expression size is 255.\n[block:api-header]\n{\n  \"title\": \"Examples\"\n}\n[/block]\n**Evaluation of KV expression**\n**Expression : a=1|b=2&c=3**\n\t\nMethod A : Left-to-Right\nEvaluation of the above expression will be done from left to right. I.e a=1|b=2 will be evaluated first and the result will be evaluated against c=3.\ne1= a=1|b=2\ne2= c3\nMethod B : Precedence enforced with parentheses\nSuppose we need b=2&c=3 evaluated as an expression,then parentheses needs to be added\nModified expression :(a=1)|(b=2&c=3)\nFor the above expression, \ne1=(a=1)\ne2=(b=2&c=3)\n\n**Building an expression with parentheses**\n**Expression : (b=1|b=2)&(c!=3)**\n* Select ‘b’ key from the dropdown.\n* Click on ‘Add Rule’ button. Enter value of b as 1.\n* Add another rule, with value as 2.\n* Add a new expression.\n* From the dropdown, select ‘c’ key.\n* Enter the value as 3.\n* Use the Equality toggle to switch to IS NOT.\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/34a2854-Screen_Shot_2018-01-09_at_18.30.37.png\",\n        \"Screen Shot 2018-01-09 at 18.30.37.png\",\n        1920,\n        994,\n        \"#f6f6f6\"\n      ]\n    }\n  ]\n}\n[/block]\n**Invalid expressions**\n* a=1&a!=1\n* a=1&(a=2|a!=1)\n* a=1&b=2|(c=3|d=4)\n* &(a=1)&(c=2)","excerpt":"","slug":"key-value-expressions","type":"basic","title":"Key Value Expressions"}

Key Value Expressions


With Key Value expressions, we’ve come up with more productive targeting solution with which you can deliver campaigns on the basis of logical combination of keys and values. **Logical Operators supported - AND, OR, IS, IS NOT** [block:api-header] { "title": "Creation of Key Value Expression" } [/block] KV Expression can be created under ‘Targeting’ tab for campaigns. [block:api-header] { "title": "a. Creation of new rule" } [/block] 1. From the dropdown, you can select any static key, dynamic key or segment. [block:image] { "images": [ { "image": [ "https://files.readme.io/deb1a7c-Screen_Shot_2018-01-07_at_11.47.46.png", "Screen Shot 2018-01-07 at 11.47.46.png", 1826, 722, "#f4f4f4" ] } ] } [/block] 2. Once a key is selected, ‘Add Rule’ button(+) is seen near the ‘Delete Group’ button. Click on it to add a rule. 3. If the key selected is static, select any value from the dropdown. 4. If the key selected is dynamic, enter the value in the text box. 5. You can add multiple rules for a single key. 6. Use ‘AND-OR Toggle’ for rule to switch between logical operators OR & AND in a rule. 7. Use ‘Equality Toggle’(IS/IS-NOT toggle) to switch between IS and IN NOT. 8. Use ‘Delete Rule’ button to delete the rule. [block:image] { "images": [ { "image": [ "https://files.readme.io/5f2991b-Screen_Shot_2018-01-07_at_13.06.30.png", "Screen Shot 2018-01-07 at 13.06.30.png", 1830, 694, "#f4f4f4" ] } ] } [/block] [block:api-header] { "title": "b. Creation of new group" } [/block] 1. Click on ‘Add Group’ button . 2. Select a key, add rules. 3. Use ‘AND-OR Toggle’ for group to switch between logical operators OR & AND. 4. Use ‘Delete Group’ button to delete the group. 5. Multiple groups can be added for an expression. [block:image] { "images": [ { "image": [ "https://files.readme.io/d6e6e50-Screen_Shot_2018-01-07_at_12.56.01.png", "Screen Shot 2018-01-07 at 12.56.01.png", 1790, 996, "#f4f4f4" ] } ] } [/block] [block:api-header] { "title": "c. Creation of new expression" } [/block] 1. Click on ‘+Expression’ button. 2. Add groups and rules. 3. Use ‘AND-OR Toggle’ for expression to switch between logical operators OR & AND. 4. Deleting the last group deletes the expression. 5. Multiple expressions can be added. [block:image] { "images": [ { "image": [ "https://files.readme.io/79c8ec3-Screen_Shot_2018-01-07_at_13.43.44.png", "Screen Shot 2018-01-07 at 13.43.44.png", 1832, 1208, "#f3f3f3" ] } ] } [/block] [block:api-header] { "title": "d. Creation of Segment KV expression" } [/block] 1. Select Segment from the keys dropdown. 2. Click on Add Rule button. 3. All the live segments will be displayed in the dropdown. 4. Select the segments and create expression. [block:image] { "images": [ { "image": [ "https://files.readme.io/cbcb06d-Screen_Shot_2018-01-09_at_18.22.46.png", "Screen Shot 2018-01-09 at 18.22.46.png", 1972, 746, "#f5f5f5" ] } ] } [/block] [block:api-header] { "title": "Expression Summary" } [/block] Shows the KV expression in user friendly terms. [block:api-header] { "title": "Raw Expression" } [/block] Shows the KV expression saved internally in the db. For example for the raw expression **day=monday&day!=tuesday**, Below API calls will serve ads, **ck_day=monday ck_day=monday&ck_day=thursday** [block:api-header] { "title": "Logic" } [/block] * All live keys will be displayed in the dropdown. * If the key is paused after the expression is created, the key will removed from KV expression on ‘Save’. * Expressions without parentheses will be evaluated from Left to Right. * Adding KV expression with characters other than regex [A-Za-z_0-9-]+ from backend, won’t load the campaign on UI. * We don’t support key with duplicate values in it. * Open (non-parenthesized) rules can't be joined with parenthesized expressions. * Maximum KV expression size is 255. [block:api-header] { "title": "Examples" } [/block] **Evaluation of KV expression** **Expression : a=1|b=2&c=3** Method A : Left-to-Right Evaluation of the above expression will be done from left to right. I.e a=1|b=2 will be evaluated first and the result will be evaluated against c=3. e1= a=1|b=2 e2= c3 Method B : Precedence enforced with parentheses Suppose we need b=2&c=3 evaluated as an expression,then parentheses needs to be added Modified expression :(a=1)|(b=2&c=3) For the above expression, e1=(a=1) e2=(b=2&c=3) **Building an expression with parentheses** **Expression : (b=1|b=2)&(c!=3)** * Select ‘b’ key from the dropdown. * Click on ‘Add Rule’ button. Enter value of b as 1. * Add another rule, with value as 2. * Add a new expression. * From the dropdown, select ‘c’ key. * Enter the value as 3. * Use the Equality toggle to switch to IS NOT. [block:image] { "images": [ { "image": [ "https://files.readme.io/34a2854-Screen_Shot_2018-01-09_at_18.30.37.png", "Screen Shot 2018-01-09 at 18.30.37.png", 1920, 994, "#f6f6f6" ] } ] } [/block] **Invalid expressions** * a=1&a!=1 * a=1&(a=2|a!=1) * a=1&b=2|(c=3|d=4) * &(a=1)&(c=2)