Data Campaigns

Data campaigns let you use your data in Customer.io, without having to reshape it using Zapier or another product first. Where our traditional workflows trigger based on a person, a data campaign lets you start a campaign when you receive data (in any shape) from a specific source.

How it works

Normally, you trigger campaigns when a person performs an event or meets some criteria you set. Data campaigns let you use webhooks to trigger workflows when you receive data from an external source. This video helps explain how it works:

When you set up a data campaign, Customer.io will generate a Webhook URL. You’ll provide this URL to the service or platform that you capture data from. And you’ll set up rules determining when that service or platform will call your webhook, sending data to Customer.io. The data that your service or platform sends to Customer.io can take any JSON shape; as a part of your workflow, you’ll transform the incoming data to fit your needs.

You might use a data campaign to capture data from an external service and convert it to:

  • An event that triggers a campaign to send messages in Customer.io. This is the most common use case.
  • An attributeA key-value pair that you associate with a person—like their name, the date they were created in your workspace, etc. Use attributes to target people and personalize messages. update for a person.
  • Another service—using Customer.io as a bridge between data platforms, like what Zapier and Segment do!
sequenceDiagram Participant A as Incoming service Participant B as Customer.io Participant C as Person C->>A: Person does something in your system A->>B: Trigger webhook rect rgb(229, 254, 249) Note over B,C: Update attributes B->>B: Identify person with webhook data end rect rgb(255, 242, 248) Note over B,C: Send messages with
the Create Event Action B->>B: transform webhook data to event B->>C: event triggers campaign end

Create a data campaign

As a part of campaign setup, you’ll receive a webhook URL that you need to provide to the external service that you want to capture data from. Before you begin, make sure that you have access to the service you want to capture data from, and that that service can send webhooks.

  1. Go to Campaigns and click Create Campaign.

  2. Select Data arrives via webhook.

    the data campaign trigger exposes a webhook URL
    the data campaign trigger exposes a webhook URL

  3. Copy the Webhook URL and provide it to your external service. If possible, trigger the webhook; this sends representative data that you can use when setting up your campaign.

  4. Click Save & Next

  5. Set up your workflow. In general, you’ll use the Send data option to transform your data as a request to another service—see the following sections to update a person’s attributes or trigger a message campaign

    Set up your workflow actions to transform data
    Set up your workflow actions to transform data

  6. Review your workflow and Save.

 You can send Slack notifications in a data campaign!

Because you trigger a data campaign with data that isn’t attached to a person in Customer.io you can’t use most message types in a data campaign—you’d have nobody to send them to!

However, because Slack messages typically have a static destination—a channel or a specific DM—you can trigger a slack message. This provides a way to notify a group of people via Slack when you trigger your workflow.

Trigger a messaging campaign from a data campaign

If your data campaign’s incoming JSON contains an identifierThe attributes you use to add, modify, and target people. Each unique identifier value represents an individual person in your workspace.—like an email or ID—your data campaign can send translate your incoming data to an event that triggers a messaging campaign. You’ll do this using the Send data action (commonly known as a webhook) to call the track API.

Before you get started, make sure that you have your Site ID and API Key. You’ll need these to complete this process.

  1. Drag Create Event into your data campaign workflow and click it.
  2. Give the action a name, and then click Configure event to set up your event.
    Add a create event action to your data campaign
    Add a create event action to your data campaign
  3. Find or add person: These settings determine the person your new event represents.
    1. Select the workspace containing the people you want to represent with this event.
    2. Select the type of identifier and incoming webhook value that represent people for your event.
  4. Set the Event Name. This is the name value in the event, and the way you’ll reference this event in campaign triggers, segments, etc.
  5. Add Event Attributes. These are the values that appear in the data object; you’ll target event attributes in campaigns using {{ event.<event-attribute> }}. You can map event attributes to properties from your incoming webhook (known as Trigger attributes), or enter a custom value.
  6. Click Done.
    Convert your incoming data to an event
    Convert your incoming data to an event
  1. Click Save & Next and finish configuring your data campaign.

  2. Set up a new People Campaign, with the trigger set to They perform an event using the event name you set in previous steps. Configure this campaign with the message(s) that you want to send to the person represented by the event you set up in your data campaign.

Now, data coming into your data campaign is converted to an event that triggers a campaign!

Update a person’s attributes

If your data campaign’s trigger contains an identifierThe attributes you use to add, modify, and target people. Each unique identifier value represents an individual person in your workspace.—like an email or ID—you can update a person’s attributesA key-value pair that you associate with a person—like their name, the date they were created in your workspace, etc. Use attributes to target people and personalize messages. in Customer.io.

  1. Click and drag Send data into your workflow.

  2. Click the Webhook block that you just added to your workflow and then click Add Request.

  3. In the URL, enter https://{site_id}:{api_key}@track.customer.io/api/v1/customers/{{trigger.identifier}}/identify where:

    • identifier is the field in your incoming data object that contains the email or ID of a person in your workspace.
    • {site_id} and {api_key} are your API credentials. Click here if you need help finding your credentials. You can find your Customer.io Site ID and API Key credentials under Data & Integrations > Integrations > Customer.io API.
  4. In the body of your request, set the attributes you want to update for this person. You can access variables in your data campaign’s trigger using {{trigger.<attribute>}}.

    {
      "<attribute>": "{{trigger.<attribute>}}"
    }
    
  5. Click Done and finish configuring your data campaign. Now, when you receive data from your external service, you’ll automatically create or update a person in Customer.io.

Data campaign liquid variables

You can reference properties in your data campaign’s trigger with 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 trigger object.

For example, if you trigger your data campaign from the data below, you would access the product property in liquid using {{trigger.product_name}}.

Remember, when you send a request to the Customer.io API—a track event or an identify request to add or update people—you’ll need to reference an identifierThe attributes you use to add, modify, and target people. Each unique identifier value represents an individual person in your workspace. in the URL of your request in the format {{trigger.identifiers.id}} (using JSON notation to access the identifier).

Incoming data Outgoing event
{
  "name": "purchase",
  "identifiers": {
    "id": "abcd-1234",
    "email": "person@example.com"
  },
  "purchase": {
    "product": "shoes",
    "sku": 1234,
    "qty": 1
  }
}
  
  {
    "name": "{{trigger.name}}",
    "data": 
    {
      "product": "{{trigger.purchase.product}}"
    }
  }
  
Copied to clipboard!