Visibility rules
Visibility rules allow you to display or hide blocks depending on rules you set using Personalize code strings. You can show or hide content in any code block automatically based on date or quantity or a combination of both! You can apply visibility rules to content source feed blocks or URL parameter feed blocks.
Content source visibility rules
For a template with a connected content source, the following options can be entered in the Visibility condition section above your source selection option.
Content source rule code |
Description |
---|---|
"%%.root.field.fieldname%%".length < 15 |
display image based on character length in data field |
"%%.root.field.fieldname%%".length < 1 |
hide if character length less than 1 |
"%%.root.field.fieldname%%" == "y" |
if data equals 'y' |
'%%.root.field.fieldname%%' != 'y' |
if data does not equal 'y' |
%%.root.field.fieldname%% > 0 |
if greater than 0 |
%%.root.field.fieldname%% < 1 |
if less than 1 |
%%.root.field.fieldname%% <= 10 |
if less than or equal to 10 |
%%.root.field.fieldname%% >= 10 |
if greater than or equal to 10 |
%%.root.field.fieldname%% >= 1 && %%.root.field.fieldname%% <= 10 |
if greater than or equal to 1 AND if less than or equal to 10 |
%%.root.field.fieldname%% == 10 || %%.root.field.fieldname%% == 20 |
if equals 10 OR if equals 20 |
Use multiple visibility rules
You can include more than one visibility rule for a block using the following options:
- && - double ampersands - for AND combinations
- || - double pipes - for OR combinations
Example of multiple rules code:
(%%.rootfield.fieldname%% <= 1 && %%.rootfield.fieldname%% >= 10) || "%%.rootfield.fieldname%%" == "y"
(if content source item is greater than or equal to 1 AND if content source item is less than or equal to 10) OR if content source data equals 'y'
Multiple rules could be used to show products or services to customers within a stock quantity range and availability, or based on a customer loyalty level and point values.
URL visibility rules
For a template using parameters from an ESP or CRM, the following options can be entered in the Visibility condition section above your URL parameter entry.
URL parameter rule code |
Description |
---|---|
'%%url(your-parameter)%%' <= 1 |
URL param length less than or equal to 1 |
'%%url(your-parameter)%%'.length >=9 |
URL param length greater than or equal to 9 |
'%%url(your-parameter)%%'.length <=1 || '%%url(your-parameter)%%'.length >=9 |
URL param length less than or equal to 1 OR URL param length greater than or equal to 9 |
NOTE: URL parameters must match the case and structure of your ESP or CRM field names.
Use multiple visibility rules
You can include more than one visibility rule for a block using the following options:
- && - double ampersands - for AND combinations
- || - double pipes - for OR combinations
Example of multiple rules code for content source:
(%%.rootfield.fieldname%% <= 1 && %%.rootfield.fieldname%% >= 10) || "%%.rootfield.fieldname%%" == "y"
(if content source item is greater than or equal to 1 AND if content source item is less than or equal to 10) OR if content source data equals 'y'
Example of multiple rules code for URL parameter:
'%%url(FirstName)%%'.length >= 4 && '%%url(FirstName)%%'.length <= 9
This code displays the first name from your ESP or CRM when it is between 4 and 9 characters in length.
Multiple rules could be used to show products or services to customers within a stock quantity range and availability, or based on a customer loyalty level and point values, as well as showing their name.