Skip to main content

Identity

clearSession()

Removes current visitor id and account id. Triggers an identify event and reloads with a new anonymous visitor.

Example

pendo.clearSession()

generate_unique_id(prefix) ⇒ string

Generate a unique id string, usually for a visitor id. Default for anonymous visitor ids.

ParamTypeDescription
prefixstringstring to prepend to the unique id

Example

pendo.generate_unique_id('user-') => 'user-RaPiWJ5M53Y'

getAccountId() ⇒ string | null

Returns the id for the account currently being applied to any events being sent to Pendo.

Returns: string | null - active account id or null if not set
Example

pendo.getAccountId()

Example

pendo.get_account_id()

getSerializedMetadata() ⇒ JSON

Returns all metadata being passed through the agent.

Returns: JSON - metadata available to the agent
Example

pendo.getSerializedMetadata()

getVisitorId() ⇒ string

Returns the id for the visitor currently being applied to any events being sent to Pendo. Will always be set either by host application or as an anonymous generated ID.

Returns: string - id of currently active visitor
Example

pendo.getVisitorId()

Example

pendo.get_visitor_id()

identify()

This function accepts either a string for just the visitor id or it accepts an Object that will contain at least a visitor object with at least an id field. It may also contain other visitor related Key/Value pairs in the visitor object. Also, in the options object may be an account object that will contain at least an id field. It may also contain other account related Key/Value pairs. This will potentially send an identify event and a metadata event.

Identifying a visitor will send an event to Pendo and begin loading eligible guides to the identified user. To remove visitor identity use pendo.clearSession().

Example

pendo.identify("put_visitor_id_here", "put_account_id_here");

Example

pendo.identify({
visitor: {
id: "put_visitor_id_here",
name: "Neo",
email: "neo@thematrix.io",
role: "admin"
},
account: {
id: "put_account_id_here",
name: "CorpSchmorp"
}
});

isAnonymousVisitor(visitorId) ⇒ boolean

Checks if a given visitor id string is anonymous. If no argument is given, calls with pendo.getVisitorId() to check current visitor status.

ParamTypeDescription
visitorIdstringstring to check if anonymous

Example

pendo.isAnonymousVisitor('_PENDO_T_123') => true

set_account_id(newAccountId)

Sets account id for the agent without changing existing metadata. However, An invalid account id or an explicit null value will clear the current account id and account metadata.

ParamType
newAccountIdstring

Example

pendo.set_account_id('new_account');

set_visitor_id(newVisitorId)

Sets visitor id for the agent. Requires a valid visitor id string. This will not change or clear existing visitor metadata set.

ParamType
newVisitorIdstring

Example

pendo.set_visitor_id('new_visitor');

updateOptions(options)

Updates metadata object for the Pendo agent. Can include visitor and/or account updates, along with customer-defined metadata values. Changes to identity information will potentially fire identity and metadata events, in turn evaluating guide eligibility for the new user and displaying any matching guides automatically.

ParamTypeDescription
optionsobjectnew metadata to set in the agent

Example

pendo.updateOptions( { visitor: {"role":"admin"} }, { account: {"industry":"retail"} });