Solved

Segmentation based on metadata

  • 21 February 2024
  • 18 replies
  • 109 views

Badge +1

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

icon

Best answer by KeviSunshine 28 February 2024, 15:44

View original

18 replies

Userlevel 4
Badge +7

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.

Badge +1

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

Userlevel 4
Badge +7

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.

Badge +1

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

Userlevel 4
Badge +7

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.

Badge +1

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

Userlevel 4
Badge +7

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

Badge +1

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

Badge +1

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

Userlevel 4
Badge +7

Hey Mads,

 

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

 

Thank you,

Kevin.

Badge +1

Hi Kevin

The last one I received from him was this.
Not sure if this is what you mean by script - my apologies if not :-)

add_filter('kl_added_to_cart','kl_modify_added_to_cart', 99, 4);

 

function kl_modify_added_to_cart($added_to_cart, $added_product, $quantity, $wck_cart) {

  

   if( isset($_REQUEST['start_date_submit']) ){

      $start_date = $_REQUEST['start_date_submit'];

      $added_to_cart['booking_start_date'] = $start_date;

   }

   if( isset($_REQUEST['end_date_submit']) ){

      $end_date = $_REQUEST['end_date_submit'];

      $added_to_cart['booking_end_date'] = $end_date;

   }

  

   return $added_to_cart;

}

Userlevel 4
Badge +7

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?

Badge +1

Hi Kevin

Did anyone from Klaviyo reach out to you yet?
Really appreciate the help! :-)

Best regards
Mads

Userlevel 4
Badge +7

Hey Mads, nothing yet, let’s try @’ing few more people…

 

@David To – are you still around here? Any chance you could help Mads? It’s a bit of a thread, but essentially the question boils down to: is it possible to include woocommerce product metadata in the top-level fields of the “Placed Order” event? Or does this data only go into the Metadata field?

 

Best,

Kevin.

Badge +1

Hi Kevin

Seems like it’s a bit difficult to receive support from Klaviyo, if you have a question that is deviating a bit from standard inquiries :(

Thanks a lot for your help, I will see and try if I can get a hold of someone in support (again)

Best regards
Mads

Userlevel 4
Badge +7

Yeah, sorry Mads. I hate to see a non-answer of mine have to be selected as the best answer.

Did you try Klaviyo support? Creating a support ticket is really easy and they’re very helpful. I think you’ve certainly exhausted your other avenues, and I think you can frame your question to the support team in a way that they will be able to help.

Badge +1

I initially reached out to them, and they were actually the ones who referred me to Klaviyo Developer Group, because they said they couldn’t help with something of that nature.

In a last desperate effort of help, are you able to provide me with an optimal framing of the question, that you believe would make support able to help?
No strings attached if it doesn’t work out, you have done more than enough for me already :-)

Best regards
Mads

Userlevel 4
Badge +7

Haha, no worries, I think this is the proper way to frame the question:

Is it possible to include woocommerce product metadata in the top-level fields of the “Placed Order” event? Or does this data only go into the Metadata field?

By default, the data goes into the “Metadata” field.

 

Best of luck!

Reply