Guide
Connectors

Klaviyo : Segmentation

13min

The following guide will walk you through accessing Klevu Smart Recommendation configurations and applying corresponding pre-configured segments to web visitors via the Klevu API.

To implement Klaviyo segmentation logic with Klevu Smart Recommendations, you need an active subscription to Klaviyo and Klevu Smart Recommendations (with Personalization enabled).



The intitial setup and configuration process takes place within the Klevu Merchant Center. Detailed instructions on how to integrate Klaviyo with Klevu Smart Recommendations can be found here.

There are four key steps to consider: 1. Fetch the applicable segments for the visitor 2. Apply the Segments to the Recommendations configuration 3. Request and display the Klevu Recommendations banner 4. Collect Klevu Analytics (impressions and interaction)

1. Fetch the Applicable Segments for the Visitor

Three parameters are necessary to obtain the appropriate visitor segments 1. Klevu API KEY 2. Klevu Session ID 3. Klaviyo Exchange ID

Once the Klevu Session ID and the Klaviyo Exchange ID have been obtained, they can be stored locally and used in subsequent calls to Klevu for recommendations.

POST
Request
Body Parameters
apiKey
required
String
The unique Klevu apiKey ID of the store
Request Body
Responses
200


Retain the sessionId value for this user for use in subsequent API calls to Klevu for a maximum of the ttl time. At this point refresh the sessionId so as to retain continuity.



Obtain Klaviyo Exchange ID

Klaviyo holds identity and tracking information in a local browser cookie. The exchange_id is an encrypted identifier for a Klaviyo profile ID. The value is commonly stored within the base64 encoded Klaviyo cookie “__kla_id” More information can be found on the Klaviyo developer's website:

Retain the $exchange_id value for this user for use in subsequent API calls to Klevu.



Obtain Applicable Visitor Segments

Use the session endpoint to push the Klaviyo exchangeID to Klevu. This will allow Klevu to communicate with Klaviyo directly and return the visitor's applied segmentation.

POST
Request
Body Parameters
apiKey
required
String
The unique Klevu apiKey ID of the store
sessionId
required
String
The session ID as obtained in the previous requests
sessionInfo
required
String
Used to pass details of the session
connectorInfo
required
String
Used to pass details of the applied connector
connectorType
required
String
The value should be "klaviyo" in this context
exchangeId
required
String
The vlaue of the Klaviyo exchangeID as previously obtained
Request Body
Responses
200


Retain the segment value for this user for use in subsequent API calls to Klevu.

IMPORTANT: The segments may be updated for any given visitor throughout the session. To keep the segments relevant, please request an updated segment list after the ttl has expired.



2. Apply the Segments to the Recommendations Configuration

Please review the section on API Configurations for a complete list of applicable parameters to use based on the application/placement of the Recommendation banner.

GET
Request
Query Parameters
sids
required
String
The SegmentIDs returned as segmentInfo.segments within the previous request <SEGMENT_ID_A>,<SEGMENT_ID_B>,<SEGMENT_ID_C>
Query Paramters
Responses
200


Retain spotKey, spotName, segmentKey, segmentName for reference in the following Analytics collection API calls to Klevu.

The resulting search.payload JSON object will be the query payload used to call Klevu for the recommendations corresponding result set.



3. Request and Display the Klevu Recommendations banner

Use the provided query structure from the search.payload json within the above response to retrieve the Recommendations array from Klevu

See the Klevu Smart Recommendations API Overview for details on query specifics.



4. Collect Klevu Analytics

After the Recommendations have been displayed, collect the analytics to send to Klevu.

Please use the appropriate event value for each event type

  • Product recommendation impression: event = view_recs_list
  • Product clicks from recommendation banner: event = select_recs_list
POST
Request
Request Body
Responses
200




POST
Request
Request Body
Responses
200




Updated 22 Dec 2023
Doc contributor
Doc contributor
Did this page help you?