Using JSON in Segments 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

Using JSON in segments in Customer.io is how you turn messy, nested ecommerce data (like cart line items, product categories, quiz answers, or shipping options) into clean targeting that actually moves revenue. Instead of building one segment per SKU or relying on blunt attributes like “last_order_date,” you can segment shoppers based on what is inside their cart, what they browsed, or what they repeatedly buy.

If you want this wired to real store behavior quickly, Propel helps teams implement Customer.io with an outcomes-first approach, then pressure test segments against revenue reporting. If you want help designing the data and segments behind your highest leverage flows, book a strategy call.

How It Works

Using JSON in segments in Customer.io works by evaluating nested properties inside an attribute or event payload, then letting you filter people based on values inside that JSON (including arrays like line_items).

In practice, most D2C brands end up with at least one of these JSON sources:

  • Event data (recommended for behavior): events like Product Viewed, Added to Cart, Checkout Started, Order Completed with JSON properties.
  • Person attributes (use sparingly): things like preferences, skin_profile, or last_cart stored as JSON on the profile.

Customer.io then lets you build segments that check for the presence of a JSON key, match exact values, or match values inside arrays. This is where you go from “cart abandoners” to “cart abandoners with a subscription-eligible item and AOV over $60.” For implementation patterns and orchestration help, we often pair this with journey logic in Customer.io.

Step-by-Step Setup

Using JSON in segments in Customer.io is easiest when you start from the decision you want to make (who gets what message), then work backward into the event payload.

  1. Pick the revenue use case first. Example: “Send an SMS only when the cart contains any item from the ‘Bundles’ collection.”
  2. Confirm where the JSON lives. Decide whether the data is coming in on an event (preferred) like Added to Cart or stored on the person profile.
  3. Standardize your JSON schema. Keep key names stable (for example, line_items, sku, product_id, collections, price, quantity). Avoid mixing strings and numbers for the same field across events.
  4. Send an event with nested properties. Typical cart event payload includes an array of line items plus cart totals. Make sure at least one stable identifier exists per item (SKU or product_id).
  5. Validate the payload in Customer.io. Check that the event is arriving with the expected nested structure and that arrays are not stringified.
  6. Build a segment using JSON conditions. Target based on JSON keys and values (for example, any line item where collections contains “bundles,” or any item with subscription_eligible = true).
  7. Pressure test edge cases. Multi-currency, discount codes, empty carts, and duplicate events can break segments silently if you do not test them.
  8. Use the segment in journeys. Apply it as entry criteria, a filter, or a branch condition to control what message a shopper receives.

When Should You Use This Feature

Using JSON in segments in Customer.io is the right move when broad segments are leaving money on the table and you need to target based on what a shopper actually intends to buy.

  • Abandoned cart recovery by item type: send different creative if the cart contains a replenishable item vs a one-time gift.
  • Product discovery journeys: if a shopper views multiple products in the same category, trigger a curated “best sellers in your routine” message.
  • Checkout behavior segmentation: treat “checkout started with express pay selected” differently than “checkout started with shipping step drop-off.”
  • Post-purchase cross-sell: if the order includes a “starter kit,” promote refills; if it includes a refill, promote bundles.
  • Reactivation with relevance: winback based on the last purchased category, shade, size, or dietary preference stored in JSON.

Operational Considerations

Using JSON in segments in Customer.io is only as reliable as the data discipline behind it, and ecommerce data tends to get messy fast.

  • Event naming and schema governance: decide who owns the schema (engineering, data, retention) and document keys so segments do not drift.
  • Array behavior: cart and order line items are arrays, so your segment logic needs to account for “any item matches” vs “all items match.”
  • Data freshness: cart state changes quickly. Prefer event-based segmentation with tight time windows (for example, “Added to Cart in last 2 hours”) instead of storing a “current_cart” attribute that goes stale.
  • Orchestration between email and SMS: use JSON-based segments to decide channel priority (for example, only SMS if cart_total is above a threshold or item is high intent).
  • Reporting alignment: make sure segment membership maps to how you report revenue (SKU, category, bundle) so you can prove lift.

Implementation Checklist

Using JSON in segments in Customer.io goes smoothly when you treat it like a small data product, not a one-off segment build.

  • Define the exact targeting rule in plain English (who qualifies and why).
  • Choose event-based JSON whenever the behavior is time-sensitive (cart, browse, checkout).
  • Standardize keys and data types (string vs number) across sources.
  • Include stable identifiers in every line item (sku or product_id).
  • Validate payloads in Customer.io before building segments.
  • Build segments with clear naming (use case, rule, time window).
  • Test with real shoppers and known orders to confirm matches.
  • Add guardrails for duplicates and edge cases (discounts, partial refunds, multi-currency).

Expert Implementation Tips

Using JSON in segments in Customer.io is where advanced D2C programs separate “basic automation” from truly personalized commerce messaging.

  • Start with 2 to 3 high-leverage JSON segments instead of modeling everything. In retention programs we’ve implemented for D2C brands, the fastest wins come from cart line item segmentation (category, replenishable, bundle) and post-purchase segmentation (starter vs refill).
  • Design for creative modularity. If your segment targets “cart contains bundles,” make sure your message templates can swap hero, product tiles, and offer logic without building a net-new email each time.
  • Use JSON to avoid SKU explosion. Rather than “Cart contains SKU123,” segment on a higher-level tag like product_type or collection included in the line item JSON.
  • Pair with time windows. A cart segment without a recency condition often becomes a “forever segment,” which leads to accidental over-messaging.

Common Mistakes to Avoid

Using JSON in segments in Customer.io can quietly fail when the data is inconsistent, even if the segment builder looks correct.

  • Stringifying arrays: sending line_items as a string instead of a JSON array makes it hard or impossible to reliably segment.
  • Inconsistent key names: mixing productId and product_id across events forces duplicate segments and breaks reporting.
  • Building segments on “current cart” profile data: it goes stale and causes shoppers to get cart messages after they purchased.
  • Over-segmenting too early: dozens of micro-segments create operational debt and slow down iteration on offers and creative.
  • Ignoring refunds and cancellations: post-purchase segments should consider order status, otherwise you can upsell someone who just refunded.

Summary

Using JSON in segments is how you target shoppers based on what they are actually doing and buying, not generic profile fields.

Use it when cart, browse, and purchase details live in nested payloads and you need sharper journeys inside Customer.io.

Implement with Propel

Propel can help you design the event schema, build JSON-powered segments, and wire them into Customer.io journeys that drive first and repeat purchases. If you want to audit your current data and identify the highest ROI segments to build next, 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