Sending custom events with the track function
Last updated: November 30, 2026
Custom events record shopper interactions specific to your site that standard ecommerce events don’t cover, such as sign-ups, video plays, or filter selections. You send one with the Noibu JavaScript SDK track() function, using any event name and an optional data object.
Noibu stores the event and its data with the session. Events you send this way appear as code-based events on the Custom events page in Settings and under the Custom Events metric category in Dashboards, where you can chart how often they happen. To analyze an event by the data you sent, such as sign-ups by placement, ask Claude through the Noibu MCP server.
Code-based events are recorded from the moment your track() call is live on your site. They don’t include activity from before the call was deployed.
Sending a custom event
window.NOIBUJS.track(eventName, eventData);
Parameter | Type | Description |
|---|---|---|
| string | The name of the event, such as |
| object or | Any JSON-serializable data about the event. Pass |
Example:
window.NOIBUJS.track('user_signed_up', {
plan: 'pro',
signupSource: 'homepage_banner',
});
Calling track before the SDK loads
window.NOIBUJS only exists after the Noibu script finishes loading. Because of script ordering and async loading, your code can fire an event before then, and a direct call to window.NOIBUJS.track would throw or be lost. Use one of the two approaches below.
Option A: Buffer calls with the noibuTrack snippet
Use this approach when event calls are spread across your codebase, run in synchronous code paths or inline handlers, or mirror events you already send to another analytics tool.
Add this snippet once, as early as possible on the page, before any code that might fire an event:
<script>
window.noibuTrack = window.noibuTrack || function () {
var q = (window.noibuTrack.q = window.noibuTrack.q || []);
if (q.length < 100) q.push(arguments);
};
</script>
Then call noibuTrack in place of window.NOIBUJS.track:
noibuTrack('user_signed_up', { plan: 'pro', signupSource: 'homepage_banner' });
The snippet buffers your calls until the Noibu script loads. The SDK then takes over noibuTrack, replays the buffered events, and forwards every later call directly to Noibu. The buffer holds up to 100 events, so it can’t grow without limit if the Noibu script never loads, for example when an ad blocker blocks it.
Calls buffered before the SDK loads don’t return a result. Calls made after it loads return the same { success, errors } object as track().
Option B: Wait for the SDK to be ready
Use this approach for a small number of deliberate events where you want to confirm each payload validated.
Noibu fires a noibuSDKReady event once the SDK loads. Wait for it, then call track() directly:
if (!window.NOIBUJS) {
await new Promise(resolve =>
window.addEventListener('noibuSDKReady', resolve),
);
}
const result = window.NOIBUJS.track(name, data);
This always gives you the { success, errors } return value. Every call site must be async and wrapped in this guard, and if the Noibu script never loads, an awaiting call never resolves.
Return value
track() returns an object with success (boolean) and errors (string array):
const result = window.NOIBUJS.track('my_event', { foo: 'bar' });
if (!result.success) {
console.warn('Tracking failed:', result.errors);
}
Validation errors
Error | Cause |
|---|---|
|
|
| The payload is a primitive, such as a string or number |
| The payload contains circular references or non-serializable values |
Checking that your events arrive
During development, log the return value of each call:
var result = noibuTrack('view_item', { item_id: 'SKU_123' });
console.log(result); // { success: true, errors: [] }
If success is false, errors explains why. Buffered events return nothing at the time of the call. Noibu validates and sends them once the SDK is ready.
Noibu processes a session after it ends, approximately 30 minutes after the shopper’s last activity. Once the session is processed, the event appears on the Custom events page in Settings and is available to chart in Dashboards.
Using Claude or Codex to add custom events
If you use an AI coding assistant, such as Claude Code, Codex, or Cursor, with access to your codebase, describe the interaction you want to track and ask it to add the call. Name the event, say when it should fire, and list the data to include. For example:
Add a Noibu custom event called size_guide_opened that fires when a shopper opens the size guide on a product page. Include the product ID in the event data.
Use the noibuTrack snippet from Noibu's docs so the call works even if it runs before the Noibu SDK has loaded. Add the snippet to the <head> if it isn't there already.
Review the proposed change before you ship it, and check the event name and data match what you want to chart.