Keyword Logic
Overview
Warning
Keyword logical operators only apply to flight-level keywords, at ad-level the default logic uses an OR operator between keywords.
When you write keyword targeting rules in the Kevel UI, or via the API, there is specific business logic you must follow, which is described below.
If you use the Kevel API, you will want to include the string under the 'keyword' field when using the Create Flights endpoint, or the ActiveKeywords
field using the Create Ads endpoint.
If you use the Kevel UI, you will add strings to the Keyword Targeting section.
Note
Operators only work at flight-level keyword targeting (not ad-level).
Keyword Targeting Rules
Keyword targeting is configured by defining one or more keyword targeting rules. A targeting rule is a set of one or more keywords separated by commas. Multiple targeting rules are separated by newlines.
The keywords within a targeting rule are combined with the AND
operator. The set of targeting rules are combined with the OR
operator.
Here is an example of a single targeting rule, targeting the keyword a
:
UI | API |
---|---|
a | a |
And a single rule to target a AND b
:
UI | API |
---|---|
a,b | a,b |
Multiple rules can be used to target alternative keywords. To target a OR b
, for example:
UI | API |
---|---|
a b | a\nb |
More complex targeting rules can be defined, for example to target (a AND b) OR (c AND d)
:
UI | API |
---|---|
a,b c,d | a,b\nc,d |
Exclusive Keyword Targeting Rules
Keyword targeting rules can also be used in an inverse fashion, that is to say rules which must not match. These are exclusive targeting rules, which are defined by adding an exclamation point at the beginning of the line.
For example, a targeting rule can be defined which matches all keywords except the keyword a
:
UI | API |
---|---|
!a | !a |
Aside from the leading exclamation point, exclusive rules have the same syntax as inclusive rules. For example to target NOT (a AND b)
:
UI | API |
---|---|
!a,b | !a,b |
And more complex exclusive targeting, such as NOT ((a AND b) OR (c AND d))
:
UI | API |
---|---|
!a,b !c,d | !a,b\n!c,d |
Combining Inclusive And Exclusive Targeting Rules
When both inclusive and exclusive targeting rules are defined they are combined with the AND
operator.
For example, to target ((a AND b) OR (c AND d)) AND NOT ((e AND f) OR (h AND i))
:
UI | API |
---|---|
a,b c,d !e,f !h,i | a,b\nc,d\n!e,f\n!h,i |
Advanced Keyword Targeting Rules
An individual keyword within a rule can be prefixed with an exclamation point to exclude that keyword in the rule.
For example, to target a AND NOT b AND c
:
UI | API |
---|---|
a,!b,c | a,!b,c |
This operator is also valid in exclusive keyword targeting rules. For example, to target NOT (a AND NOT b AND c)
:
UI | API |
---|---|
!a,!b,c | !a,!b,c |
Note
In the example above the
!
at the beginning of the rule identifies the rule as an exclusive keyword targeting rule, it does not negate the first keyword in the rule,a
. To negate the first keyword in an exclusive targeting rule, add another exclamation point (or simply reorder the keywords in the rule such that a non-negated keyword is first).For example, to target
NOT (NOT a AND NOT b AND c)
:
UI API !!a,!b,c !!a,!b,c
Full Keyword Targeting Rules Example
Targeting ((a AND NOT b) OR (c AND d)) AND NOT ((e AND NOT f) OR (g AND h))
:
UI | API |
---|---|
a,!b c,d !e,!f !g,h | a,!b\nc,d\n!e,!f\n!g,h |
Updated 21 days ago