Solved

Can I pass HTML through an event property in an API call and just use that HTML inside of an email?

  • 1 March 2024
  • 2 replies
  • 37 views

Badge

We are in the process of transitioning over to Klaviyo, and to migrate our transactional emails we want to make an API call that sends an already formatted chunk HTML with all of the order information in it with the API call and then use that chunk of HTML in the email.

 

When I’ve tried testing this out, it just prints all the HTML and treats it as text. I’ve been looking for a solution or a workaround. This is a temporary setup for us, later on in the year we will plan on changing how it’s set up to adhere to best practices for Klaviyo but are in the process of changing our e-commerce store right now so wanted to do this to save time and get transactional emails migrated to Klaviyo.

 

It seems like it should be a pretty straightforward and simple thing to do, something you should be able to do in Klaviyo, but I’m having trouble finding examples of this being done successfully. Are there any official or unofficial solutions to just inserting HTML into an email that’s coming from an event property in an API call?

icon

Best answer by retention 1 March 2024, 22:36

View original

2 replies

Userlevel 7
Badge +58

Hi @kenny.porterfield, welcome to the community!

Depending on how you’re injecting the HTML into an existing Template programmatically, you may be able to use a variable filter safe to let the interpretor know that its HTML safe content.

For example, let’s assume your variable is “content” - so you might want to try this:

{{ content | safe }}

There’s a related discussion here that isn’t exactly what you’re trying to do, but somewhat related that might be helpful.

Not sure if @Walid can clarify more here, but hope this helps and let us know if it works.

 

Badge

Hi @retention, this seems to be the answer I was looking for, now the HTML is rendering. Thanks!

Reply