Solved

Help creating a Liquid link from a merge tag

  • 24 June 2023
  • 5 replies
  • 103 views

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 %}

icon

Best answer by Felix 24 June 2023, 09:11

View original

5 replies

Userlevel 4

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 %}

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 %}

Userlevel 4

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 😉 

 

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!

Userlevel 4

Hey Gravy,

glad that helped!

 

Best,
Felix

Reply