Condition elements
Before you start, make sure to familiarize yourself with the types of parameters and context parameters for conditions, as well as unsupported JavaScript functions. Use the following structure to declare variables in conditions:
let nameParam = `[[parametername | type | value1 | {config1: value1, config2: value2 } ]]`;
The following table contains descriptions of condition elements that you can use.
Element |
Description |
Required |
---|---|---|
|
The name of the field that the marketer sees when they add a condition. Example: Cart transaction. |
Yes |
|
The type of input that the marketer enters when using the condition. Options: string, text, number, enum. |
Yes |
|
The default value for the parameter input. |
Optional, but necessary if you want to add variables that the marketer can select from. |
|
A JSON configuration object that contains name/value pairs, in relation to the |
Optional |
|
A placeholder text that appears in the input box, helping marketers understand the type of input that is expected here. |
Optional |
This condition identifies site visitors by their type: whether new or returning. It does this by checking for an existing closed web session for the visitor. If the session exists, the visitor is classified as "returning"
. If the session does not exist, the visitor is considered new. The userType
parameter enables marketers to choose whether the visitor must be new or returning to pass the condition.
(function () {
var userType = "[[type | enum(new, returning) | | { required: true, placeholder: type }]]";
var expectedType = "WEB";
var expectedStatus = "CLOSED";
var isReturning = false;
if (guest && guest.sessions && guest.sessions.length > 0) {
for (var index = 0; index < guest.sessions.length; index++) {
if (
guest.sessions[index] &&
expectedType === guest.sessions[index].sessionType &&
expectedStatus === guest.sessions[index].status
) {
isReturning = true;
break;
}
}
}
if (isReturning && userType === "returning") {
return true;
} else if (!isReturning && userType === "new") {
return true;
} else {
return false;
}
})();