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

# track

> Send custom events with properties.

```javascript theme={null}
Hacktionbase.track(event, properties?)
```

Records a custom event. Events are sent to the Hacktionbase API and can be used to build segments, trigger campaigns, and analyze user behavior.

## Parameters

<ParamField body="event" type="string" required>
  Event name. Use `snake_case` by convention (e.g., `project_created`, `checkout_completed`).
</ParamField>

<ParamField body="properties" type="object">
  Optional key-value pairs attached to the event.
</ParamField>

## Example

```javascript theme={null}
Hacktionbase.track('project_created', {
  projectName: 'My Project',
  plan: 'growth',
  teamSize: 5
});
```

## Automatic events

The SDK tracks these events automatically — you don't need to call `track` for them:

| Event              | Description                                                    |
| ------------------ | -------------------------------------------------------------- |
| `page_view`        | Fired on every page navigation (including SPA route changes)   |
| `js_error`         | Fired on unhandled errors and `console.error` calls            |
| `replay_triggered` | Fired when session replay transitions from buffer to recording |

## Delivery

Events are sent using `navigator.sendBeacon` for reliability (works even during page unload). If `sendBeacon` is unavailable, the SDK falls back to `fetch` with `keepalive: true`.

Events are delivered asynchronously and never block the host page. Network failures are silently ignored — tracking must never break your application.

## Context

Every event automatically includes:

* `sessionId` — current session identifier
* `anonymousId` — persistent anonymous identifier
* `userId` — set after `identify()` is called
* `accountId` — set if the identified user has an account
* `device` — browser, OS, screen resolution, language, timezone
* `timestamp` — millisecond Unix timestamp
