Track events
Updated August 20, 2026Events 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 automations, and capture usage metrics in your app.
This page is part of a setup flow for the SDK. Before you continue, make sure you've implemented previous features—i.e. you can't send events before you identify people!
Track a custom event
After you identify a profile, you can use the track method to send events representing their activities to Customer.io. When you send events, you can include event data—information about the profile or the event that they performed.
In Customer.io, you can use events to trigger automations and broadcasts. Those automations might send someone a push notification or manipulate information associated with the profile 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.data(Optional): Additional information that you might want to reference in a message. You can reference data attributes in messages and other workflow actionsA block in an automation 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
in the format{{customer.first_name}}.{{event.<attribute>}}.
import CioTracking
CustomerIO.shared.track(name: "logged_in", data: ["ip": "127.0.0.1"])
// The `data` parameter can be optionally skipped
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", data: data)
// 2. A custom `Encodable` type:
struct Purchase: Encodable {
let product: String
let price: Double
}
CustomerIO.shared.track(name: "purchase", data: Purchase(product: "socks", price: 23.45))
Screen view events
Screen views are events that record the pages that your audience visits in your app. They have a type property set to screen, and a name representing the title of the screen or page that a profile visited in your app.
Screen view events let you trigger automations An automated process people enter when they meet your criteria. An automation has a trigger (who enters, and when), a workflow of messages and actions, and exit criteria (when they leave). A person's path through the workflow is their journey. A group of people who match a series of conditions. People enter and exit the segment automatically when they match or stop matching conditions.
Enable automatic screen tracking
When you enable automatic screen tracking, the SDK sends an event every time a person visits a screen in your app. You can turn on automatic screen tracking in CustomerIO.config.
CustomerIO.config {
$0.autoTrackScreenViews = true
// Optional configuration where you can modify the `data` being sent for
// automatic screenview events.
$0.autoScreenViewBody = {
return ["seconds_on_screen": SecondsOnScreenManager.getTimeInScreen()]
}
}
For automatic screenview tracking, the SDK automatically names the screen as the class name of the UIViewController, minus ViewController. For example, if you have a class EditProfileViewController in your code base, the SDK will automatically send a screenview event with the screen name EditProfile.
If you want to send more data with screen events, or you don’t want to send events for every individual screen that people view in your app, you can disable automatic screen tracking and send screen events manually.
Send your own screen events
Screen events use the .screen method. Like other event types, you can add a data object containing additional information about the event or the currently-identified profile.
import CioTracking
// You can send an event with or without `data`.
CustomerIO.shared.screen(name: "BaseballDailyScores")
// `data` accepts [String: Any] or an `Encodable` object
// 1. [String: Any]:
let data = ["prev_screen": "homescreen", "seconds_in_app": "120"]
CustomerIO.shared.screen(name: "BaseballDailyScores", data: data)
// 2. A custom `Encodable` type:
struct Screen: Encodable {
let prevScreen: String
let secondsInApp: Int
}
CustomerIO.shared.screen(name: "BaseballDailyScores", data: Screen(prevScreen: "homescreen", secondsInApp: 120))