Solved

How to create a snippet that sends a white-labeled email with dynamic image URL based on customer attributes?

  • 13 March 2023
  • 4 replies
  • 273 views

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.

icon

Best answer by Felix 15 March 2023, 08:35

View original

4 replies

Userlevel 4

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.

Userlevel 4

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

Userlevel 2
Badge

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!

Reply