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

# Tracking Events

> Capture user actions in FlagSync with Numeric and Property events.

## How Are Events Tracked?

Manually track user actions in FlagSync via the `track()` function, providing the core data that all [Metrics](/metrics/overview) rely on for analysis.

```typescript theme={null}
client.track(
  eventKey: string,
  eventValue?: number | null,
  properties?: Record<string, any> | null
);
```

## Tracking Event Types

There are two types of events:

<CardGroup>
  <Card title="Numeric" icon="hashtag" href="#numeric-events">
    Captures measurable data like time or counts.
  </Card>

  <Card title="Property" icon="brackets-curly" href="#property-events">
    Captures rich context like purchase details.
  </Card>
</CardGroup>

### <Icon icon="hashtag" size={24} /> <span class="inline-block pl-2">Numeric Events</span>

Use `eventValue` to capture measurable data like time or counts for [Numeric Metrics](/metrics-numeric/overview):

```typescript theme={null}
// Track page load time in seconds
client.track('page_load_time', 1.42);
```

<Steps>
  <Step title="Why" icon="circle-info">
    Perfect for metrics like "Average Page Load Time"—tracks quantifiable outcomes for analysis.
  </Step>

  <Step title="Use Case" icon="flask">
    Test if a feature slows or improves your app—send this event, then review the average in Metrics.
  </Step>

  <Step title="Example" icon="memo">
    A developer might track load times across a new UI—e.g., 1.42s—to ensure performance holds.
  </Step>
</Steps>

### <Icon icon="brackets-curly" size={24} /> <span class="inline-block pl-2">Property Events</span>

Use `properties` to capture rich context like purchase details for detailed [Numeric Metrics](/metrics-numeric/overview):

```typescript theme={null}
const purchase = {
  productId: '0x123',
  price: 49.99,
  discount: 0.20,
  isReturningUser: true,
};

client.track('purchase_event', null, purchase);
```

<Steps>
  <Step title="Why" icon="circle-info">
    Allows the creation of multiple [Numeric Metrics](/metrics-numeric/overview) (e.g., "Average Purchase Price" from `price`, "Discount Usage" from `discount`) from one `purchase_event`.
  </Step>

  <Step title="Use Case" icon="flask">
    Test if a feature increases purchase amounts or targets returning users—analyze in [Metrics](/metrics/overview).
  </Step>

  <Step title="Example" icon="memo">
    Track a `purchase_event` to check if a 20% discount boosts \$49.99 purchases or engages returning buyers.
  </Step>
</Steps>

<Tip>
  Why not just use `price` as the `eventValue`?

  Properties let you track one `purchase_event` and create separate metrics for `price`, `discount`, or other keys—more flexibility than a single number.

  See [Metric Examples](/metrics-numeric/examples) for more detail.
</Tip>

## Best Practices

* **Name Clearly**: Use descriptive event keys (e.g., `signup-cta-click`) to match metrics.
* **Limit Data**: Include only relevant properties (e.g., `price`, `discount`) to avoid clutter.
* **Validate Early**: Check events in [Live Events](/events/live-tail) before defining metrics.

## Next Steps

* Learn basics in [Events Overview](/events/overview).
* Explore live tracking in [Live Events](/events/live-tail).
* Define metrics in [Quickstart: Define Metrics](/quickstarts/metrics) or explore in [Metrics](/metrics/overview).
