Skip to main content
Solved

How to target an event variable in an email template

  • February 16, 2021
  • 2 replies
  • 910 views

Forum|alt.badge.img+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?

 

 

 

 

 

 

Best answer by David To

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

2 replies

Forum|alt.badge.img+2
  • Author
  • Contributor I
  • February 16, 2021

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


David To
Klaviyo Employee
Forum|alt.badge.img+60
  • Klaviyo Employee
  • Answer
  • May 11, 2021

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