Skip to main content

Add a rating aggregate to abandoned cart emails in Klaviyo

Dynamically display product star ratings in Klaviyo abandoned cart flows by adding a rating aggregate feed and code snippet.

Written by Simon Mainwaring

Overview

Shoppers who leave items in their cart are more likely to come back when they can see how other customers rated those products. Add a rating aggregate to your Klaviyo abandoned cart emails, and each product's star rating and review count appear under its title.

Abandoned cart email with star ratings under each product title

Before you begin

🔔 The rating aggregate feed is available on the Power plan and above. View pricing.

Connect Klaviyo to Okendo first: see Integrating Klaviyo with Okendo.

⚠️ The rating aggregate works in Klaviyo flows only, not campaigns.


Enable your Klaviyo feed

  1. Open your Okendo app

  2. Click the pencil icon next to Klaviyo

    Klaviyo integration settings in Okendo with the Product Review Aggregate Feed toggle

  3. Turn on the Enable Product Review Aggregate Feed toggle

  4. Click Save

⚠️ Once enabled, allow up to 24 hours for your feed to be populated before continuing.


Add the product review aggregate feed

  1. Navigate to your Klaviyo account > Settings > Other > Web Feeds > Add Web Feed.

    Klaviyo Web Feeds page with the Add Web Feed button

  2. Input the following data into the spaces and click update.

    • Required name: product_review_aggregate

    • Feed URL: add the URL from the Okendo admin

    • Request Method: GET

    • Content-Type: JSON

    Klaviyo Add Web Feed form


Adding star rating under product title

  1. Add a Table block to your email. Set the first column to Image and the second column to HTML

  2. In the left menu, go to Styles, set the Data to "Dynamic" and confirm that you are using the correct “Row Collection” and “Row Alias”:

    • Row Collection: event.extra.line_items

    • Row Alias: item

    Klaviyo table block Styles panel with Data set to Dynamic

  3. Go to Content > Select Image > Dynamic Image and insert the code below (this is the same code Klaviyo uses in their default abandoned cart email):

    {% if item.product.variant.images.0.src %}{{item.product.variant.images.0.src}}{%else%}{{item.product.images.0.src|missing_product_image}}{%endif%}

    Adding the dynamic image code in Klaviyo

  4. In the second column (HTML) add the following code:

    {% with productId=item.product.id|slugify %}
    <table role="presentation" border="0" cellspacing="0" cellpadding="0" width="100%" style="border:0;">
    <tbody>
    <tr>
    <td style="font-family:'Helvetica Neue', Arial, sans-serif;color:#1d2236;font-size:16px;font-weight:bold;line-height:22px;padding-bottom:6px;">
    {{ item.product.title }}
    </td>
    </tr>
    {% for value in feeds.product_review_aggregate %}
    {% if productId == value.product_id %}
    <tr>
    <td style="padding-bottom:8px;">
    <table role="presentation" border="0" cellspacing="0" cellpadding="0" style="border:0;">
    <tbody>
    <tr>
    <td style="padding-right:6px;vertical-align:middle;">
    <img src="https://d3hw6dc1ow8pp2.cloudfront.net/emails/review/stars/stars-{% widthratio value.rating 1 10 %}-000000.png" height="14" alt="{{ value.rating }} out of 5 stars" style="height:14px;display:block;border:0;outline:none;text-decoration:none;">
    </td>
    <td style="vertical-align:middle;font-family:'Helvetica Neue', Arial, sans-serif;font-size:14px;color:#545866;">
    {{ value.count }} {% if value.count == 1 %}Review{% else %}Reviews{% endif %}
    </td>
    </tr>
    </tbody>
    </table>
    </td>
    </tr>
    {% endif %}
    {% endfor %}
    <tr>
    <td style="font-family:'Helvetica Neue', Arial, sans-serif;color:#545866;font-size:14px;line-height:20px;padding-bottom:2px;">
    Quantity: {{ item.quantity|floatformat:0 }}
    </td>
    </tr>
    <tr>
    <td style="font-family:'Helvetica Neue', Arial, sans-serif;color:#545866;font-size:14px;line-height:20px;">
    Total: {% currency_format item.line_price|floatformat:2 %}
    </td>
    </tr>
    </tbody>
    </table>
    {% endwith %}

⚠️ Because this is configured with HTML, you will either need a developer or a tool like Claude or Codex to make styling changes.

Your table in the editor will look like this:

Finished table block in the Klaviyo editor

And when you click Preview and Test it should look like this (if there is a valid Checkout started event with a product that has reviews):

Preview of the abandoned cart email with star ratings

💡 If you’d like to update the star color, update the 000000.png section in the code. If it doesn't work, please contact support@okendo.io. We will create a ticket and upload the color to our system, which takes around 3 business days. It won't reflect in the code until we do this.

Did this answer your question?