Campaign for new subscribers with Stripe

Updated

Use subscription events from Stripe to trigger a campaign welcoming new subscribers to your service.

As a part of this process, you’ll trigger a campaign when someone signs up for a subscription (a subscription_schedule.created event). You’ll use this incoming data to identify your new subscriber and send an event to trigger a welcome campaign to your new subscriber.

 This process works for other Stripe events

This tutorial is based on subscription events, but you could just as easily adapt it to send dunning emails based on Stripe’s invoice.payment_failed event or other use cases!

sequenceDiagram participant A as Subscriber participant B as Stripe participant C as Customer.io A->>B: Signs up for subscription B->>C: Webhook containing subscription trigger C->>C: Identify person C->>C: Convert webhook to event
that triggers campaign C->>A: Send messages (Welcome to our service!)

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 Data & Integrations > Integrations > Customer.io API.

As a part of this guide, you’ll:

  1. Set up a webhook-triggered campaign using Stripe’s Connect Webhook feature to capture a response from Stripe when someone creates a subscription—represented by the subscription_schedule.created event below.
  2. Set up an event-triggered campaign using the Stripe event to message people about their new subscription.
{
  "id": "sub_sched_1Jydf3JRq3BWBpoSiD8FYI62",
  "object": "subscription_schedule",
  "canceled_at": null,
  "completed_at": null,
  "created": 1637591905,
  "current_phase": null,
  "customer": {
      "id": "customers-id-here",
      "email": "person@example.com"
  },
  "default_settings": {
    "application_fee_percent": null,
    "automatic_tax": {
      "enabled": false
    },
    "billing_cycle_anchor": "automatic",
    "billing_thresholds": null,
    "collection_method": "charge_automatically",
    "default_payment_method": null,
    "invoice_settings": null,
    "transfer_data": null
  },
  "end_behavior": "release",
  "livemode": false,
  "metadata": {},
  "phases": [
    {
      "add_invoice_items": [],
      "application_fee_percent": null,
      "billing_cycle_anchor": null,
      "billing_thresholds": null,
      "collection_method": null,
      "coupon": null,
      "default_payment_method": null,
      "default_tax_rates": [],
      "end_date": 1669646305,
      "invoice_settings": null,
      "items": [
        {
          "billing_thresholds": null,
          "price": "price_1Jyd0G2eZvKYlo2CgSUwG9P3",
          "quantity": 1,
          "tax_rates": []
        }
      ],
      "proration_behavior": "create_prorations",
      "start_date": 163819670
      5,
      "transfer_data": null,
      "trial_end": null
    }
  ],
  "released_at": null,
  "released_subscription": null,
  "status": "not_started",
  "subscription": null
}

 Capture your audience’s email in subscriptions!

The customer value in a Stripe event can be a string containing a person’s ID, or an object containing multiple identifiers (id, email, etc) depending on the information you gather from a person. Capturing a person’s email lets you use Stripe as a single source to identify and message people as a part of this tutorial.

Set up your webhook-triggered campaign

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. people and convert incoming subscription_status.succeeded events—sent when someone subscribes to your service—to Customer.io events. Later, we’ll use these events to trigger a campaign that messages your new subscribers and assigns them an ID if they don’t already have one.

  1. Go to Campaigns and click Create Campaign.

  2. Select Data arrives via webhook and copy the Webhook URL.

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

  3. 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 Supscription Schedule > subscription_schedule.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 campaign.
      Set up your webhook in Stripe
      Set up your webhook in Stripe
  4. Return to Customer.io and make sure that you received test data. If so, click Save & Next.

  5. In the Workflow step, use the Create or Update Person action to add or update a person in Customer.io
    1. Drag Create or update person into your workflow and click it. Set the Name of the action to Identify subscriber.

    2. Click Add Details

    3. Under Find or create person, make sure that id is selected and then click the .data.object.customer.id property in the Trigger data. This identifies your new person by their Stripe id.

    4. Under Edit attributes, set attributesA key-value pair that you associate with a person or an object—like a person’s name, the date they were created in your workspace, or a company’s billing date etc. Use attributes to target people and personalize messages. Attributes are analogous to traits in Data Pipelines. from your Stripe event. In this example, you must set the email attribute.

    5. Click Save Changes.

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

  6. Drag a Create Event block in your workflow. This converts your incoming Stripe data to a Customer.io event that will trigger your “New Subscriber” campaign.
    1. Set the Event Name to New subscriber event and click Configure event.

    2. Under Find or add person, select id and click the id value in in your Trigger data.

    3. For the Event Name, set a Static value to New subscriber.

    4. Under Event Attribute, add an attribute called start_date and click the Trigger attribute called start_date in your trigger data.

    5. Click Save Changes. Now you’re ready to set up your campaign to message people who responded to your NPS survey!

    create an event to trigger a campaign to new subscribers as indicated by stripe
    create an event to trigger a campaign to new subscribers as indicated by stripe

  7. Click Save Changes and finish setting up your webhook-triggered campaign. Now you’re ready to set up your campaign to message people who responded to your NPS survey!

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

Set up your event-based campaign

Now you can trigger a campaign to send messages to new subscribers using the Stripe Subscription Created event you set up in your webhook-triggered campaign.

 Tag your campaigns

In this tutorial, you need two campaigns to achieve your goal. If you apply a tag to both your webhook-triggered and event-based campaigns, you can easily relate your campaigns and find them on the Campaigns page.

  1. Go to Campaigns and click Create Campaign.

  2. Click A person performs an event. Under Define the trigger event, enter stripe-subscription-created and set additional filters. For this case, we only care that they’re creating a subscription, but we might want to limit the campaign Frequency, in case a person has cancelled and restarted their subscription over a short period.

    set up an event trigger based on your webhook-triggered campaign
    set up an event trigger based on your webhook-triggered campaign

  3. In your workflow, add messages. You can access properties from the incoming event using liquidA syntax that supports variables, letting you personalize messages for your audience. For example, if you want to reference a person’s first name, you might use the variable {{customer.first_name}}. in the event object—i.e. {{event.<property>}}.

  4. When you’re finished, click Save & Next, and finish configuring your campaign. Now, when someone subscribes to your service, you can identify them and start them on a campaign!

Copied to clipboard!
  Contents
Is this page helpful?