Overview
batchTrack() sends an array of events to Analytiq in one single network request instead of one request per event. Use this when you need to track multiple events at the same time, like when a page loads and you want to record several things at once.
Signature
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
events | BatchEvent[] | Yes | An array of event objects to send together |
BatchEvent object
Each item in the array is aBatchEvent with these fields:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Name of the event |
properties | object | No | Same as track() properties |
userId | string | No | Override user for this specific event (otherwise uses globally identified user) |
timestamp | string | No | ISO 8601 timestamp. Auto-generated if not provided |
Example
When to use batchTrack vs track
Use track() | Use batchTrack() |
|---|---|
| Single events happening one at a time | Multiple events at the same time |
| Button clicks, form submits | App startup events, page load events |
| Real-time single interactions | Summary of actions at the end of a session |