Skip to content

Tracking Events

The Analytics Engine allows you to track user behavior, game clicks, payment flows, and custom UI interactions.

The SDK uses a fire-and-forget pattern. You do not need to await the tracking calls, ensuring zero impact on your frontend's performance.

Tracking an Event

Call track() anywhere in your application. Pass an eventName and an optional payload object with any custom data you want to record.

javascript
// Example: Tracking a game tile click in the lobby
sdk.analytics.track('game_tile_click', {
  gameId: 'game_sweet_bonanza',
  position: 'row_1_col_3',
  category: 'SLOTS'
});

// Example: Tracking a deposit initiation
sdk.analytics.track('deposit_initiated', {
  method: 'GCASH',
  amount: 50.00,
  currency: 'PHP'
});

Event Interface

The SDK automatically constructs the final event object sent to the backend.

typescript
interface AnalyticsEvent {
  eventName: string;
  timestamp: string;      // Auto-generated ISO 8601 string
  payload?: Record<string, any>;
  userId?: string | null; // Auto-injected if user is logged in
}

Auto-Context Enrichment

You do not need to manually pass the userId. The SDK is wired directly to the Authentication module.

  • If the user is logged in, their userId is automatically attached to the event.
  • If the user is not logged in (e.g., viewing the landing page), the userId will be null, allowing you to track anonymous traffic.