Expression Targets

Expression targets allow you to create sophisticated targets once and use them repeatedly in different campaigns, experiences, and so on. In an expression target, you can also use multiple OR and AND conditions that are not allowed in the standard targeting interface.

For advanced users, these custom targeting groups permit targeting based on flexible JavaScript expressions evaluating to a boolean value. You can select this target in the targeting interface for the campaign, from the Target Library category. If the user matches the target (the target evaluates to "true"), the targeting condition is met. If the target evaluates to "false," the targeting condition is not met. You can also combine an expression target with other targeting options in the targeting interface. (Refer to the JavaScript Expression cheat sheet.)

For best practices, see Script Profile Attributes.

To create your own reusable expressions in targeting groups:

  1. To create a target group, click Segments > Expression Targets, then click Add Expression Target.
  2. Enter any one-line JavaScript expression that evaluates to a boolean true or false value, essentially anything inside an if ().

    Example: Suppose we wanted to target customers on Saturdays and Sundays in order to offer them promotions only available on weekends.

    return (new Date()).getDay() == 0 || (new Date()).getDay() == 6;


    Saturday OR Sunday (In server time, 0 is Sunday and 6 is Saturday.)

    You can now use your target in campaign and experience population selection, in segments, or in success metrics.