Solved

Web feed with different personalized products per profile

  • 2 September 2021
  • 7 replies
  • 48 views

Badge

Hello.

I’m looking to send personalized products recommendations to subscribers using dynamic blocs.

The product recommendations will be a JSON feed from another system.

I was wondering if I could use a web feed with products per profile. Is there a specific structure that I should follow ?

Or maybe there’s another way to import individual recommendations into a customer profile ?

 

Thanks !

icon

Best answer by Dov 3 September 2021, 20:54

View original

7 replies

Userlevel 6
Badge +5

Hello @jocallier,

Thanks for reaching out to the community. We are glad to have you here!

Web feeds are great for displaying data dynamically, however they will not be able to target based on personalized recommendations. In order to target individual’s based on personalized recommendations, I recommend either using product feeds or sending Klaviyo the JSON as a custom event, using the Track API (more details on the Track API here). You would then trigger a flow off of this custom event. The content of the flow email could then be personalized based on the event variables in the track event. It is completely up to you what data you’d like to include in the event. I recommend reviewing our guide on using event variables to personalize flows for more detail on how to populate personalized dynamic data for each recipient in your flow email(s).

Alternatively, you can use the Identify API which will populate information on the user profiles as custom properties. You would then use personalization variables to dynamically pull in these custom properties in your emails. The advantage of using the Identify API is that this dynamic data can be used in both flows and campaigns. Dynamic data from track events can only be pulled into flows.

I am also attaching a thread below with a use-case on using the Track API:

I hope that is helpful.

Badge

Thaky you @Dov for your answer.

It does help a lot.

 

I have done a quick proof of concept using custom properties as I plan to use this data for both campaigns and flows.

I used one custom property in which I pushed directly the HTML and used personalization variables with ‘autoescape off’ directive to display this code in the email and i works perfectly.

However, I’m wondering if pushing HTML code directly in a custom property is the best way to display this personalized content ? I might have 3 to 5 different products for each customers. Should I create properties like ‘product_perso_url_1’, ‘product_perso_image_url_1’, ‘product_perso_title_1’, ‘product_perso_url_2’, ‘product_perso_image_url_2’, etc ?

Or is there a way to create some sort of array or JSON structure within a single property and then loop in this structure in the template ?

 

What would be your advice here ?

 

Thanks again !

Userlevel 6
Badge +5

Thanks @jocallier!

So glad to hear that using custom properties has been helpful for you.

The easiest solution is to use discrete custom properties +values for each of these fields and then use standard personalization variables to dynamically pull in these custom properties in your emails. For example, {{ person|lookup:'Favorite Color' }}.

Alternatively, if you organize these in an array of values within the property i.e. Favorite Color [“Blue”, “Red”, “Orange”] you can target individual values within the array using {{ person|lookup:'Favorite Color'|lookup:'color name' }}In that example, the 'color name' would be replaced with what the array item is labeled i.e. “Red”. If you wanted to pull the first value in the array you could use  {{ person|lookup:'Favorite Color'|lookup:'0' }}. 0 being the first value in the array, in this case the color Blue. The second value in the array would be 1, the third value in the array would be 2 etc.

Hope that helps!

 

Badge

Thanks @Dov !

 

In the meantime, I think I figured out a solution that works pretty well for me.

Let me know if you think there’s something wrong or something that can be optimized.

First I use an array of arrays in a custom property, so for example 

myProductList = [["ProductName 1","https://domain.com/link/to/product1/","https://domain.com/link/to/product1_image.jpg"],["ProductName 2","https://domain.com/link/to/product2/","https://domain.com/link/to/product2_image.jpg"],["ProductName 3","https://domain.com/link/to/product3/","https://domain.com/link/to/product3_image.jpg"]]

 

This array is updated through the Identify API from an external system.

 

Then in my template, I use this loop :

 

{% with recos=person|lookup:'myProductList' %}
<table>{% for value in recos %}
    <tbody>
        <tr>
            <td style="width:160px;padding:3px;border-bottom:1px solid #0f0f0f;"><a border="0" href="{{ value.1 }}" target="_blank"><img src="{{ value.2 }}" width="150" /></a></td>
            <td style="width:260px;padding:3px;border-bottom:1px solid #0f0f0f">
            <h3><a border="0" href="{{ value.1 }}" target="_blank">{{ value.0 }}</a></h3>
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% endwith %}

 

So the important thing to do is to keep the name, url and image link of the product always in the same order in the array, so that I can access them using value.0, value.1, value.2

 

It worked pretty well so far.

 

Thanks!

Userlevel 6
Badge +5

Hi @jocallier,

Thanks for sharing this. Looks really good! Yes, I think this will work fine as long as you keep the order of items the same.

Thanks for being a member of our community.

Badge

Hi @Dov 

It seems I’ve spoken a little too fast.

The solution I described works perfectly as long as you update the data in the custom property manually from the interface.

So, for example, I go in my profile page in Klaviyo and add or update a custom property in an list format such as ‘[“element1”,”element2”] or event [[“element_1_1”,”element_1_2”],[“element_2_1”,”element_2_2”]]

The system will automatically detect it’s a list and will treat the property as such. Therefore, in this case, the code provided in my previous post works.

However, when the property is updated through the API, the system treats it as a normal string of text and does not recognize the fact list format.

Is there a way to force the system to consider the custom property as a list ?

 

Thanks

Userlevel 6
Badge +5

Hello @jocallier,

Thanks for the updated note!

Check out the solution outlined in this thread!

In short, in order to update or add an array/list property to a profile you need to pass the query parameter and value for each item in the list e.g.

?newKey=cat&newKey=dog

This will then be reflected on the profile as

Or you can add it like the following format described here:

 

Reply