• Recipes
  • Marketing
  • How to deliver personalized lifecycle emails with Segment & Customer.io

How to deliver personalized lifecycle emails with Segment & Customer.io

Marketing B2B Retail Intermediate
This recipe will explain how you can use Segment to collect customer data and then funnel that into Customer.io to create personalized lifecycle email campaigns.
Increase conversions, retention rates, and engagement with personalized lifecycle campaigns
Collect data once with Segment and send it any tool you use. No more tedious integrations. No more engineering resources wasted.
Start with Segment

When customers abandon their online shopping cart, an email can nudge them back to making that purchase. An email can do the same for a user who doesn’t complete the initial tutorial of an app. Even folks who are fully committed to a product can become even more engaged through a personalized message delivered at precisely the right time.

Increasing conversion, retention, and engagement are the main benefits of personalized lifecycle emails—messages tailored to the recipient that provide relevant information at the perfect moment in the customer journey. But, as any marketer who has tried knows, executing such campaigns is challenging.

Your messages need to align with your customer’s actions in your product or platform, with content automatically tailored to different personas. It’s easy to get this personalization wrong by sending an email too early, too late, or to the wrong person. Such mistakes result in churn—lost sales, product abandonment, or unsubscribers.

To get such emails right, you need to collect data across the customer journey that informs when you should send an email, to whom, and with what content. But just capturing such information isn’t enough. You also need to make this data available in real time in a tool that can send out those personalized messages.

This recipe will explain how you can use Segment to collect customer data and then funnel that into Customer.io to create a personalized lifecycle email campaign. We’ll walk you through three main steps on how to:

  1. Collect customer behavior data with Segment.

  2. Plan your email campaign.

  3. Build and activate your campaign in Customer.io.

We’ll use a business-to-business (B2B) Software as a Service (SaaS) use case to walk you through these steps, but you can apply these steps to other sectors like eCommerce.

Step 1: Collect customer behavior data with Segment

To start collecting customer behavior data with Segment, you first need to map out your customer journey. Doing so helps you determine which customer actions to track.

Map out your funnel

Most customer journeys resemble a funnel with several stages, similar to the one pictured below of our B2B SaaS use case. Each phase includes an outcome that defines when the customer has completed that stage of the funnel.

We have identified five main steps our customers go through:

  1. Acquisition: Someone, for example, a website visitor, goes from being a lead to becoming a user by creating an account in our app.

  2. Onboarding: The user has started a free trial of our product by entering their credit card details.

  3. Activation: Our user has completed our product’s tutorial and used the main feature of our product.

  4. Retention: The user regularly engages with more advanced features of our product, like dashboards and reports. They’ve even shared our product with friends.

  5. Revenue: The user has upgraded their account to become a paying customer of our product.

Segment funnel

Create a tracking plan

This breakdown of funnel stages and outcomes forms the foundation of your tracking plan, a detailed overview of the data you’ll need to collect with Segment.

You can capture three types of events with Segment:

  • Page events to register the URL of pages where track and identify events happen.

  • Track events for customer actions, like a button they clicked on a webpage or in your app.

  • Identify events to capture user traits, like their name or email address.

For example, in the first stage of our funnel—Acquisition—we want to make sure our customer created an account. To do so, we want to capture events on the “signup” page, track if they clicked the “sign up” button, and store identify events for their name, email address, and job title.

Tracking-plan

While it’s not necessary for short funnels, usually, it’s a good idea to use a spreadsheet similar to the one above to create a detailed Tracking Plan.

Map out the actions you want to track and the corresponding Segment events for each stage of your funnel. When you’re done, we move on to setting up the actual data collection in Segment.

Set up your source in Segment

Log in to Segment—or create a free account—and navigate to the “Connections” section in the main menu on the left. From there, select the sub-option “Sources.” A Source is any property where you collect data that gets sent into Segment. We run a web-based app in our use case, so we want to add it as a JavaScript Source. You would use this same option for any other web-based service and eCommerce websites.

Segment-sources

Follow these steps to set up your JavaScript Source:

  1. Click the blue “Add Source” button in the Sources overview screen.

  2. Give your source a name, for example, “web-app.”

  3. Copy and paste the code shown on the JavaScript Source overview page into the <head> tag of your site’s pages. 

web app header

Next, let a developer add the events you’ve defined to the elements of your site’s pages. For example, the code for an identify event could look like this: 

