Substituting Email Blocks According to Contact Profile Data
The Velocity code allows you to create an email with content depending on the data in the contact's profile, e.g., gender. Men will see a selection of products for men, women — for women, and those contacts whose gender is not specified — a common product selection.
Setting Up Dynamic Blocks
- Place three structures with content for different segments in the template: women's clothing, men's clothing, and a common product selection.
- Select the structure with women's products and open its code editor.
- Add a conditional statement to the code. Use the following format:
!--#if($!parameterName == 'value1')-->In our case, the operator will be like this:
<!--#if($!personal.gender == 'F')-->
- Select the structure with men's products. You will see the structure’s code in the editor.
- Add a conditional statement to the code above the
trtag. Use the following format:
<!--##elseif($!parameterName == 'value2')-->In our case, the operator will be like this:
<!--#elseif($!personal.gender == 'M')-->
- Select the structure with the common products.
- Add a conditional statement to the code above the
trtag. Use the following format:
<!--#else-->
- Add an
endstatement after thetrtag that closes the structure.
<!--#end-->
You can make a more complex check in case the fields have different cases: M or m, F and f:
#if($!personal.gender == 'm' || $!personal.gender == 'M')You can also use such option:
#if('m'.equalsIgnoreCase($!personal.gender))Similar articles:
Updated about 21 hours ago
