Track events
UpdatedEvents represent things people do in your app so that you can track your audience’s activity and metrics. Use events to segment your audience, trigger campaigns, and capture usage metrics in your app.
Track an event
The track
method helps you send events representing your audience’s activities to Customer.io. When you send events, you can include event data
—information about the person or the event that they performed.
In Customer.io, you can use events to trigger campaigns and broadcasts. Those campaigns might send someone a push notification or manipulate information associated with the person in your workspace.
Events include the following:
name
: the name of the event. Most event-based searches in Customer.io hinge on the name, so make sure that you provide an event name that will make sense to other members of your team.properties
(Optional): Additional information that you might want to reference in a message. You can reference data attributes in messages and other campaign actionsA block in a campaign workflow—like a message, delay, or attribute change. 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 format{{event.<attribute>}}
.
import CioDataPipelines
CustomerIO.shared.track(name: "logged_in", properties: ["ip": "127.0.0.1"])
// You don't need to send `data`
CustomerIO.shared.track(name: "played_game")
// `data` accepts [String: Any] or an `Encodable` object
// 1. [String: Any]:
let data = ["product": "socks", "price": "23.45"]
CustomerIO.shared.track(name: "purchase", properties: data)
// 2. A custom `Encodable` type:
struct Purchase: Encodable {
let product: String
let price: Double
}
CustomerIO.shared.track(name: "purchase", properties: Purchase(product: "socks", price: 23.45))
Perform downstream actions with semantic events
Some downstream actions don’t neatly map to our simple identify
, track
, and other calls. For these, we use “semantic events,” events that have a special meaning in Customer.io and your destinations. See Semantic Events for more information.
Anonymous activity
If you send a track
call before you identify
a person, we’ll attribute the event to an anonymousId
. When you identify the person, we’ll reconcile their anonymous activity with the identified person.
When we apply anonymous events to an identified person, the previously-anonymous activity becomes eligible to trigger campaigns in Customer.io.
Semantic Events
Some actions don’t map cleanly to our simple identify
, track
, and other calls. For these, we use “semantic events,” events that have a special meaning in Customer.io and your destinations.
These are especially important in Customer.io for destructive operations like deleting a person. When you send an event with a semantic event
name, we’ll perform the appropriate action.
For example, if a person decides to leave your service, you might delete them from your workspace. In Customer.io, you’ll do that with a Delete Person
event.
CustomerIO.shared.track(name: "Delete Person")