Klaviyo : Search Events
The following guide is for integrating Klevu search events into Klaviyos event tracking using API.
To implement the connector to Klaviyo, you need an active subscription to Klaviyo and be on a Klevu plan with Personalization enabled.
For details on the setup and configuration of Klevu to Klaviyo events within the platform(s), please see: https://help.klevu.com/support/solutions/articles/5000878078-integration-steps-to-send-klevu-search-events-to-klaviyo
You must have Klaviyo active on the site to utilize Klaviyo's API for pushing event data.
There are three key aspects to consider:
- Check the data against Klevu NLP Annotations API
- Prepare the data object for push to Klaviyo
- Submit object to Klaviyo as a Klevu Search event
1. Check the data against Klevu NLP Annotations API
Klevu provides an external function for Klaviyo event tracking that will analyze and prepare the values to be sent to Klaviyo. Although not required, this step is recommended to get the optimal values that will be injected into the Klaviyo event flow. This check may be fired after a search query and held in localstorage for use in constructing the object for the Klaviyo event push (see step 2 below)
?query={search query}
&title={product title}
&category={product attribute 'category' from search results}
&language={store language ISO code}Example Response
{
"apiKey": "klevu-12345",
"annotations": {
"subjects": [
"sneakers",
"sneaker"
],
"fullTerm": [
"men shoes"
]
},
"responseMessage": "SUCCESS",
"qtime": 0
}
2. Prepare the data object for push to Klaviyo
The values returned by the Klevu Annotations query will be used in the object sent to Klaviyo for use in the event flow. Product Clicked tracking and Search Results data will need to be captured independently for use in the object. Build the object to push to Klaviyo using the following JSON format:
{
"Search Term": "String", // original search query
"Search Term(full)": ["String"], //contained in the NLP response object
"Subjects": ["String","String"], //contained in the NLP response object
"Total Number of Product Results": Integer, // total number of products found by the search query
"Product Clicked": {
// product data for clicked product
},
"Search Results":[
{
// product data for first product in the klevu search response
},
{
// product data for next product in the klevu search response
},
... // 10 products
],
"Recommended results": []
// optional list of products formated similar to
// the Search Results, only valid in the case of
// click being extracted from a fallback query
}Example:
{
"Search Term": "men shoes",
"Search Term(full)": ["men shoes"],
"Subjects": ["sneakers","sneaker"],
"Total Number of Product Results": 2,
"Product Clicked": {
"name": "Acme Men Black Sneakers",
"id": "456789",
"url": "https://myexample.com/products/acme-men-black-sneakers",
"imageUrl": "https://myexample.com/images/products/456789_images_medium.jpg?v=1666139322",
"price": "26.95",
"salePrice": "26.95"
},
"Search Results":[
{
"name": "Cool Men Khaki Shoes",
"id": "987654",
"url": "https://myexample.com/products/cool-men-khaki-shoes",
"imageUrl": "https://myexample.com/images/products/987654_images_medium.jpg",
"price": "29.95",
"salePrice": "29.95"
},
{
"name": "Acme Men Black Sneakers",
"id": "456789",
"url": "https://myexample.com/products/skechers-men-black-sneakers",
"imageUrl": "https://myexample.com/images/products/456789_images_medium.jpg",
"price": "26.95",
"salePrice": "26.95"
}
],
}
3. Submit object to Klaviyo as a Klevu Search event
_learnq.push(["track", "Klevu Search", <objectToPush>]);See Klaviyo developer documentation for details on submitting tracked events. https://developers.klaviyo.com/en/v1-2/docs/javascript-api
The event Klevu Search will now be available within the Klaviyo Profile > Events view
