Personalized Recommendations with Klaviyo
Klaviyo CEP x Tweakwise
This integration allows you to leverage Klaviyo's profile and segment data within Tweakwise to personalize product recommendations.
This explains how to pass user browsing behavior tracked by Tweakwise into Klaviyo e-mails. This setup enables true 1-to-1 personalized product recommendations in automated email flows such as Browse Abandonment, Cart Abandonment, or Welcome series.
Architecture Overview
- Website Tracking: As visitors browse your webshop, Tweakwise assigns or tracks a unique profile identifier (
tn_profilekey) stored in local storage or cookies. - Profile Enrichment: When a visitor identifies themselves (e.g., logging in or submitting a form), you push this
tn_profilekeyas a custom profile property to your ESP/CDP. - Flow Execution: During email automation execution, the profile key is used to fetch live, personalized recommendations from the Tweakwise Delivery API.
Step 1: Capture and Sync the Profile Key
When an anonymous user becomes known on your website, capture the active Tweakwise profile key from the browser and send it to Klaviyo via their identify script or API.
Example: extract the tn_profilekey and push it to Klaviyo:
// Example: Extracting the Tweakwise profilekey and updating Klaviyo's profile
var tweakwiseProfileKey = localStorage.getItem('profilekey'); // or get it from a cookie
if (tweakwiseProfileKey) {
_learnq.push(['identify', {
'Tweakwise_Profile_Key': tweakwiseProfileKey
}]);
}Step 2: Implementation Methods
Klaviyo Web Feeds do not support dynamic profile properties (such as `person.Tweakwise_Profile_Key`) directly within the Web Feed URL. To bypass this, use a webhook trigger via middleware (e.g., Make.com, Zapier, or a custom microservice).
Workflow Setup
[Klaviyo Flow Trigger] ➔ [Webhook to Middleware] ➔ [Fetch Tweakwise Recommendations] ➔ [Update Klaviyo Profile Property] ➔ [Send Email]
- Trigger Webhook:
Add a Webhook action as the first step in your Klaviyo Flow. Configure the webhook payload to send the customer's email andTweakwise_Profile_Keyto your middleware endpoint. - Middleware Processing:
- Receives the webhook payload.
- Calls the Tweakwise Delivery API:
GET https://api.tweakwise.com/recommendations/featured/{instancekey}/{recommendationid}?tn_profilekey={Tweakwise_Profile_Key}- Formats the returned product array (URLs, image links, titles, prices).
- Pushes the array back to the Klaviyo profile using the Klaviyo Profile API under a property named
Tweakwise_Recommendations.
- Email Template Rendering:
After a short delay step (e.g., 1 minute), send the email. Render the recommendations directly from the profile property:
{% for product in person.Tweakwise_Recommendations %}
<div style="display: inline-block; width: 45%; text-align: center; margin: 2%;">
<a href="{{ product.url }}">
<img src="{{ product.image_url }}" alt="{{ product.title }}" style="max-width: 100%;" />
<p style="font-weight: bold;">{{ product.title }}</p>
<p>{{ product.price }}</p>
</a>
</div>
{% endfor %}
Best Practices
- Fallback Configuration: Ensure your Tweakwise recommendation rules have a fallback configured (e.g., overall bestsellers or trending category items) in case a user has insufficient browsing history.
- Error Handling: When using middleware, set default empty arrays or conditional checks in your email templates (
{% if person.Tweakwise_Recommendations %}) to prevent broken layouts if an API call fails. - Profile Merging: When a user logs in across multiple devices, ensure your front-end logic updates the ESP profile with the latest active
tn_profilekey.
Updated about 3 hours ago
