Loop Through Data in Customer.io

Customer.io partner logo

Table of Contents

Summarize this documentation using AI

This banner was added using fs-inject

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Overview

Loop through data in Customer.io is how you turn raw event payloads (like cart items, order line items, or recommended products) into dynamic message blocks that actually sell. Instead of sending a generic abandoned cart email, you can render the exact items someone left behind, with images, variants, prices, and deep links back to checkout, then reuse the same template across thousands of SKUs.

If you want this to be reliable across email and SMS, Propel can help you standardize your commerce event schema and Liquid patterns so your programs scale without constant template edits. If you want help pressure testing your cart and post-purchase data model, book a strategy call.

Built on top of Customer.io, this approach is most valuable when your catalog is large, your cart sizes vary, or your brand runs frequent promos where the content needs to adapt per customer.

How It Works

Loop through data in Customer.io works by using Liquid loops (typically for) to iterate over arrays in your data, like items in a cart event or line_items in an order event, and print out fields for each item.

In practice, your message pulls from a few places:

  • Trigger data from the event that started the campaign (for example, an Added to Cart or Checkout Started event containing an items array).
  • Person attributes (like loyalty tier, last ordered category, or preferred size) to filter or change what you show.
  • Objects or related data (if you store product metadata separately and reference it).

The loop renders a repeated block per item, which is how you get a clean “Your cart” section, a “You bought” order recap, or a “Top picks for you” grid. When implemented well, it reduces template sprawl because one message can handle 1 item or 12 items without breaking.

For deeper orchestration patterns and QA workflows, we typically implement this inside Customer.io campaigns where the trigger event is guaranteed to include the array you plan to loop over.

Step-by-Step Setup

Loop through data in Customer.io is easiest to implement when you start from a real event payload and build the template around the exact structure your store sends.

  1. Pick the revenue moment you are personalizing. Common starting points are abandoned cart, browse abandon, post-purchase cross-sell, and replenishment.
  2. Confirm the event payload includes an array. For cart recovery, you want something like items with each item containing product_id, name, image_url, quantity, price, and a product_url or checkout_url.
  3. Trigger a campaign from that event. Use the event that reliably contains the full cart state (often “Checkout Started” or “Cart Updated” rather than “Product Added” if the latter only contains one SKU).
  4. Add a message and open the editor. Use a single reusable module for the item row or card layout (image, title, variant, price, quantity, CTA).
  5. Write the Liquid loop to render each item. Iterate through the array and print the fields you need. Keep the loop minimal, then add formatting and fallbacks.
  6. Add guardrails for missing data. Handle missing images, long names, out-of-stock flags, or null prices so the message does not break.
  7. Cap the number of items displayed. Show the first 3 to 6 items and then add a “View full cart” button so the email stays scannable.
  8. QA with multiple payloads. Test a 1-item cart, a multi-item cart, and a cart with variants or bundles to confirm layout stability.
  9. Measure conversion at the message level. Track click-to-checkout rate and recovered revenue, not just opens, because loops mainly improve relevance and cart completion.

When Should You Use This Feature

Loop through data in Customer.io is the right move when your message performance is limited by generic content, especially in cart recovery and post-purchase where specificity drives revenue.

  • Abandoned cart recovery with multi-item carts. Showing the exact items typically lifts click intent because customers recognize what they were building.
  • Post-purchase order recap plus next-step merchandising. Render line items, then append category-based cross-sells that match what they bought.
  • Bundled products and variants. If you sell kits, subscriptions, or size/color variants, looping prevents you from hardcoding product blocks.
  • Product discovery journeys. If you capture “Viewed Collection” or “Viewed Product” events with arrays (for example, last 5 viewed SKUs), you can loop to build a personalized “Still thinking about these?” email.
  • High-SKU catalogs with frequent creative refreshes. One template can stay stable while the data changes.

Operational Considerations

