Solved

Creating custom metric for Password Reset emails

  • 18 September 2023
  • 2 replies
  • 452 views

Badge

I am new to Klaviyo and so far I have found some of the Klaviyo documentation confusing around creating and sending metrics/events.

Note: I only wish to use server-side APIs, not client-side.

According to this article on Transactional emails I can use the open API to set up a custom metric:-

“If you want to use a metric to trigger the flow that isn't synced through your ecommerce integration, you will need to create a new custom metric. Klaviyo has an open API that you can leverage to set this up. For example, a password reset email would need a corresponding "Password Reset" event, which would need to be configured as a custom metric.

I then tried to use a request like this to create a metric/event using the server-side APi - https://developers.klaviyo.com/en/reference/create_event

I got a 202 Accepted but the custom metric never showed up in my Account and the event never showed up in the history of the profile I included as part of the request.

What I am trying to do is set up a flow for sending Password reset emails which are triggered by events. I was reading this article and reviewed the sample event included - https://developers.klaviyo.com/en/v1-2/docs/guide-to-setting-up-api-based-transactional-events#reset-password

 

I tried using a request like the sample

{
"token": "PUBLIC_API_KEY",
"event": "Reset Password",
"customer_properties": {
"$email": "john.smith@test.com"
},
"properties": {
"$event_id": "1234",
"PasswordResetLink": "https://www.website.com/reset/1234567890987654321"
},
"time": 1387302423
}


but got the following response:-

{
"errors": [
{
"id": "e0fd89e4-1fb7-4bc8-acbb-639b36cfadcf",
"status": 400,
"code": "invalid",
"title": "Invalid input.",
"detail": "An object with data is required",
"source": {
"pointer": "/data"
},
"meta": {}
}
]
}


Can anyone kindly explain to me how I can create a custom metric/event in my Klaviyo account such that I can send password reset events as demonstrated here - https://developers.klaviyo.com/en/v1-2/docs/guide-to-setting-up-api-based-transactional-events#reset-password

The terminology is also confusing. I assumed a metric is the event type eg. “Password Reset” and the events are the actual instances of messages that use this metric to trigger a flow. The very first sentence of this Klaviyo article however states that “Events, also referred to as metrics, record…..” - are they the same, are they different, confusing for the newcomer.

 

icon

Best answer by jjack 22 September 2023, 01:09

View original

2 replies

Userlevel 7
Badge +36

Hi @jjack!

I’m going to check on this with our API team and I’ll update the thread ASAP!

Best,

Brian

Badge

Hi

Thanks for looking into this question Brian.

I figured out that I was able to create the custom metric by creating an event as per the recent stable API docs - https://developers.klaviyo.com/en/reference/create_event

It took me quite a while to get here which I believe was mostly due to the following factors:-

  • Documentation discussing events/metrics but not indicating that it relates to the now deprecated API versions.
  • The terms events and metrics being used analogously as though they are the same thing but actually they are slightly different (though related). I still failed to find an article that explains these two concepts clearly for beginners.

The following works - creates a new Password Reset metric if it does not yet exist, and creates an event in the profile matched on the profile email.

POST https://api.moltin.com/v2/api/events/

{
"data": {
"type": "event",
"attributes": {
"properties": {
"email": "jon.doe@email.com",
"PasswordResetLink": "https://www.website.com/reset/1234567890987654324"
},
"metric": {
"data": {
"type": "metric",
"attributes": {
"name": "Password Reset"
}
}
},
"profile": {
"data": {
"type": "profile",
"attributes": {
"email": "jon.doe@email.com"
}
}
}
}
}
}

 

Reply