analytics snippet

You can find more technical guidance on how to do this here.

Once you have your events set up, go to the “Debugger“ tab of the Sources section. There you can check if the desired data is coming through. It should look like the below screenshot, with a live feed of individual events from each user. 

Debugger

You can also navigate to the “Schema“ tab to check if you’ve set up all events correctly. You should see the total number of users who have completed a specific stage of your funnel, for example, Account Created or Featured Used, like in the screenshot below.

Schema

Add Customer.io as a destination in Segment

Finally, we should add Customer.io as a destination in Segment. Destinations are endpoints where you put your data to use. Segment lets you connect your source with hundreds of cloud applications for a wide variety of use cases. In this recipe, we want our Segment data to flow to Customer.io to send out personalized emails.

Navigate to “Destinations” in the main menu on the left, then click the blue “Add Destination” button. Select Customer.io from the list of partners.

destinations

You’ll now need to paste in the API key from your Customer.io account, which you can find there in the Settings tab. Your data is now ready to use in Customer.io. Segment will continuously update it as new information comes in.

customerio-setup

Step 2: Plan your email campaign

An email campaign usually consists of multiple messages that aim to reach one or more goals, like the outcomes of our funnel stages. In theory, you could cover your entire funnel with one campaign, but, in practice, such a campaign often becomes too complex to plan, build, and monitor. It might span weeks or even months and involve dozens of goals, personas, and branches.

Instead, we recommend you cover your funnel with multiple campaigns so that each spans a short period and serves only one objective. Each campaign could cover one part of the funnel, or you can group stages that are naturally close together or related. In our example, a user should quickly move from Acquisition to Activation through Onboarding—usually in one session. We can cover these stages with one campaign, which we’ll set up in this recipe.

Set the campaign goal and outcome

Once you’ve decided which funnel stages you’ll cover with your campaign, determine its overall goal and a specific outcome that verifies if you’ve achieved your goal. In our use case:

  • Goal: Turn someone who has created an account into an activated user of our product.

  • Outcome: The user has used our product’s main feature.

Usually, the campaign outcome matches the outcome of the final funnel stage our campaign covers. In our case, the campaign outcome is the same as the outcome we’ve defined earlier for the Activation stage of our funnel.

Tailor your campaign to multiple personas

Now, determine if you need to tailor your campaign to multiple personas. These could be people with different roles—say engineers versus marketers—or people at different types of companies—like startup versus enterprise. Each could go through the same funnel but require slightly different content.

Our campaign will target two personas: workspace owners and regular users. These two roles need different emails for each stage of the funnel. Their requirements and the options available to them in our product are slightly different.

Draw a flowchart of your email campaign

Finish planning by drawing a flowchart of your email campaign following these steps:

  1. Determine the initial trigger that activates the campaign. In our case, it’s when someone creates an account.

  2. For each funnel stage’s outcome, define what email gets sent to users who have completed that step versus those who haven’t.

  3. Add where you require separate emails for different personas. In our case, that’s right at the start—after account creation—where we want to send other instructions to workspace owners than to regular users.

Flowchart

 Here’s what our flowchart looks like, with the campaign goal, outcome, and personas listed on the left.

Step 3: Build and activate your campaigns in Customer.io

With your campaign drawn out, you’re ready to set it up in Customer.io so you can start sending emails to your customers.

Check if Customer.io receives your data

Log in to your Customer.io account or start a free trial. We’ll first make sure the data you need for your campaign is coming through from Segment. Go to the “Data & Activity” section in the left main menu of Customer.io, then select “Data Index” and go to the “Events” tab. Here you’ll see which events are available. It should look similar to the below screenshot.

data-index

Use your flowchart to cross-check whether the items you need appear in the “Data Index.” In our case, we want to see info on:

  • Account created.

  • User type.

  • Trial started.

  • Feature used.

Create a segment for each persona

Once you’re sure the right data is coming in, you need to create a segment in Customer.io for each persona so we can later select these when we’re building our campaign. (Note the small “s” of segment, as Customer.io’s name for specific audience groups is the same as our product and company name, Segment with a capital “S.”)