Loop through data in Customer.io becomes operationally smooth when your data contracts are stable and your team agrees on what each event must contain.

  • Event design matters more than Liquid. In retention programs we’ve implemented for D2C brands, the biggest wins came from standardizing a single “cart snapshot” event that always includes the full cart array and checkout URL.
  • Segmentation and orchestration. Use segments to separate high-intent abandoners (checkout started) from low-intent browsers, then tailor how aggressive the looped content is (discount gating, urgency copy, shipping thresholds).
  • Data freshness. Carts change. If you trigger off an old payload, you may show items that are no longer in the cart. Consider triggering from the most recent cart update event or adding a short delay so the cart stabilizes.
  • Inventory and pricing. If you do not pass inventory state and current price in the event, you risk showing stale pricing. Either pass these fields at send time or link to a cart/checkout page that reflects real-time values.
  • Template governance. Build a reusable “item card” component so creative changes do not require rewriting the loop logic each time.

Implementation Checklist

Loop through data in Customer.io goes live faster when you treat it like a data plus creative project, not just a template tweak.

  • Cart and order events include arrays with consistent field names
  • Each item includes image URL, title, variant, quantity, price, and destination URL
  • Fallbacks exist for missing images, long names, and null prices
  • Item display capped (for example, first 3 to 6 items) with a “View cart” CTA
  • UTM parameters and attribution are consistent across item links and primary CTA
  • QA coverage includes 1-item, multi-item, variant-heavy, and bundle carts
  • Conversion tracking is set up for recovered revenue and checkout completion

Expert Implementation Tips

Loop through data in Customer.io performs best when you optimize for clarity and speed to checkout, not maximum personalization.

  • Design for scanning. In abandoned cart, prioritize image, product name, and one strong CTA. Price and variant details can be secondary if they clutter the layout.
  • Use a “hero item” pattern. In retention programs we’ve implemented for D2C brands, featuring the highest-priced or most-viewed item first (then looping the rest below) often improves click-to-checkout because the email feels curated, not autogenerated.
  • Keep the loop logic simple. Complex conditional formatting inside loops becomes fragile. If you need heavy logic (like grouping by category or bundle), consider preprocessing the array in your data pipeline.
  • Pair with threshold messaging. If you run free shipping over $X, calculate and pass cart subtotal and remaining-to-threshold so the looped cart items sit next to a strong incentive.

Common Mistakes to Avoid

Loop through data in Customer.io can backfire when the message shows the wrong products or the layout breaks on edge cases.

  • Triggering from an event that does not contain the full array. A “Product Added” event often only has one item, which leads to incomplete cart renders.
  • No fallbacks for missing fields. One null image URL can make the whole section look broken, especially in email clients with strict rendering.
  • Showing too many items. A 12-item cart email becomes noisy and reduces clicks. Cap the display and push the rest to the cart page.
  • Stale cart content. If customers remove items, your email can feel inaccurate. Use the freshest cart snapshot available.
  • Over-optimizing the loop instead of the offer. Dynamic content helps, but the biggest lift often comes from the right timing, incentive rules, and a clean path back to checkout.

Summary

Loop through data is the fastest way to make cart, browse, and post-purchase messages feel specific to each customer. Use it when you have item arrays in your events and you want higher click-to-checkout and repeat purchase.

Implemented well in Customer.io, it reduces template maintenance while improving relevance at scale.

Implement with Propel

Propel can help you implement loop-based cart and order templates in Customer.io with a clean event schema, reusable components, and QA coverage for real commerce edge cases. If you want to move faster and avoid brittle Liquid, book a strategy call.

Contact us

Get in touch

Our friendly team is always here to chat.

Here’s what we’ll dig into:

Where your lifecycle flows are underperforming and the revenue you’re missing

How AI-driven personalisation can move the needle on retention and LTV

Quick wins your team can action this quarter

Whether Propel AI is the right fit for your brand, stage, and stack