Show Menu
TOPICS×

Sample Expressions With Boolean and Comparison Operators

Examples you can refer to for creating expressions in the Expression Builder code editor.

Code Samples Overview

Create your own trait rules with the Expression Builder code editor. The following examples can help you get started. Some of the examples preface the key variable with c_ to identify it as a user-defined variable. Include the c_ prefix (or any other naming convention) for key variable if your event calls send data to Audience Manager using that syntax.

Boolean Expressions

AND Example

The rule establishes trait qualification requirements using Boolean AND operators.
Sample Code To qualify, a visitor must
(c_make=="A") AND (c_model=="B") AND (c_search=="1")
  • Look for a specific make and model.
  • Find the product from a search results page (search = "1" or "true").

OR Example

This rule establishes trait qualification requirements using Boolean OR and AND operators.
Sample code To qualify, a visitor must
(a== "1" OR b=="1") AND (c=="new") Meet the conditions set by variables a or b and c .

Range Example with Greater Than, Less Than, Equal To

This rule establishes trait qualification requirements using a range.
Sample code To qualify, a visitor must
(price >= 1.00 AND price <= 100.00) Meet any price condition between 1.00 and 100.00.