Skip to main content

How can I fix the code for the "logo_test" snippet in a white-label email service using customer.io?

I'm trying to create a snippet that sends the URL of an image stored in my assets, based on an attribute such as customer.company_name. However, the code I have tried doesn't seem to work. Here is the liquid code I have tried:

{% assign env = "91305" %}
{% assign file_name = "Acme-logo.png" %}

{% capture company_url %}
https://userimg-assets.customeriomail.com/images/client-env-{{ env }}/{{ file_name }}
{% endcapture %}

{% if customer.company_name == 'Acme Inc.' %}
{{ company_url }}
{% else %}
https://default-img-url.com{{ env }}/default-logo
{% endif %}

I'm expecting the link generated by this code to appear as the src of the html tag. Could someone please help me figure out what's wrong with this code and how to fix it? 

The img URL are tested.

Hey Thomas,

I had a look and found out something interesting. I recreated you scenario and built up one for myself. After sending an test emailing and inspecting the HTML, I found out that CIO is adding the region you have chosen (EU or US) to the subdomain. So the final image url is different from the one in the asset library.

I had to add “-eu” in the liquid code as shown in the screenshot. After doing that it worked!

 

Hope that helps,

Felix


Thank you for your interest in my question.

 

May I provide some clarification? The objective is to dynamically send the URL generated above to the built-in image component. However, upon attempting to do so in preview mode, the console indicates that the <img> element has no URL, as shown below.

If I remove the necessary logic and instead include a static image URL from my assets in the snippet, the image displays properly.


Hey Thomas,

got ya! I checked again with the dynamic image feature and a snippet and it doesn’t show the image for me neiter:

 

But: I sent myself a test email and that worked!

 

Seems like you found a bug 😋 @Customer.io 

 

Since it gets sent out correctly it seems like it is only the preview, though. Maybe you can set up a live campaign and only select yourself as recipient to make sure it is only a bug in the preview mode.

 

Hope that helps,

Felix


Popping in to say that Felix is exactly right and we’ve already logged this issue with our team. Thanks for bringing it to our attention!


Hello!  Has this bug been fixed yet?  I am experiencing exactly the same issue.

  1. I created a snippet that checks a customer attribute to get the correct image.
{% if customer.first_name == "Anna" %}
https://userimg-assets.customeriomail.com/images/client-env-XXXXX/XXXXX1.png
{% else %}
https://userimg-assets.customeriomail.com/images/client-env-XXXXX/XXXXX2.png
{% endif %}
  1. I added this snippet as a dynamic url in my email message
  2. I go to preview mode and the image is not rendered properly
  3. If I remove the if statement in my snippet code and just use a straight url, the image is rendered correctly.

 

I have not tried sending out an email yet though.

Please advise.  Thanks so much!


Reply