Personalize Actions with JavaScript 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

Personalize actions with JavaScript in Customer.io is how you turn raw shopper behavior into the exact message, offer, and timing that gets a first or repeat purchase. Instead of building five separate flows for five scenarios, you compute what to do at send time based on what the customer just did (SKU viewed, cart value, discount sensitivity, last purchase category, and more).

A common D2C example is cart recovery where the content and incentive changes based on margin and cart size, rather than blasting everyone with the same 10% off. Propel helps brands operationalize these personalization rules cleanly so the logic is maintainable as your catalog and promos evolve. If you want help pressure testing the logic and building it into production-ready journeys, book a strategy call.

Learn more about Customer.io implementations for ecommerce teams.

How It Works

Personalize actions with JavaScript in Customer.io works by evaluating JavaScript expressions inside your workflow actions or message content, so the platform can dynamically set values like coupon selection, product blocks, copy variants, and routing decisions.

In practice, you use JavaScript when Liquid templating alone starts to get messy, especially when you need computed outputs (like tiering, fallbacks, or selecting from arrays) that should be consistent across email, SMS, and push.

Typical pattern:

  • Shopper triggers an event (Viewed Product, Added to Cart, Started Checkout, Order Placed).
  • Your workflow pulls in the event payload and any stored customer attributes (last_order_date, LTV, preferred_category, discount_used_count).
  • JavaScript computes a decision or value (recommended SKU list, incentive tier, subject line angle, shipping threshold messaging).
  • The computed value is injected into the next action, usually a message, a webhook, or a branch condition.

If you are building this across multiple journeys, keep the logic consistent by standardizing inputs and outputs, then reusing patterns across campaigns in Customer.io.

Step-by-Step Setup

Personalize actions with JavaScript in Customer.io is easiest to roll out when you start with one high-impact journey (usually cart or checkout abandonment) and keep the first version tight.

  1. Pick a single journey where personalization changes revenue outcomes (for most brands, checkout abandonment beats browse abandonment to start).
  2. Confirm your event payload has the fields you need (cart items with SKU, quantity, price, compare_at_price, category, and cart total).
  3. Decide what JavaScript should output (for example: incentive_tier, hero_sku, product_recos, shipping_message).
  4. Implement the JavaScript expression in the relevant action or message template and map the output to a named variable you can reuse in the message.
  5. Add defensive fallbacks for missing data (empty cart array, unknown category, null compare_at_price) so the journey never breaks.
  6. QA with real event examples from your store (high AOV cart, low AOV cart, full price, discounted items, returning customer).
  7. Launch with a holdout or A/B split so you can prove lift (personalized vs. standard) before expanding the logic to other flows.

When Should You Use This Feature

Personalize actions with JavaScript in Customer.io is the right move when you need flexible decisioning that directly affects conversion rate, margin, or repeat rate.

  • Cart and checkout recovery: Tier incentives by cart value and margin, or suppress discounts for customers who reliably convert without one.
  • Product discovery journeys: Swap creative and product blocks based on the last category viewed (skin care vs. hair care) and show the right bundle.
  • Post-purchase upsell and replenishment: Compute “next best offer” based on what was purchased (refill, complementary product, or subscription prompt).
  • Reactivation: Choose winback angle based on prior purchase category and time since last order (new arrivals for fashion, replenishment reminder for consumables).

Operational Considerations

Personalize actions with JavaScript in Customer.io gets powerful fast, but it also becomes a source of hidden complexity if you do not treat it like production logic.

  • Data contracts: Lock down event schemas (especially cart and order events). If your ecommerce platform changes field names, your personalization can silently degrade.
  • Segmentation alignment: Do not compute values that conflict with your segments (for example, a “no-discount” segment that still receives a computed coupon).
  • Orchestration across channels: Use the same computed variables in email and SMS so customers do not see mismatched offers.
  • QA and monitoring: Build a small library of test profiles and event payloads, and re-run them anytime you change catalog structure, pricing, or promo rules.
  • Performance and maintainability: Keep expressions readable. If the logic is turning into a mini app, move it upstream (CDP, warehouse, or middleware) and pass clean attributes into Customer.io.

Implementation Checklist

Personalize actions with JavaScript in Customer.io is easiest to scale when you standardize inputs, outputs, and QA early.

  • Cart and order events include item arrays with SKU, price, compare_at_price, category, and product URL
  • Customer profile includes basics for decisioning (orders_count, last_order_date, LTV, discount_used_count)
  • Defined output variables (incentive_tier, offer_code, hero_sku, recos) with clear fallback values
  • Message templates reference the computed variables consistently across email and SMS
  • Holdout or A/B test is configured to measure lift and margin impact
  • QA plan covers edge cases (empty cart, single item, out of stock, international shipping)
  • Documentation exists for the logic so future promo changes do not break journeys

Expert Implementation Tips

Personalize actions with JavaScript in Customer.io performs best when the logic is tied to a specific business rule you can defend, not “more personalization” for its own sake.

  • In retention programs we’ve implemented for D2C brands, the biggest win is usually incentive governance. Start by computing who should not get a discount, then selectively add incentives only where it increases incremental conversion.
  • Use JavaScript to compute a single source of truth for offer selection (like an incentive tier), then let creative vary around it. That keeps your margin strategy consistent even as you test subject lines and layouts.
  • For replenishment brands, compute days_to_replenish from last order and product type, then trigger messaging when customers are most likely to need the product again. This often beats generic “come back” winbacks.
  • Keep a “promo calendar override” input (like a customer attribute or object) so you can quickly change logic during major moments (BFCM, end-of-season) without editing every workflow.

Common Mistakes to Avoid

Personalize actions with JavaScript in Customer.io can backfire when teams ship logic without guardrails or measurement.

  • Over-discounting by default: If your expression returns a coupon when data is missing, you will leak margin. Default to no incentive, then add incentives intentionally.
  • Ignoring channel consistency: Email shows “Free Shipping” while SMS shows “10% off” because each message computed its own logic. Compute once and reuse variables.
  • Not handling nulls and empty arrays: Real event payloads are messy. One missing field can break product blocks or create blank copy.
  • Hard-coding SKUs and categories: Catalogs change. Use category tags or product metadata instead of brittle SKU lists when possible.
  • No lift measurement: Without a holdout, personalization can look good while simply shifting conversions earlier or cannibalizing full-price purchases.

Summary

Use JavaScript personalization when you need dynamic decisions that impact conversion, incentives, and product recommendations. It matters most in cart recovery, post-purchase upsells, and reactivation where small logic changes compound into revenue lift. Build it cleanly in Customer.io so it stays maintainable as your promos and catalog evolve.

Implement with Propel

Propel can help you design the decision logic, validate your event data, and deploy JavaScript-powered personalization in Customer.io without creating a brittle mess. If you want a working plan for your highest-leverage journeys, 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