TABLE OF CONTENTS


What is Liquid?

Liquid is a template language that enables you to manipulate variables in your contact files using conditional logic. You can use Liquid in both your initial scripts and response scripts, whether you're working on the Global Response Scripts page or within a specific campaign.


To ensure your template is working as expected, you can preview it in the Message Preview section. This allows you to see how your template looks with actual values, ensuring that your fallback values (such as displaying "Friend" if the first name is blank) are set up correctly as you're building your scripts.


Fallback First Name


Round Up


It's essential to consider data formatting when using Liquid templates. If a template relies on specific formatting, like numbers or text, and the data doesn't match, it might fail to render correctly. For example, attempting to compare a first name to a number (if first_name > 5)  would lead to a rendering failure.


If your entire campaign is experiencing rendering issues, it will automatically pause, and you'll be notified on the Campaign Results page. If only certain contacts encounter problems due to mismatching data, you'll find details under the Initial Status section on the campaign results page. They’ll be marked as “Script Rendering Failed”.



Examples of Liquid Templates

Fallback First Name:

  • If the first name is blank, display a fallback value

  • {% if first_name %}{{ first_name }}{% else %}Fallback{% endif %}


Max/Min Donation Asks:

  • If the donation amount exceeds or falls below a certain threshold, display a fallback value

  • {% if donation_ask > Max %}Fallback{% else %}{{ donation_ask }}{% endif %}

  • {% if donation_ask < Min %}Fallback{% else %}{{ donation_ask }}{% endif %}


$0 or Null Donation Ask:

  • If the donation amount is 0 or blank, display a fallback value

  • {% if donation_ask == 0 or donation_ask == null %}Fallback{% else %}{{ donation_ask }}{% endif %}



Max + Min Donation Ask (accounting for $0 or Null):

  • Consider various conditions such as donation being $0, null, exceeding Max, or falling below Min

  • {% if donation_ask == 0 or donation_ask == null or donation_ask > Max or donation_ask < Min %}Fallback{% else %}{{ donation_ask }}{% endif %}


Rounding:

  • Round the donation amount to the nearest whole number

  • {{ donation_ask | round }}



Liquid Template Generator

We also have a Liquid Template generator you can use to help you draft scripts with fallback first names and donation ask conditions. Here are the steps to use it:


  1. Make a copy of this sheet.

  2. Add your script to cell B10. 

    1. Important Note: The sheet will automatically look for and replace ‘first_name’ and/or ‘donation_ask’ placeholders. For example - “Hi first_name, this is Mariah with STW. Can you chip in donation_ask?”

  3. Determine whether or not you want to add a fallback first name, so if the ‘first_name’ cell is blank in your contact list, a fallback word will be used in the script. (For example, if ‘first_name’ is blank, return ‘Friend’). Check the box in C2, and add your preferred fallback name in F2.

  4. Determine whether to set conditions on the donation ask. (For example, if ‘donation_ask’ is under/over/null, return ‘$50’). Check the box in C3, and input your preferred ‘donation_ask’ minimum, maximum, and fallback amount in cells F3:F5.

    1. If you want to round your ‘donation_ask’ to the nearest whole number, mark the checkbox in C4.

  5. Click “Generate”, then copy and paste the result into your initial script editor.