Cobrowse Visitor Events

Visitor Events are the events included within the visitor side behavior of Cobrowse:

Event Name Object Passed to Event Handler Description
sessionstarting sessionstarting is a session that is in the process of starting. Occasionally it can take a moment for the session to start. This event is followed by either "sessionstart" or "error."
sessionstart sessionstart occurs when a session has successfully started.
sessioncontinue sessioncontinue occurs when a session has continued after a visitor navigated to a new page.
statereceived statereceived occurs after a visitor has navigated to a new page and the initial session state has been received from the session server. Call GLANCE.Cobrowse.Visitor.getSessionState() to retrieve the state information.
sessionend sessionend occurs when a session has ended.
error {msg : [a description of the error]}{code : [error code]msg: [message]} error indicates that an error occurred. The object passed to the event handler contains information about the error.

Possible error codes:
  • service
  • conndrop
agents {count : [agent count], agentlist : [{ username:"", partnerid:72, partneruserid:"12345", name:"Janet Wills“, title:"" }, {… } ]} agents occurs when updated agent information is available. This event occurs when a page first loads, and again whenever the agent's information changes. The object passed to the event handler contains information about the agents viewing the session.

Note: "agentlist" is only available in Cobrowse 4.10.1+. This is an optional feature, off by default, which can be enabled by Glance support.
blur blur occurs when the visitor clicks on or opens another browser tab or window pointing to the same website. The newly activated window takes session focus and blur occurs in the original window.
focus focus occurs when the visitor clicks on the window, making it the active session window.
rcrequested {accept : [callback fn],decline: [callback fn]} rcrequested occurs when an agent requests remote control. Call accept() to continue, or decline() if the visitor does not wish to allow remote control.
rc {enabled :[true | false]} rc occurs when the remote control state changes. When remote control is enabled, the rc event also occurs whenever the visitor navigates to a new page.
accessibility {enabled :[true | false]} accessibility occurs when accessibility features are turned on or off.
reverseconfirm {accept : [callback fn],decline: [callback fn]} reverseconfirm occurs when an agent requests the visitor joins a reverse session. Call accept to continue, or decline if the visitor does not wish to join.
reverseended reverseended occurs when the agent ends a reverse session. The session will automatically end for the visitor. However, if a reverse session confirmation dialog is still pending a visitor response, hide it on reverseended.
screenshare {screenshareView :[viewname],state : ["new"|"continued"| "ended"],paused : [true|false]} screenshare occurs when a screen share session starts or ends. screenshareView will be "glance_screenshare" or "glance_agentvideo" if using a standard Glance Cobrowse agent viewer such as the Glance client.

If using a custom agent viewer, screenshareView may be a custom name.

This event occurs as follows:
  • When a screen share session first starts (state="new").
  • After every page load—as long as the session is in progress (state="continued").
  • When a screen share session ends (state="ended").

Handle this message by positioning, sizing and displaying the iframe identified by screenshareView.
{screenshareView :[viewname]} screensharepause and screenshareresume occurs when the agent pauses or resumes the screen share session. This event is typically handled by hiding the corresponding screenshare viewer, or by replacing it with a static image.
viewerinfo {screenshareView:[viewname],screen : { width: [w],height : [h]}scaledview : {width: [w], height : [h]}glance_viewer : {stats : {fpslimit: [n]viewerfps: [n]displayfps: [n]}}} viewerinfo occurs when screenshare viewer information is available. It occurs after a Screen Share session is first started, and subsequently, when the display side monitor or resolution changes. For sessions running in video mode, this event also occurs periodically to report statistics such as viewer frame rate.

The screenshareViewproperty indicates the viewer to which the viewer information applies. All other properties are provided if they have changed since the last viewerinfo event.

This event is typically handled by adjusting the dimensions of the screen share viewer according to the display resolution.
connection {status : ["ok" | "reconnecting"] }{} connection occurs when the status of the connection to the Glance Cobrowse Service has changed. The UI may display a connectivity warning if the status is "reconnecting," and clear the warning if the status is "ok".

A connection event with statusreconnecting will be followed by either a connection event with the status ok, or an error event with codeconndrop.
urlstartwarning {accept : [callback fn],decline: [callback fn]} urlstartwarning occurs as parameters are passed onto the page URL signaling that a session should continue on a new domain. This technique for cross domain cobrowse is only required for IE9 and 10.

Invoking Visitor API from Another Window

In some cases, it is useful to control the Cobrowse session from a window other than the one the visitor is browsing the instrumented website from. A chat window is a typical example.

To support this functionality, the visitor window listens for glance_invoke messages posted from the chat window. The window message handler will only accept glance_invoke messages if the domain of the origin is in the list of trusted domains as configured in the Cobrowse settings for the account.



To invoke a GLANCE.Cobrowse.Visitor function from a chat window using GLANCE.Cobrowse.InvokeVisitor, add the GlanceCobrowseInvokeVisitor.js to the chat window page.


The following methods are available on Glance.Cobrowse.InvokeVisitor:

Method Description

(wnd, groupid, origin)
init initializes the GLANCE.Cobrowse.InvokeVisitorobject.

wnd the visitor browser window.

groupid must match the group ID in the Cobrowse script tag in the visitor page.

origin should be the hostname of the visitor's current page, or "*" if it is ok to post the glance_invokemessage to any page.
invoke(func, args) Invoke the function func passing the specified args.


GLANCE.Cobrowse.InvokeVisitor.init(wnd, 12345, "*");
GLANCE.Cobrowse.InvokeVisitor.invoke("startSession", { sessionKey : "9999" });

Invoking Visitor API Using postMessage

To invoke a GLANCE.Cobrowse.Visitor function from another window using postMessage, post a message to the visitor window in the form:

glance_invoke : { func : [method of GLANCE.Cobrowse.Visitor], args : [args object], groupid : [goupid]}

The groupid must match the groupid on the visitor side.


wnd.postMessage({ glance_invoke: { func: "showTerms", args: { sessionKey: "12121212" }, groupid: "72937"} }, "*")

Screenshare and Agent Video in a Custom Visitor UI

When using the default visitor user interface, both Glance Screen Share and Agent Video are automatically displayed in the visitor browser. When using a custom visitor user interface, implement a listener for the screenshare event.

When an agent chooses to share their screen or webcam video, a screenshare event fires. See Visitor Side Events for a description of the Screen Share event. Glance uses the standard screenshareView names: glance_screenshare and glance_agentvideo for Screen Share and Agent Video sessions respectively.

To support Screen Share and Agent Video with a custom user interface, add hidden iframes and with id="glance_screenshare" and id="glance_agentvideo" to the visitor's page, and unhide the corresponding iframes when a screenshare event fires.

The glance_agentvideo and glance_screenshare iFrames must exist in the page before the agent initiates Agent Video or Screen Share. In addition, if the visitor navigates after Agent Video has already been turned on, the iframe must exist in the page before the visitor connects to the Cobrowse server. It is not possible to wait to create the iframe until the "screenshare" event fires.

By continuing to use the site, you agree to the use of cookies. Learn More