Skip to main content
Solved

Help creating a Liquid link from a merge tag


Hi there,

 

I am crafting an email with merge tags. I think the following Liquid code inserts the URL in the magic_link_june_2023 attribute if it exists for the user and displays “No magic link” otherwise. However, when I preview the email in customer.io’s email builder tool, it always shows “No magic link” even though the attribute exists. 

 

What am I doing wrong?

 

{% if customer.magic_link_june_2023 > 0 %}

{{customer.magic_link_june_2023}}   

{% else %}

No magic link

{% endif %}

Best answer by Felix

Hey Gravy,

try it without “> 0”. If you only use the attribute name without an operator this means “if attribute exists”. That should solve your problem. Otherwise the value has to be a number, which it isn’t:

{% if customer.magic_link_june_2023 %}

{{customer.magic_link_june_2023}}   

{% else %}

No magic link

{% endif %}

View original
Did this topic help you find an answer to your question?

5 replies

Felix
  • Novice
  • 211 replies
  • Answer
  • June 24, 2023

Hey Gravy,

try it without “> 0”. If you only use the attribute name without an operator this means “if attribute exists”. That should solve your problem. Otherwise the value has to be a number, which it isn’t:

{% if customer.magic_link_june_2023 %}

{{customer.magic_link_june_2023}}   

{% else %}

No magic link

{% endif %}


  • Author
  • Novice
  • 2 replies
  • June 24, 2023

Gotcha. I simplified the code below. I sent a test email to a customer with their magic_link_june_2023 attribute set to a URL. However, the blahblahblah content did not show. Why is the if test failing?

 

customer’s attribute

{% if customer.magic_link_june_2023 %}

blahblahblah

{% endif %}


Felix
  • Novice
  • 211 replies
  • June 25, 2023

Hey Gravy,

I am not sure what went wrong with your setup. I recreated your case and it works fine for me. In order to make sure that the code is correct, maybe use “Add Liquid” option.

BTW: You also can preview each customer in the preview tab, no need to send an email 😉 

 


  • Author
  • Novice
  • 2 replies
  • June 25, 2023

Using the ‘Add Liquid’ option helped! I still don’t know what was different in the logic but adding the code via ‘Add Liquid’ did the trick. Thank you so much Felix!


Felix
  • Novice
  • 211 replies
  • June 26, 2023

Hey Gravy,

glad that helped!

 

Best,
Felix


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings