Forum Discussion

elena14's avatar
elena14
Practitioner
6 months ago

Personalization with Liquid using purchase events on order level

Hello, I am trying to personalize an email based on purchase event on order level.

Here it says that event properties schema could not be generated for purchase events, but that the nested data is supported by purchase events. Is nested objects even supported for purchase events on order level?

This is the event that I am using:

 

 

{
    "purchases": [
        {
            "external_id": "2023_new",
            "product_id": "Completed Order",
            "currency": "USD",
            "price": 219.98,
            "properties": {
                "products": [
                    {
                        "name": "Monitor",
                        "category": "Gaming",
                        "product_amount": 19.99
                    },
                    {
                        "name": "Gaming Keyboard",
                        "category": "Gaming ",
                        "product_amount": 199.99
                    }
                ]
            },
            "time": "2024-06-20T13:59:30+01:00"
        }
    ]
}

 

 

So can you please clarify how can we add liquid tag in order to display the name of the first product - "Monitor"?

Looking forward for your reply!

Many thanks

  • Hi inespais , it finally worked with this piece of code in the email template.

    {{event_properties.${products}[0].name}}
    {{canvas_entry_properties.${products}[0].name}}
  • inespais's avatar
    inespais
    Practitioner II

    HI elena14 - if your JSON event data structure is like the one shown above, you will need to use dot notation to access the nested data. Please try the following and see if it works:

    To display the name of the first product:

    {{purchases[0].properties.products[0].name}}

    To display the name of the second product:

    {{purchases[0].properties.products[1].name}}

     and so on...


    • elena14's avatar
      elena14
      Practitioner

      Hello inespais , 

      I tried your suggestion and unfortunately it is not working. 😐

      Do you know what can be the issue here?

      • inespais's avatar
        inespais
        Practitioner II

        Hey elena14 - are you able to share an example of your JSON event structure? I believe the one above might be taken from Braze's documentation. Even if your's is really similar, a small difference (structure, naming, etc) might be the key here.