Skip to main content

Events

attachEvent(element, evt, fn, useCapture)​

Pendo Web SDK's version of attaching event listeners.

ParamTypeDescription
elementHTMLElementDOM element to attach listener to
evtstringtype of DOM event
fnfunctioncallback function
useCaptureBooleanuse 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.

ParamTypeDescription
elementHTMLElementDOM element to detach listener from
evtstringtype of DOM event
fnfunctioncallback function
useCaptureBooleanuse 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.

ParamTypeDescription
[options]ObjectOptions passed through to each queue's flush method
[options.unload]booleansignals the page is unloading; drains the send queue using sendBeacon or sync XHR for reliable last-chance delivery
[options.hidden]booleansignals 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.

ParamTypeDescription
namestringname of the collected event
[props]Objectoptional properties object to collect with the event
[eventProperties]Objectoptional 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.

ParamTypeDescription
typestringtype of the collected agentic event (e.g. 'prompt', 'agent_response', 'user_reaction')
propsObjectevent-specific properties object
[eventProperties]Objectoptional 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' })