I have a question about sending date/time values via the Klaviyo Events API.
I’m trying to store a date-time value in an event property, but it is always saved as a string instead of a date in Klaviyo. I’ve tried several formats, but the result is the same.
For example, I want the following value to be stored as a date, not a string:
expiry_date: "2022-11-08T00:00:00+00:00"
Below is a sample of the event payload I’m sending:
Is there a specific way or required field type to ensure Klaviyo recognizes this as a date/time property instead of a string? Or is it expected behavior that event properties are always stored as strings?
Any guidance or best practices would be greatly appreciated. Thank you in advance!
Best answer by Kim from Cadence
Hey @shahidIqbal, what exactly are you trying to do with this expiry_date property? Are you trying to use it in a segment? As part of a flow trigger filter or conditional split?
From a quick test, I don’t think the UTC offset is causing problems here. ISO8601 format is Klaviyo’s recommended datetime format.
Klaviyo doesn’t seem to support filtering by top-level date fields in segments in a way that recognizes it as a date. The date operators (before, less than, between, etc.) are not supported for these “What someone has done” sub-filters.
Depending on what you’re trying to do here, you might want to do one or more of the following:
Move this date to be a top-level field on the event properties.
Use a profile property instead. These have more expansive filtering capabilities in segments.
Create an event modeling Product
Happy to share more specific advice once I know what you’re trying to do!
@shahidIqbal have you tried sending it without +00:00? just convert the datetime to the Klaviyo’s account’s timezone and abide by that instead of trying to pass the timezone suffix.
Hey @shahidIqbal, what exactly are you trying to do with this expiry_date property? Are you trying to use it in a segment? As part of a flow trigger filter or conditional split?
From a quick test, I don’t think the UTC offset is causing problems here. ISO8601 format is Klaviyo’s recommended datetime format.
Klaviyo doesn’t seem to support filtering by top-level date fields in segments in a way that recognizes it as a date. The date operators (before, less than, between, etc.) are not supported for these “What someone has done” sub-filters.
Depending on what you’re trying to do here, you might want to do one or more of the following:
Move this date to be a top-level field on the event properties.
Use a profile property instead. These have more expansive filtering capabilities in segments.
Create an event modeling Product
Happy to share more specific advice once I know what you’re trying to do!