What is batchTrack?
batchTrack() lets you send multiple events in one request to the Analytiq server instead of making separate requests for each event.
Think of it like this:
When to use batchTrack vs track
Use track() | Use batchTrack() |
|---|---|
| One event at a time | Multiple events at the same moment |
| User clicks a button | App startup — track several things at once |
| Form is submitted | Page loads — send session + page view together |
| Real-time single interaction | End of session summary |
batchTrack(). If they happen at different times based on user actions, use track() individually.
Basic usage
name(required) — the event nameproperties(optional) — same key-value pairs astrack()
React — App startup tracking
- JavaScript (.jsx)
- TypeScript (.tsx)
pages/Dashboard.jsx
Next.js App Router
Vue 3
Vanilla HTML
With user identity
If the user is already logged in when the batch fires, you can includeuserId per event: