> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clix.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Event Tracking

> Event tracking in the Clix SDK allows you to capture user actions and enrich them with meaningful properties, enabling events to drive campaign triggers, audience filters, and ongoing behavior insights.

For API usage, see the Clix SDK GitHub repositories for each platform:

* [iOS](https://github.com/clix-so/clix-ios-sdk#event-tracking)
* [Android](https://github.com/clix-so/clix-android-sdk#event-tracking)

## When to Track Events

<Steps>
  <Step title="Identify the user action">
    Decide which user interaction or system event to track—for example, button
    taps, feature milestones, or funnel checkpoints.
  </Step>

  <Step title="Attach meaningful properties">
    Attach key-value properties that provide relevant details about the event
    (e.g., plan type, screen name, experiment variant).
  </Step>
</Steps>

***

## Example Usage

```swift theme={null}
Clix.trackEvent(
  "signup_completed",
  properties: [
    "method": "email",
    "discount_applied": true,
    "trial_days": 14,
    "completed_at": Date()
  ]
)
```

***

## Property Types and Formatting

`properties` accepts a key/value map. The SDK normalizes values before sending them:

* Booleans, numbers, and strings map directly to JSON primitives.
* Date-like values are serialized to ISO 8601 strings (`2024-05-16T09:30:00Z`).
* Unsupported objects default to a string representation. Prefer serializable primitives to keep reporting clean.

***

## Error Handling

Event tracking calls can throw errors. Always handle errors for robust apps:

```swift theme={null}
do {
  try await Clix.trackEvent(
    "signup_completed",
    properties: [
      "method": "email",
      "discount_applied": true,
      "trial_days": 14,
      "completed_at": Date()
    ]
  )
} catch {
  print("Failed to track event: \(error)")
}
```
