Solved

Issue with Dynamic Logo Display in Email Template based on customer attribute

  • 15 March 2023
  • 2 replies
  • 89 views

Hello,

I am attempting to dynamically display a logo based on the "customer.first_name" attribute. To achieve this, I am using the obtained URL and referencing it in the dynamic url field within an image in the Create Password email template. Please note that the "tenants_logo_file_name" variable must be declared on the same line for the snippet to work correctly. However, if this cannot be resolved, it is not a critical issue.

error message: Variable 'Liquid::VariableNotFound'

Here is the code that I am currently using to display the proper logo based on the "customer.first_name" attribute:

{% assign tenants_logo_file_name = [{ "first_name": "Mathis", "logoFileName":"1678708227624_rainbow-flower_01GVDCXEPX7MHQHX2SF7GDR0D4.png" }, { "first_name": "Timon","logoFileName":"1678907118448_atom.png_01GVKAK3ZCCCYAVXBCBE8NRC5H.png" }, { "first_name": "default", "logoFileName":"1678907291974_logo-medzy_01GVKARDDV8S1WZTZJ6GD5F9P.jpg"}] %}

{% for logo in tenants_logo_file_name %}
{% if logo.first_name == customer.first_name %}
{% capture tenant_logo_url %}
https://userimg-assets.customeriomail.com/images/client-env-91305/{{logo.logoFileName}}
{% endcapture %}
{% else %}
{% capture tenant_logo_url %}
https://userimg-assets.customeriomail.com/images/client-env-91305/1678907291974_logo-medzy_01GVKARDDV8S1WZTZJ6GD5F9PR.jpg
{% endcapture %}
{% endif %}
{% endfor %}

{{ tenant_logo_url }}

Thank you.

icon

Best answer by Felix 17 March 2023, 06:06

View original

2 replies

Userlevel 4

Hey Thomas,

I think you can store JSON in a variable, but it will be stored as a string, so it isn’t possible here to reference to the variable “first_name” in the for loop. Please see a similar problem here in Shopify and a workaround here in Stackoverflow.

 

In order to understand your setup: You are trying to personalize a “forgot password” email with the tenants picture, correct? If so you are sending an event to CIO in order to trigger the email? I am asking because I am trying to understand why there would be more than one tenant name and image file name in the JSON. If there is only one, it would be way easier 🙂

 

Best,

Felix

Userlevel 2
Badge

Hi Thomas! One thing I’m noticing looking at your code, is that Liquid parameters are being used that aren’t supported within Customer.io. For a list of supported parameters within Customer.io, use this resource as a reference: 
https://customer.io/docs/liquid-tag-list/

An easier approach for now may be to save the image urls as a profile attribute, then reference that {{customer.attribute}} within an image block. Or send those images via an event, then reference the urls within an event triggered campaign. 

Reply