Skip to main content

How Are Events Tracked?

Manually track user actions in FlagSync via the track() function, providing the core data that all Metrics rely on for analysis.
client.track(
  eventKey: string,
  eventValue?: number | null,
  properties?: Record<string, any> | null
);

Tracking Event Types

There are two types of events:

Numeric Events

Use eventValue to capture measurable data like time or counts for Numeric Metrics:
// Track page load time in seconds
client.track('page_load_time', 1.42);

Why

Perfect for metrics like “Average Page Load Time”—tracks quantifiable outcomes for analysis.

Use Case

Test if a feature slows or improves your app—send this event, then review the average in Metrics.

Example

A developer might track load times across a new UI—e.g., 1.42s—to ensure performance holds.

Property Events

Use properties to capture rich context like purchase details for detailed Numeric Metrics:
const purchase = {
  productId: '0x123',
  price: 49.99,
  discount: 0.20,
  isReturningUser: true,
};

client.track('purchase_event', null, purchase);

Why

Allows the creation of multiple Numeric Metrics (e.g., “Average Purchase Price” from price, “Discount Usage” from discount) from one purchase_event.

Use Case

Test if a feature increases purchase amounts or targets returning users—analyze in Metrics.

Example

Track a purchase_event to check if a 20% discount boosts $49.99 purchases or engages returning buyers.
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 for more detail.

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 before defining metrics.

Next Steps

I