How can we help?

Conditionals and loops overview


Smarty enables you to pull real-time data into messages and render it according to certain rules and filters, unlocking a wide range of possibilities for sending dynamic, personalized content. You can also update portions of your Cordial database using Smarty utilities to save time and establish scalable processes for data maintenance.

For a complete list of available utilities, see the Cordial utilities reference page.


  • {if} statements: renders content based on a condition.
  • {foreach} statements: retrieves data arrays, loops through the items and executes a specified operation which may include printing data for each item in the message.
  • Randomizing content: randomizes what content will show in a message.
  • Calculate distance between postal codes: calculates the distance between two postal codes, which is useful for sorting records by proximity. (Ex: printing the five nearest store locations for each contact.)
  • Sort an array: sorts an array of data according to a key in ascending or descending order.
  • String contains: finds a string of characters within another string.
  • Update contact attribute or list values: updates contact attributes and list values when a message is sent.
  • Send Webhook: pings a URL at the time a message renders (preview or send).
  • Last send timestamp: renders the last send date of a specified automation template.
  • Add send properties: adds key/value pairs to the properties object of any system event related to the message contact ID (open, click, bounce, etc.).



Please sign in to leave a comment.