Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Liquid Script is an open source scripting language that can be used to personalize content in an email. You can use any data point within Blueshift to conditionally hide, show, or modify content in an email allowing you to create campaigns that dynamically adapt to the customer.

Info

For more information beyond the basics covered here, visit the Liquid Script External Wiki.

Topics

Table of Contents
maxLevel3
minLevel2
indent20px
stylenone

Personalization

Date

Code Block
languagexmlfirstline1
{{ "now"| date: "%m/%d/%Y" }} 

Note: For additional options visit http://strftime.net/ 

Default

Code Block
languagexml
firstline1
{{ Object | default: "My Default" }} 

First, Last, & Email

Code Block
languagexml
firstline1
{{ user.firstname }}
{{ user.lastname }}
{{ user.email }}

User Transactions (Advantage Data Objects)

Code Block
languagexml
firstline1
{{ user_transaction.object }}

Note: For a list of available advantage data objects, please see the Data Object Map.

Whitespace Control

Code Block
firstline
languagexml1
<!--If Liquid Script is causing formatting issues, try using the minus sign (-) inside your tags-->
{%- some liquid script -%} 

Assigning a Value to a Variable

Code Block
languagexmlfirstline1
{%  assign  my_variable =  "some value" %} 
<p>This is {{ my_variable }}</p> 

Output:  
This is some value

Template and Shared Asset Logic

The following markup examples are shown using the list_code data object mapped from Advantage to Blueshift. You can use any data object available to create dynamic content within a template. You can also use values assigned to variables within other liquid script markup. Liquid script values can be passed between templates and shared assets in both directions. You can also pass values from one shared asset to another as long as both are used within the same template.

Note: When using transaction data in your logic, the list, publication, or product you have starred in your advanced segment will be referenced. For more information, please see Creating Advanced Segments

Using IF Statements

Code Block
languagexml
firstline1
{% if user_transaction.list_code == "ABC" %} 
  Show ABC content 
{% elsif user_transaction.list_code == "XYZ" %} 
  Show XYZ content 
{% else %} 
  Show default content or warning 
{% endif %} 

Using SWITCH Statements

Code Block
languagexml
firstline1
{% case user_transaction.list_code %}
	{% when "ABC" %}
		Show ABC content
	{% when "123" or "XYZ" %}
		Show 123/XYZ content
{% endcase %}

Using CAPTURE Statements

Code Block
languagexmlfirstline1
{% capature introduction %}Hi {{ user.firstname }},<br /> Thank you for subscribing. <b>To login, visit our <a href="https://westora.io">website</a>.</b>{% endcapture %}
{{ introduction }}

Output:  
Hi Jane,
Thank you for subscribing. To login, visit our website.