Hi @jhorngacher, welcome to the community!
If I understand you correctly, you want to get the content of the Universal Block, and inject it into an existing template programmatically.
I haven’t done this myself, but I think you can build a “hybrid template” which is a mixture of HTML and editable items, and reference a Universal Block’s ID with this snippet of code in your HTML:
<td data-klaviyo-region="true" data-klaviyo-region-width-pixels="600"> <div data-klaviyo-universal-block="block_id_1"> <div></td>
Where “block_id_1” is the ID of the universal block that you stored earlier.
Here’s some documentation of the “hybrid templates” that might be helpful:
Now note, this documentation assumes you’re building the HTML template manually as a “HTML Template” by copying/pasting in the HTML code. You would do this programmatically instead - but I haven’t verified if this works. Let us know!
Hi @retention , thanks for your answer about my question!
I have stumbled upon this documentation already and it’s not really helpful at all. If I like integrate this HTML-Code in a HTML-Block it doesn’t do anything. So not loading any Content at all into my mailing template.
To figure this out, heres what I do exactly:
→ I create the universal content via api
→ I created a template which should include this universal content created. My idea now is to store a dynamic property on a customers profile which includes the references ( ids ) from the universal_content which should be loaded inside the mail template and then send it.
With the given solution this is not working. Is there anything else or do I just have to like go the non-prefered way of storing HTML-Code inside a customers property?
Now I finally understood that you can create plain-html templates. Further to this I am now trying to set the dynamic property ( stored as a list ) and load the block with the id, for some reason klaviyo always states that the universal content doesn’t exist. Here’s my example code:
{% for item in person.ppi_reference %}
<td data-klaviyo-region="true" data-klaviyo-region-width-pixels="600">
<div data-klaviyo-universal-block="{{ item }}">
</div>
</td>
{% endfor %}
If I like set the blockId fixed the universalcontent is loaded without any errors, both have the same id!
I found the issue. I gotta have to reverse the logic on how to show the klavio-universal-block. Since dynamic setting of the id is not working, I am just gonna set the universal content as a fixed div and check if the id is in a profile’s reference. Here’s some example code:
{% if 'universalcontentid' in person.reference %}
<td data-klaviyo-region="true" data-klaviyo-region-width-pixels="600">
<div data-klaviyo-universal-block="universalcontentid">
</div>
</td>
{% endif %}