Checking common syntax errors for liquid templating

  • 20 November 2019
  • 0 replies
Checking common syntax errors for liquid templating
Userlevel 6
Badge +4

Every week, we will release tips to help you get the most out of Mixpanel. Want to see more? Click here to see other #mpknowledgedrop articles!


So now you have read our Liquid Templating help article and even learned some more liquid templating from our community post. Now to complete your mastery Liquid Templating training, we want to arm you with some knowledge on common syntax errors that can happen.

Here are some common issues that could cause errors in your liquid message.


Gmail replaces regular double quotes with open (“) and close (”) double quotes. When typing your message in Mixpanel, Liquid does not recognize these quotes and can throw errors. To avoid errors, ideally use single quotes instead of double quotes in all liquid messages.


HTML inserts characters

Sometimes when inserting liquid formatting into the text, the text to HTML may create special characters such as “&nbsp” or </p> within the liquid text template. To avoid errors, examine the HTML to make sure that the special characters are being rendered correctly in the HTML, not inside your liquid call.


{{user[‘$prop_name’]}}will work

{{user[<p>‘$prop_name’<p>]}} will not work because the html falls within the liquid syntax


Stick to Mixpanel’s dynamic content syntax OR Liquid templating syntax but don’t use both together

You should not combine regular Dynamic Content syntax with liquid templating syntax in the same message.

If you see a variable that looks like this: {{$prop_name}} and one that looks like this: {{user[‘$prop_name’]}} in the same message, you are gonna run into issues.

To avoid errors, make sure you do not use them together, choose one and stick to it.



Liquid doesn’t work well with whitespaces especially in assign statements.

For example:

{% assign temp_price = {}}} %} will work.

{% assign temp_price = {{ item.price | multiply: {}}} %} will not work, because it has a space before the item.price within the curly brackets.

To avoid this error, make sure you do not include white spaces within your liquid templating.


Push messages

When using push messages, use single quotes in the JSON payload for Liquid templating to avoid JSON syntax issues.

For example:

{"mp_message": "{% if user [‘language’] == ‘French’ %} bonjour {% endif %}" will work because the values within the curly brackets {}, is using single quotes for liquid templating.

{"mp_message": "{% if user [“language”] == “French” %} bonjour {% endif %}" would not work because it uses double quotes for values inside curly brackets { }, which needs to be in single quotes for liquid templating.


Hope these troubleshooting tips help when write your Liquid messages! Have you run into any other errors and found a quick solution? Please share them here for everyone to learn from them!


0 replies

Be the first to reply!