We’ll need to create two segments, one for workspace owners and one for regular users. Do so by following these steps:

  1. Go to the “Segments” section in the main menu on the left, then click the “Create segment” button toward the right top corner of the screen.

  2. In the next screen, name your segment, for example, “Is owner.”

  3. Select “Create data-driven segment,” which takes us to the next screen to define which attributes add someone to a segment.

  4. In our case, we want at least one of the conditions we’re going to specify to be true, so we select “At least one” from the drop-down.

  5. Next, we add a condition that someone’s role attribute should either be “owner” or “admin.” In our example, both these roles qualify someone as a workspace owner. Here you can also include other conditions to build your segment based on the data you’re capturing with Segment. Besides attributes, you can select events, pages, or specific devices to create your segments.

  6. Select “Save changes,” and you’re back at the “Is Owner” segment’s page, where you immediately see how many people qualify based on the conditions you’ve set.

  7. Repeat these steps for any additional personas you’d like to target with your campaign.

name-your-segment

is-owner

attribute

Create your campaign in Customer.io’s campaign builder

With data flowing and our segments set up, we’re ready to create our campaign. Here’s how to do this:

  1. Navigate to the “Campaigns” section in the main menu on the left, then click the “Create campaign” button in the right top.

  2. Give your campaign a name and select “Create Campaign.” This name is for internal reference only and will not be visible to your customers.

  3. We’re now in the first step of campaign creation, “1. Trigger.” Here we indicate which people we’ll add to our campaign.

  4. Select “They meet conditions” and define the trigger condition by selecting they’re in the “Account Created” segment.

  5. Select “Save” in the right top corner of the screen, which takes you to the second step, “Workflow.” This section is a drag-and-drop editor where you’ll design the exact working of your campaign based on the flowchart you made earlier.

  6. Start by dragging in a “True/False Branch” from the left menu that checks the user’s persona type—owner or regular user—after the initial trigger. Select the “True/False Branch” block, then add a condition in the left column that checks whether someone is part of the “Is owner” segment we created earlier.

  7. You now have two branches, the True one representing workspace owners and the False one for regular users. Drag an “Email” block from the right column to the bottom of each branch. Doing this creates a different email for each of these personas.

  8. Select each of these email blocks and give them a unique name in the left panel.

  9. Repeat steps 6-8 to add two more “True/False Branches” that check whether the user has started a trial and whether they’ve used our product’s main feature.

Customerio-conditions trigger-condition image19

customerio-activate

 

Finalize and activate your campaign

Two steps remain before you can activate your campaign and start sending emails:

  • Create the content of your emails. Select an email block in your flow and choose “Add content” in the left column. You can then use the “Drag-and-drop” or “Rich Text” editors to create your content or import your own HTML using the “Code” function.

  • Add time delays to different sections of your campaign. You might send a user too many emails within a short period if they quickly move through your funnel. You can avoid this by dragging a “Time Delay“ element from the left menu into the campaign flow and specifying how long Customer.io should wait before moving to the next step of your campaign.

customerio-startingplace new-user-welcome-customerio

Now your campaign is ready for activation. Follow these final steps:

  1. Go to the “3. Goal & Exit” tab of the campaign builder in Customer.io.

  2. Specify a conversion goal to measure the success of your campaign. Select “Define goal“ and indicate when Customer.io should consider someone converted. In our case, we want a user to reach the end of the Activation stage of our funnel, so we mark someone as converted when they enter the segment “Activated.”

  3. Indicate when users should exit the campaign. You can choose whether every user should complete the campaign from start to finish or add conditions that remove them from the campaign prematurely. In our case, we could add a requirement that exits users who went straight from their free trial to upgrading their accounts. We don’t want to send them emails intended for users on a free trial.

  4. Select “Next” to go to the final “4. Review” step to do a last check on your campaign.

  5. When you’re ready, scroll down to the bottom of the page. Select whether you want to send this campaign to people who are already in your database and match your criteria or only to new additions from this point forward.

  6. Select “Start Campaign,” and that’s it; your emails will start going out to your customers.

define-goal image2

Wrapping up

As a recap, here’s what we’ve done in this recipe:

  • We started collecting customer behavior data on our channels using Segment.

  • We mapped out the flow of our email campaigns, including different branches, for different personas and events.

  • We built the campaign in Customer.io and started sending emails.

Getting your first lifecycle campaign set up involves many steps. Still, once you have your flow worked out in Customer.io, you have a solid foundation to iterate and expand upon to increase customer conversion, retention, and engagement. You can also add additional destinations in Segment without much effort so you can connect the source you’ve set up in this recipe to hundreds of other tools.