# Event tracking

Track what your users do in your product, with properties, so you can trigger surveys and messages on their actions.

Track the actions your users perform: a plan upgrade, a product added to the cart, an export. In Screeb, you then target surveys and messages on these events, for example on how many times a user did it or when they last did it. What events are on the Screeb side is explained in [Understanding user events](https://help.screeb.app/user-data/user-events/).

## Track an event

```swift
import Screeb

Screeb.trackEvent(name: "plan_upgraded")
```

Event names are less than 128 characters. They contain letters, digits, spaces and the characters `-`, `_`, `.`, `/` and `:`. Keep each name stable: a renamed event is a new event for Screeb.

## Add properties to an event

Properties give the context of the event. You can use them in targeting rules and as hidden fields in your surveys.

```swift
Screeb.trackEvent(name: "Product added to cart", trackingEventProperties: [
    "product_name": "Red bike 2021",
    "category": "sport",
    "price": 299,
    "count": 1,
    "user_logged": false,
    "added_at": ISO8601DateFormatter().string(from: Date()),
])
```

An event has at most 1000 properties. Property names are 128 characters at most. Values are strings, numbers, booleans or dates.

On iOS and with Kotlin Multiplatform, send dates as ISO 8601 strings.

> [!NOTE]
> Screeb ignores events while [consent exemption](https://developers.screeb.app/sdk-ios/consent-exemption) is on for the workspace.

## Next steps

- [Track screens](https://developers.screeb.app/sdk-ios/screen-tracking) to target surveys on the pages or screens your users visit.
- [Assign users to groups](https://developers.screeb.app/sdk-ios/group-assignation) to target a company, a team or a plan.
