Events
attachEvent(element, evt, fn, useCapture)
Pendo Web SDK's version of attaching event listeners.
| Param | Type | Description |
|---|---|---|
| element | HTMLElement | DOM element to attach listener to |
| evt | string | type of DOM event |
| fn | function | callback function |
| useCapture | Boolean | use capture phase instead of bubble |
Example
pendo.attachEvent(pendo.dom("h1")[0], 'click', helloWorld = () => { console.log("Hello World") });
detachEvent(element, evt, fn, useCapture)
Pendo Web SDK's version of detaching event listeners. The callback must be a named function; anonymous functions cannot be removed.
| Param | Type | Description |
|---|---|---|
| element | HTMLElement | DOM element to detach listener from |
| evt | string | type of DOM event |
| fn | function | callback function |
| useCapture | Boolean | use capture phase instead of bubble |
Example
pendo.detachEvent(pendo.dom("h1")[0], 'click', helloWorld);
doNotProcess : boolean
If a visitor has been marked as "Do Not Process" then this value will be set to true.
Example
pendo.doNotProcess => true
flushNow([options]) ⇒ void
This will force a flush of cached event objects.
| Param | Type | Description |
|---|---|---|
| [options] | Object | Options passed through to each queue's flush method |
| [options.unload] | boolean | signals the page is unloading; drains the send queue using sendBeacon or sync XHR for reliable last-chance delivery |
| [options.hidden] | boolean | signals the page is being hidden; drains the send queue immediately rather than waiting for the next timer tick |
Example
pendo.flushNow()
isSendingEvents() ⇒ Boolean
Returns true if event collection is currently enabled.
Example
pendo.stopSendingEvents()
pendo.isSendingEvents() => false
pendo.startSendingEvents()
pendo.isSendingEvents() => true
startSendingEvents()
Starts event collection and transmission.
Example
$ pendo.startSendingEvents()
> Pendo Web SDK unlocked. Events will be written.
stopSendingEvents()
Stops event collection and transmission.
Example
$ pendo.stopSendingEvents()
> Pendo Web SDK locked. No more events will be written.
track(name, [props], [eventProperties])
Method to manually track events. Requires a non-empty name string to collect the event.
| Param | Type | Description |
|---|---|---|
| name | string | name of the collected event |
| [props] | Object | optional properties object to collect with the event |
| [eventProperties] | Object | optional key-value map stored on the event as top-level event properties |
Example
pendo.track('scroll')
pendo.track('Registered', { plan: 'Pro' }, { experiment: 'variant_a' })
trackAgent(type, props, [eventProperties])
Method to manually track agentic events. Uses agent functions for IDs and context. Automatically applies privacy filters if agentId is provided and agent configuration exists.
| Param | Type | Description |
|---|---|---|
| type | string | type of the collected agentic event (e.g. 'prompt', 'agent_response', 'user_reaction') |
| props | Object | event-specific properties object |
| [eventProperties] | Object | optional key-value map stored on the event as top-level event properties (same as pendo.track) |
Example
pendo.trackAgent('type_of_event', {
agentId: 'weather_assistant',
conversationId: 'conv_abc123',
messageId: 'msg_xyz789',
content: 'thumbs_up',
modelUsed: 'gpt-4',
suggestedPrompt: false,
toolsUsed: [],
fileUploaded: false
}, { experiment: 'variant_a' })