GitHub project

Track events

Events 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!

graph LR getting-started(Install SDK) -->B(Initialize SDK) B --> identify(identify people) identify -.-> track-events(Send events) identify -.-> push(Receive push) identify -.-> rich-push(Receive Rich Push) track-events --> test-support(Write tests) push --> test-support rich-push --> test-support identify -.-> in-app(Receive in-app) in-app --> test-support click getting-started href "/integrations/sdk//getting-started/#install" click B href "/integrations/sdk//getting-started/#initialize-the-sdk" click identify href "/integrations/sdk//identify" click track-events href "/integrations/sdk//track-events/" click push href "/integrations/sdk//push" click rich-push href "/integrations/sdk//rich-push" click in-app href "/integrations/sdk//in-app" click test-support href "/integrations/sdk//test-support" style track-events fill:#B5FFEF,stroke:#007069

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. You can reference the data in your event to segment members of your audience or as variables in your messages using liquid.

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.
  • attributes (Optional): The body of the event. You can reference attributes in messages and other workflow actions using liquid in the format {{event.<attribute>}}.
CustomerIO.instance().track(
  name = "purchase",
  attributes = mapOf("product" to "socks", "price" to "4.99")
)

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 or add profiles to segments based on the parts of your app your audience uses. Screen view events also update your audience’s “Last Visited” attribute, which can help you track how recently profiles used your app.

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 by appending autoTrackScreenViews(true) to CustomerIO.Builder.

When automatically tracking screen events, we capture the name of the screen with the following priority from highest to lowest:

  1. We check if the current Activity has a label in the manifest file. If it does, the SDK will use the value for label.
  2. We get the class name of the Activity and use that value.

The SDK will take whatever value it receives and will strip the word Activity from it. Example: If you have an Activity with the manifest label or class name ProfileActivity, the SDK will track the screen view with the name Profile.

CustomerIO.Builder(
  siteId = "your-site-id",
  apiKey = "your-api-key",
  appContext = this
)
.autoTrackScreenViews(true)
.build()

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 send screen events manually.

Send your own screen events

Screen events use the .screen method. Like other events, you can add a map of attributes object containing additional information about the screen event or the currently-identified profile.

CustomerIO.instance().screen(
  name = "baseballDailyScores",
  attributes = mapOf("prevScreen" to "homescreen", "secondsInApp" to "120")
)
Updated August 20, 2026