Solved

How to target an event variable in an email template

  • 16 February 2021
  • 2 replies
  • 684 views

Badge +2

Hi All,

We operate a custom product business with over 10^18 possible SKUs. We’re on Shopify but don’t use Shopify products due to SKU limitations. When building confirmation emails in Klaviyo we’re struggling to pull line item properties as they may be in a different order based on the type of product ordered.

 

If we used Shopify products, we could pull the value for the field “_image” like this:

{{item.product.properties|lookup:'_image'}}

 

instead this _image value may be in position 14, 20, or 25 like this:

{{ event.extra.line_items.0.properties.25.value }}

 

Is there a way to query all event.extra.line_items and only return the value if it matches a specific name?

 

 

 

 

 

 

icon

Best answer by David To 11 May 2021, 21:52

View original

2 replies

Badge +2

As a follow up, this is what I’d normally use if Klavyo supported “assign”:

 

{% assign lip_image event.properties | where: 'name', 'lip_image' | first %} 
Your Image: {{ lip_image.value }}

Userlevel 7
Badge +60

Hello @newuser,

Thanks for sharing your question with the Community!

Similar to Shopify, you can query all the values in the event.extra.line_items to allow it to return a specific name if a specific value was matched. You can typically do this with an “if” statement or your choice of a conditional statement within the templates. 

For example: {% if “EXAMPLE” in event.extra.line_items %}<img src="{{ event.item.product.variant.images.0.src }}>(% endif %} 

This statement would be looking into this event.extra.line_items variable and return the image provided in the event.item.product.variant.images.0.src field. You can learn more about using conditional statements within Klaviyo from the following articles:

If you need further help building out your emails and creating these custom conditional statements, feel free to checkout out our extensive network of agency partners.

-David

Reply