Sync customers from Stripe to Customer.io

Updated

Use Customer events from Stripe to trigger an automation syncing customers from Stripe with leads in Customer.io. Then you can send them messages in Customer.io!

Customer.io is great for tracking leads and sending profiles messages. Stripe is great for managing customer and purchase data. With this process, you’ll capture Stripe’s customer.created event in Customer.io to represent profiles that have become customers. From here you might do things like thank profiles for making their first purchase or offer them coupons!

 This process works for other Stripe events

This tutorial is based on customer events, but after you sync customer data between Stripe and Customer.io, you can easily adapt this process to things like dunning emails based on Stripe’s invoice.payment_failed event or other use cases!
sequenceDiagram participant A as Lead/Customer participant B as Stripe participant C as Customer.io A->>B: Signs up for subscription B->>C: Webhook containing subscription trigger C->>C: Identify profile C->>C: Convert webhook to event
that triggers automation C->>A: Send messages (Welcome to our service!)

Why would I sync Stripe customers to profiles in Customer.io?

Imagine that you manage leads in Customer.io. People give you their email addresses indicating that they’re interested in your service, and you might send them promotional messages to get them to make their first purchase, subscribe to your service, and so on. When they become customers, as marked by a purchase in Stripe, you’ll probably want to sync their data to Customer.io—because you’ll send them different automations depending on whether they’re leads or customers.

When someone becomes a customer, you’ll send a Stripe webhook called customer.created to Customer.io. This event includes the customer’s Stripe ID and their email! We’ll use the email from the event to find and update the right profile in Customer.io—or create a new profile if we can’t find a profile matching the email from the incoming event. This effectively syncs our Stripe audience with our Customer.io audience so we can differentiate between leads and customers.

We can also send follow-up events from Stripe that trigger automations in Customer.io. For example, you might send your customers messages through Customer.io when a customer’s subscription is about to renew or when a payment fails in Stripe!

sequenceDiagram participant a as Person participant b as Customer.io participant c as Stripe a->>b: Fills out a form
and becomes a lead b->>a: Send automation
encouraging conversion a->>c: Person converts to customer/subscriber/user c->>b: customer.created webhook b->>b: Webhook-triggred automation sets id on profile note over a,c: Profile is now identifiable by both stripe ID and email

Before you begin

You’ll need access to your Stripe account and your Customer.io Site ID and API Key credentials. You can find your Customer.io Site ID and API Key credentials under Integrations > Customer.io API.

This process assumes that you track leads in customer.io by email address and use their Stripe customer ID as their ID in Customer.io. Profiles that have an ID are customers who’ve made a purchase; profiles without an ID are leads who you want to convert.

As a part of this guide, you’ll set up a webhook-triggered automation using Stripe’s Connect Webhook feature to send customer.created events to Customer.io. We’ll use these events to find a profile in Customer.io by their email address and set their ID to the Stripe customer ID.

{
  "id": "cus_NffrFeUfNV2Hib",
  "object": "customer",
  "address": null,
  "balance": 0,
  "created": 1680893993,
  "currency": null,
  "default_source": null,
  "delinquent": false,
  "description": null,
  "discount": null,
  "email": "wile.e.coyote@example.com",
  "invoice_prefix": "0759376C",
  "invoice_settings": {
    "custom_fields": null,
    "default_payment_method": null,
    "footer": null,
    "rendering_options": null
  },
  "livemode": false,
  "metadata": {},
  "name": "Wile E Coyote",
  "next_invoice_sequence": 1,
  "phone": null,
  "preferred_locales": [],
  "shipping": null,
  "tax_exempt": "none",
  "test_clock": null
}

Set up your webhook-triggered automation

This workflow will identifyThe Customer.io operation that adds or updates a person. When you identify a person, Customer.io either adds a person if they don’t exist in your workspace, or updates them if they do. Before you identify someone (by their email address or an ID), you can track them anonymously. profiles and apply a Stripe ID to their profile. This gives you a way to represent leads and conversions in Customer.io, and syncs your audience from Stripe to Customer.io if someone makes a purchase without becoming a lead in Customer.io first. If you use your Stripe ID as the ID in Customer.io, you can easily differentiate between leads and customers and send them different messages.

  1. Go to Automations and click Create Automation.

  2. Click the trigger block then choose Webhook.

    the trigger exposes a webhook URL
    the trigger exposes a webhook URL

  3. Copy the Webhook URL.

  4. In Stripe, go to Developers > Webhooks and click Add endpoint.

    1. Paste your Webhook URL into the Endpoint URL field.
    2. Click Select events, select Customer > customer.created, and then click Add events. This tells Stripe to trigger your webhook when someone creates a new subscription.
    3. Click Add endpoint.
    4. Turn Test mode on, if it isn’t already, and then Send a test event. This provides Customer.io with some test values that you can reference when creating your automation.
      Set up your webhook in Stripe
      Set up your webhook in Stripe
  5. Return to Customer.io and make sure that you received test data. If so, click Save and build workflow.

  6. Drag a Create or update profile block into your workflow and click it. Set the Name of the action to Identify customer.

  7. Click Add Details.

  8. Under Find or create profile, make sure that email is selected and then click the data.email property in the Trigger data. This identifies your new profile by their Stripe email.

  9. Under Edit attributes set an attribute called id where the Trigger attribute is data.id.

  10. Click Save Changes.

    Create or update your stripe customer
    Create or update your stripe customer

  11. Click Save Changes and finish setting up your webhook-triggered automation.

Remember, this is just one way you can use Stripe data in Customer.io. Now that profiles in Customer.io have a Stripe ID, you can pull in other events from Stripe and use them to trigger automations in Customer.io.

your webhook-triggered automation workflow after you've set up both data events
your webhook-triggered automation workflow after you've set up both data events

What else can I do with Stripe events?

Most Stripe webhooks identify profiles by their Stripe Customer ID. Now that you’ve synced that ID to Customer.io, you can use other Stripe events to trigger automations in Customer.io.

For example, you can capture subscription information, payment schedules, and more. You can use people’s Stripe activity to send messages to your customers based on their purchases, subscription statuses, payment histories, and more!

Copied to clipboard!