Create event action

You can convert the incoming webhook for a data campaign into an event associated with a person—in any workspace within your account. This makes it easy to trigger campaigns or add people to segments based on things that happen outside of Customer.io without having to talk to a developer and write your own integration.

How it works

Data campaigns start with arbitrary data from an incoming webhook. This data isn’t associated with a person, and it can take any shape.

When you create a data campaign, you trigger your campaign based on an incoming webhook. You need to associate it with a person and re-shape your incoming data to a format that Customer.io recognizes—so that you can trigger campaigns, add people to segments, etc. This shape is called an event!

The Create Event action makes it easy to generate an event from your incoming webhook data, so that you can trigger other campaigns and organize segments as a part of your data campaign. This action even lets you send an event to another workspace, making it easy to manage people and events across your workspaces.

sequenceDiagram participant A as Person participant B as External System participant C as Customer.io A->>B: Does something B->>C: Incomming webhook C->>C: Create event C-->>C: Add person to segment C-->>C: Trigger campaign C-->>A: Response message (Optional "Thanks for your response!")

The Create Event action

To create an event, your incoming webhook must contain a value that you use to identify people. When you create an event, you associate a value in your incoming webhook with an identifierThe attributes you use to add, modify, and target people. Each unique identifier value represents an individual person in your workspace. for people in one of your workspaces. If a person with this identifier doesn’t already exist, this action will add them to your workspace.

  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

Handling nested or complex data

When you create an event, you’ll provide an Event Data section—a data object—containing values you might want to use to:

While you can pass the entirety of your incoming webhook on as event data using {{trigger | to_json}}, you may want to simplify your event so that it only contains the data that you want to use in Customer.io.

For example, if we want to use a property from our incoming webhook called deeply.nested.thing in our event, we can map that property to sit within the data object like this:

Incoming webhook Event
{
    "deeply": {
        "nested": {
            "thing": "my-event-attribute"
        }
    }
}
{
    "name": "example",
    "data": {
        "thing": "{{trigger.deeply.nested.thing}}"
    }
}

Use data in complex arrays

If your webhook contains arrays of objects, and you want to access individual properties within the array, you’ll need to use liquid with the Custom value or JSON editor to pass them to your event.

For example, we’ll use this array of items representing someone’s purchase receipt.

{
    "items": [
        {
            "name": "socks",
            "qty": 2,
            "sku": 123456,
            "coupon": null,
            "price": 9.99
        },
        {
            "name": "sandals",
            "qty": 1,
            "sku": 789012,
            "coupon": "socks-n-sandals",
            "price": 24.99
        }
    ],
    "total": 34.98
}

You could add the entire array of objects to your event by specifying the items property.

{
    "name": "purchase",
    "data": {
        "items": {{trigger.items | to_json}}
    }
}

However, this may make for a complicated event with information that isn’t relevant to your person in Customer.io. You may want to keep a few specific properties so that it’s easier to read your event in Customer.io and use it to segment people or personalize messages.

For example, you might want to capture the names of the products your customer purchased. You can access the name of the first item in the cart at items[0].name. You can capture all of the product names a person purchased using a for loop!

{
    "name": "purchase",
    "data": {
        "items_purchased": [{% for item in trigger.items %}"{{name}}",{% endfor %}]
    }
}

For more information about available liquid tags and manipulating your incoming webhook data, see our liquid tag list.

Copied to clipboard!