Skip to main content
Contributor IV
February 21, 2024
Solved

Segmentation based on metadata

  • February 21, 2024
  • 18 replies
  • 473 views

Hi there

We want to help one of our clients be able to segment customers based off their booking period, rather than just their placed order date.

The company is renting items to private consumers, and we want to be able to send automated mails to the customers based on their pick-up and return dates - not just what date they placed the order.

However, currently this information is stored in the metadata, and therefore we can’t segment based on that data. Klaviyo Support says that we need to move the data “higher”, so we can see it in our property overview. However, they can’t be specific about WHERE we need to move the data, in order to be able to use it when segmenting it. 

Can anyone help exactly where in JSON this info needs to be present in order to qualify as “primary” data, so we can see it as a property just like we can with category, item name etc.

Any help would be much appreciated - thanks in advance!

Best regards
Mads

    This topic has been closed for replies.
    Best answer by KeviSunshine

    Hey Mads,

    Ah, I think I understand the issue now.

    You’re using a built-in WooCommerce <-> Klaviyo integration that (I’m assuming) automatically picks up the product’s metadata from the cart and supplies the “Metadata” field on the “Order” event. You cannot simply add metadata to the top-level event properties.

    I’ve never used this integration so I am at a loss now. However, I think I understand the problem and can format the question in a way that someone from the Klaviyo community might be able to better respond to…

    @carleygilmore – can you or someone on the Klaviyo team let us know if it’s possible to include woocommerce product metadata in the top-level fields of the “Placed Order” event? Does this data only go into the Metadata field?

    18 replies

    KeviSunshine
    Expert Problem Solver III
    Expert Problem Solver III
    February 21, 2024

    Hi Mads,

    Is the “metadata” currently stored on the user’s profile, or in klaviyo events? Can you explain the “metadata” more? I am not sure what this means in Klaviyo.

    I think the “higher” comment from Klaviyo means the profile/event properties need to be “top-level” properties. Does this make more sense?

    Klaviyo doesn’t totally support nested object fields on profiles (or events, I think) for the purposes of segments.

     

    Let me know.

    Kevin.

    Contributor IV
    February 21, 2024

    Hi Kevin

    I have attached some screenshots, where I have highlighted the data marked as “metadata” in Klaviyo.
    The data is clearly sent to Klaviyo - but just nested, so we can’t make segments based off it. 
    I understand the “higher” comment the same way as you, that the specific data needs to be “moved up”

    What I’m trying to find out is, where in the JSON should “booking_start_date” and “booking_end_date” be placed, in order to be seen as a “top-level” property, when put into Klaviyo :-)



    Best regards
    Mads

    KeviSunshine
    Expert Problem Solver III
    Expert Problem Solver III
    February 21, 2024

    Hey Mads,

    Can you move the `booking_start_date` (and end_date) to be at the same hierarchical level as `Metadata`?

    If you do that, you can create segments based on “What someone has done” (in your instance, the “Ordered Sne...” event) with filters for the profile properties.

     

    If you try to do this now, you should see “Metadata” as an option in your segment, but you won’t be able to “drill down” into any subproperties.

     

    If it helps your understanding, try making a segment based on the Metadata property of the “Ordered” action. You can hack Klaviyo’s segment builder by doing something like “where Metadata contains booking_start_date: value: 2024-01-01” (or something like that, treating the nested object as a serialized string). This won’t work for your use case, but it might help you understand how Klaviyo handles sub-objects.

     

    Best,

    Kevin.

    Contributor IV
    February 22, 2024

    Hi Kevin

    “Can you move the `booking_start_date` (and end_date) to be at the same hierarchical level as `Metadata`?” - that is exactly what I’m trying to achieve.

    However, we are not sure how to do that from a technical standpoint. Klaviyo support suggested that it can be done, but can’t advise on how to do it. That’s what we need help with :-)

    Best regards
    Mads

    KeviSunshine
    Expert Problem Solver III
    Expert Problem Solver III
    February 22, 2024

    Ah, my apologies Mads, I understand now.

    I don’t believe you can update a prior event’s properties. Would you have a path forward if you could store the booking dates directly on a profile? Or would you be able to call your “order” event a second time?

    Since you can’t update a past event, I am trying to figure out how to make this work for your current workflow and future workflow. We’d have to update the “Order” event to save the booking dates to the profile (for any future orders), and then also backfill current profiles who have already placed orders.

     

    With a custom script using Klaviyo’s API, you could certainly fetch all instances of this event and backfill current profiles that have already placed orders.

     

    Let me know if I’m making sense and what approach you want to go with.

     

    Best,

    Kevin.

    Contributor IV
    February 22, 2024

    Hi Kevin

    With all due respect, it’s not making a lot of sense - but I think that’s because of my technical shortcomings and not your explaining skills :-)

    We have a developer employed with the website, who “just” needs to know where in the JSON, he needs to place the booking dates, in order for it to be perceived as “primary” data in Klaviyo.

    Backfilling previous orders is second priority, right now we “simply” want to make it work for new orders coming in. 

    Best regards
    Mads

    KeviSunshine
    Expert Problem Solver III
    Expert Problem Solver III
    February 22, 2024

    Hi Mads,

    Show this to your developer:

    // New Klaviyo API call format.
    {
    "data": {
    "type": "event",
    "id": "",
    "attributes": {
    "properties": {
    "booking_start_date": "" // Put the data here!!!
    "Metadata": {} // this is where you're putting the data right now
    }
    }
    }
    }

    // Old Klaviyo API call format.
    {
    "token":"",
    "event":"Placed Order",
    "customer_properties":{}, // Put booking data here IF YOU WANT IT TO BE ON A PROFILE
    "properties": {
    "booking_start_date": "" // Put the data here!!!
    "Metadata": {} // this is where you're putting the data right now
    }
    }

     

    Hope that helps

    Contributor IV
    February 26, 2024

    Hi Kevin

    Thanks a lot for the provided snippet - it was exactly something like that I was looking for!

    I have forwarded it to the developer and is awaiting his response

    Best regards
    Mads

    Contributor IV
    February 28, 2024

    Hi Kevin

    Unfortunately, it didn’t seem to do the trick.
    Booking data is still being nested in the same place as before.
    One of the chat supporters mentioned that the dates, can’t be in actual date formats, otherwise it won’t work. 

    “It is not possible to segment on date type data from a property”

    Best regards
    Mads

    KeviSunshine
    Expert Problem Solver III
    Expert Problem Solver III
    February 28, 2024

    Hey Mads,

     

    Any chance you can share the script your developer is using?

     

    Thank you,

    Kevin.