Solved

How to trigger a custom transactional email

  • 14 December 2021
  • 4 replies
  • 710 views

Badge +2

I use Zapier to trigger transactional emails in other programs and would like to send custom emails through my Klaviyo account so all of my email tracking is in one place. I see that the API supports event-based triggers where I can re-create everything I’ve done in Zapier inside Klaviyo, but my metrics aren’t anything supported by the examples provided in the API docs. What options do I have to use Klaviyo for this purpose?

icon

Best answer by David To 14 December 2021, 16:04

View original

4 replies

Badge +2

David - this is extremely helpful, and it all makes sense. I’ll give this all a try and see how it goes. Thanks a million. :clap:

Userlevel 7
Badge +60

Hello @Dstepchew,

Great question!

First, I would suggest taking a look at our Guide to Using Flows to Send Transactional Emails Help Center articles to learn more about how Klaviyo initiates transactional flow emails and the process on how to request your email be marked transactional. 

Second, Klaviyo actually has a fairly robust open API which allows you to create your own custom events; which can be used to trigger flows. You would not be limited to the example provided within our documentation. From my experience, I’ve seen a wide variety of different custom events created by our clients to serve their goals! 

To learn more about building your own custom events and about leveraging Klaviyo’s API, I would recommend taking a look at the following Help Center articles and documents:

In addition, I would also encourage working with a developer you are familiar with or working with an accredited Klaviyo Partner if you need further assistance working with the API and creating your own custom events. 

I hope this helps!

David

Badge +2

Thanks David! I appreciate the response and I have been studying these Help Center articles and documents closely. I can’t wait to get started with custom events, but I’m having particular trouble identifying exactly where in the docs it outlines, “how to create custom events.” I see how to name them properly and how to track a corresponding event, use it in flows, etc. but I don’t see where to define these custom events/metrics and their corresponding custom properties. Are they defined upon sending the first request? For example, in the docs I found this:

 

 

Server-Side Requests

You'll want to send server-side data to Klaviyo in one of two ways: real-time or batch.

  • Real-time: requests are made as soon as an action is taken
  • Batch: script runs at least once an hour, sending all events from the past hour to your Klaviyo account

Key things to be aware of when tracking server-side events:

  • Make sure to replace PUBLIC_API_KEY with your public API key
  • The $event_id should be a unique identifier for the order (e.g., Order ID)
  • If the same combination of event and $event_id are sent more than once, all subsequent tracked events with the same combination will be skipped
  • time is a special property that should be a UNIX timestamp of the order date and time

Server-side events should include any information about the person who took the action (e.g. first name) as profile properties in the customer_properties dictionary and any information specific to the event itself (e.g., a list of ordered items) in the properties dictionary.

 

Do I need to define  event before I begin sending the events? I also have a long list of custom properties that need to be available in the triggered flows in order to send personalized messages (in this case we are asking customers to approve or reject custom logo sew outs). Where do I define those? Thanks!

Userlevel 7
Badge +60

Hey@Dstepchew,

Glad to hear you’re heading in the right direction!

You’ll actually want to define both the event and any of those custom properties as part of the event directly within your API payload you are making. 

Using a Placed Order event below as an example, you can see that the event is defined as "Placed Order" along with all subsequent properties pertaining to this order event below it. As a note, when creating filters based on event data, what is an available filter depends on how deep the data is nested. Objects available to filter are only available up to two levels deep. 

{
"token": "API_KEY",
"event": "Placed Order",
"customer_properties": {
"$email": "john.smith@test.com",
"$first_name": "John",
"$last_name": "Smith",
"$phone_number": "5551234567",
"$address1": "123 Abc st",
"$address2": "Suite 1",
"$city": "Boston",
"$zip": "02110",
"$region": "MA",
"$country": "USA"
},
"properties": {
"$event_id": "1234",
"$value": 29.98,
"Categories": ["Fiction", "Classics", "Children"],
"ItemNames": ["Winnie the Pooh", "A Tale of Two Cities"],
"Brands": ["Kids Books", "Harcourt Classics"],
"Discount Code": "Free Shipping",
"Discount Value": 5,
"Items": [{
"ProductID": "1111",
"SKU": "WINNIEPOOH",
"ProductName": "Winnie the Pooh",
"Quantity": 1,
"ItemPrice": 9.99,
"RowTotal": 9.99,
"ProductURL": "http://www.example.com/path/to/product",
"ImageURL": "http://www.example.com/path/to/product/image.png",
"Categories": ["Fiction", "Children"],
"Brand": "Kids Books"
},
{
"ProductID": "1112",
"SKU": "TALEOFTWO",
"ProductName": "A Tale of Two Cities",
"Quantity": 1,
"ItemPrice": 19.99,
"RowTotal": 19.99,
"ProductURL": "http://www.example.com/path/to/product2",
"ImageURL": "http://www.example.com/path/to/product/image2.png",
"Categories": ["Fiction", "Classics"],
"Brand": "Harcourt Classics"
}
]
},
"time": 1387302423
}

David

Reply