Skip to main content

Glance Cobrowse API Guide

The Glance Cobrowse API Guide will help you integrate a customized version of Glance Cobrowse into your company website or third party tools. For additional details on configuring Glance Cobrowse, please refer to the Glance Cobrowse Setup Guide.

Interested in learning how Glance Cobrowse works? Just click: "What is Glance Cobrowse?"


clipboardnew.png Note Session Key and Session Code are used interchangeably throughout the document.

Visitor Side API

The Visitor Side API allows you to customize the visitor side behavior of Glance Cobrowse.

Certain cobrowse parameters can be controlled by setting properties on the Javascript variable: window.GLANCE_COBROWSE.

The following string properties can be set on GLANCE_COBROWSE. These properties would typically be set if the visitor is logged in and the information is known at the time the page is rendered.


If specified, a visitorid is used as the Session Code when a cobrowse session starts instead of a random key. A visitorid is often a user ID or some other string that uniquely identifies the website visitor. It may contain alphanumeric characters, (-) and (.). If name, email, and phone are provided, the visitorid is stored with the session record in the Glancedatabase.


Visitor’s name.


Visitor’s email address.


Visitor’s phone number.

For example:

visitorid: "59204gh-42",
name: "Joe Smith", 
email: "",
phone: "314-555-1212"

If this variable is defined at the time a session starts, these visitor parameters are used for the session regardless of how the session was started.


The GLANCE.Cobrowse.Visitor object is defined in any web page that includes the Glance Cobrowse<script>tag.

The following properties and methods are available on Glance.Cobrowse.Visitor. Methods marked with (*) can only be called when there is a session running.


startSession(sessionKey) starts a cobrowse session.

  • If sessionKey is of type "string", that key is used for the session. A session key can contain the following characters: numbers, letters (upper or lower case), underscore, or dash and can be up to 50 characters long.
  • If sessionKey is "GLANCE_KEYTYPE_RANDOM",a random key is generated.
  • If sessionKey is undefined and either GLANCE_COBROWSE.visitorid is defined or data-visitorid is present in the <script> tag, the visitorid is used as the session key.
  • If neither sessionKey nor GLANCE_COBROWSE.visitorid is defined, a random key is generated.


startSession(startParams) starts a session according to the parameters specified in startParams.

startParams may contain any of the following properties:

groupid (Optional) Id of the group in which to start the session.  If no groupid is present, the session starts in the group specified in the data-groupid attribute of the script tag.
sessionKey (Optional) Session key.  See startSession(sessionKey) for behavior when sessionKey is not specified.
name (Optional) Visitor name
email (Optional) Visitor email
phone (Optional) Visitor phone


var startParams = {
sessionKey : "ABCD",
name : "Julie Smith",
email : "",
phone : "314-555-1212"



setStartParams(startParams) sets the start parameters in advance for the next session. These start parameters will be used when the session is started in one of the following ways:

  1. Visitor clicks the standard cobrowse button.
  2. GLANCE.Cobrowse.Visitor.startSession() is called with no arguments.
  3. Visitor clicks the button with the attribute glance_button='startSession'.
  4. Visitor clicks the button with the attribute glance_button='showTerms'​ and then clicks Accept.

To clear the start parameters, call setStartParams() with no arguments.


readyState indicates the state of the visitor page as it connects to a cobrowse session. The possible values for readyState are contained in the GLANCE.Cobrowse.Visitor.READYSTATE object:

  • sessionend
  • sessionstarting
  • sessionstart
  • sessioncontinue
  • statereceived

An event occurs at each state change. For example, when adding listeners for these state events, it may be necessary to check readyState to determine whether the event has already occurred.



inSession() returns true if in a session, false otherwise.


stopSession() stops the cobrowse session.


getKey() returns the session key.


lightning2-bold-icon-clear.png New in version 3.3.0

enableRC() enables or disables remote control
getSessionState(eventName [, identifier])*

getSessionState() returns the information that was reported in the most recent state event specified by eventName. For example, getSessionState("agents") returns the object that would have been passed into the agents event listener. For the screenshare state, pass the screenshareView as the optional identifier parameter. If the specified event has not yet occurred, getSessionState() returns null.

addEventListener(eventName, listener)

addEventListener(eventName, listener) adds a listener function to be called when the event specified by eventName occurs.

See Visitor Side Events below.

removeEventListener(eventName, listener)

removeEventListener(eventName, listener) removes the specified event listener function.

addSessionMessageListener(msgName, handler)*

addSessionMessageListener(msgName, handler) adds a handler function that is called when a message with the name msgName is received from an agent.

addSessionMessageListener(msgName, handler) is in the form: function(msgName, msg) {...} where:

  • msgName: the message name.

  • msg: the message payload object that was sent from the agent side in sendSessionMessage.

sendSessionMessage(msgName, msg)*

sendSessionMessage(msgName, msg) sends a message with the name msgName and the payload msg to the agent.


setCookieValue(name, data)*

getCookieValue() and setCookieValue() are convenience methods for storing and retrieving values on the Glance Cobrowse session cookie. It can be helpful to store the UI state in a cookie for faster rendering of the UI when a page first loads. If stored in a cookie, the UI state is available immediately when a page loads instead of waiting for API events that occur only after the visitor script connects to the session server.

These methods can only be called after the sessioncontinue event occurs.


Note the Glance Cobrowse session cookie is a cookie on your website domain.



setUserState(name, data)*

setUserState() stores information on the cobrowse session.  getUserState() can be used to retrieve user state data.  These methods are similar to setCookieValue() and getCookieValue(), except that the data is stored on the server instead of in a browser cookie.

After the visitor navigates to a new page, user state is only available after the statereceived event has fired.


isRandomKey() returns true if the session key was randomly generated by Glance. This method is useful for scenarios when the key only needs to be displayed if it was randomly generated.


lightning2-bold-icon-clear.png New in version 3.5.0

params = {
    destination : [destination domain such as ""],
    destinationurl : [optional, a helper url to use instead of the one that is configured on the Cobrowse Settings page],
    oncomplete : [function to call when the session data has been passed to the new domain],
    iewarningsuppressed : [optional, set to true if the warning is suppressed for Internet Explorer - the destination page will auto-accept the "urlstartwarning" event]

continueSessionAt() allows a cobrowse session to continue even if the visitor navigates to a page on a different domain.  The destination domain must be a website that is tagged with the Glance Cobrowse script tag.  

Include both source and destination domains in the list of domains that are trusted for Cross Domain Cobrowse on the Cobrowse Settings page.

Normally, cross domain cobrowse works automatically once domains are listed under Cross Domain Cobrowse. However, if the visitor navigates to a destination domain via a server or client side redirect, as opposed to clicking on a link or button, then it will be necessary to call continueSessionAt() before the redirect occurs.


lightning2-bold-icon-clear.png New in version 3.7.0

params = { url : ["url to the pdf file"] }

viewPDF() opens a pdf file using the Glance Cobrowse pdf viewer.  When a web page opens a PDF using viewPDF(), the agent is able to view the PDF along with the visitor, as with any other cobrowseable web page.

Visitor Side Events

Visitor Side Events are the events included within thevisitor side behavior of Glance Cobrowse:

Event Name Object Passed to Event Handler Description

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 occurs when a session has ended.

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



count : [agent count]
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.
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,
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.

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, to indicate the initial state of remote control.

accept : [callback fn],
decline: [callback fn]

confirmreverse 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.
screenshareView : 
state : ["new"| 
"continued"| "ended"],
paused : [true|false]

screenshare occurs when a screen share session starts or ends./p>

screenshareView will be "glance_screenshare" or "glance_agentvideo" if using a standard Glance Cobrowse agent viewer such as the Glance 3 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.

See Using Screen Share and Agent Video within a Cobrowse session for more information.



screenshareView : 

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.

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 screenshareView property 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.

{ 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 statusreconnectingwill be followed by either a connection event with the statusokor an error event with codeconndrop.

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 Glance Cobrowse settings for the account.

To invoke a GLANCE.Cobrowse.Visitor function from another window, use the GLANCE.Cobrowse.InvokeVisitor helper API, or call postMessage directly.

Invoking Visitor API using GLANCE.Cobrowse.InvokeVisitor

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:

init(wnd, groupid, origin)

init initializes the GLANCE.Cobrowse.InvokeVisitor object.

wnd is the visitor browser window.

groupid must match the groupid in the cobrowse script tag in the visitor page.

origin should be the hostname of the visitor's current page, or "*" if it is okay to post the glance_invoke message 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.

For example:

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

Using screen share and agent video within a cobrowse session

Glance Screen Share allows an agent to show their desktop screen or view a customer's screen for instant clarification. The agent and customer can now see exactly what both parties were originally just talking about. Glance Screen Share can be used as a stand-alone service but in this application is invoked from within a cobrowse session as needed.

Glance Agent Video offers one-way webcam video of an agent during a screen share session from within cobrowse.

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 screen share event. See the Glance Cobrowse Setup Guide for more information on using the default vs. a custom visitor user interface.

When an agent chooses to share his or her screen or webcam video, a screen share event occurs.  See Visitor Side Events for a description of the screen share event. Glance uses the standard screenshareView names: glance_screenshare andglance_agentvideo for screen share and agent video sessions respectively.

To support screen share and video with a custom user interface, add hidden iframes and with id="glance_screenshare"and id="glance_agentvideo"​ to the visitor's page, and un-hide the corresponding iframes when a"screenshare"event occurs.


The GLANCE.Cobrowse.VisitorUI object is defined when the default visitor user interface is used. This object exposes methods for displaying the default user interface. See the Glance Cobrowse Setup Guide for more information on using the default vs. a custom visitor user interface.

The following methods are available on GLANCE.Cobrowse.VisitorUI:


showButton(show) displays the cobrowse button if show is true. If show is false, it hides the button.


toggleButton() toggles the display of the cobrowse button.


showTerms(termsParams) shows a terms and conditions dialog. The dialog, which is customizable via the cobrowse button customization tool, has an Accept and a Decline button. Clicking Accept will start a cobrowse session.


termsParams is optional and can contain any of the same properties as startParams.

See startSession inthe GLANCE.Cobrowse.Visitor section.

setStyle(groupid) (New in 3.5.1) If the site allows cobrowse in multiple groups, each group uses its own button customization.  Call setStyle() to load the style for a particular group before calling other VisitorUI methods.  Once a session is running, however, the button style will be loaded according to the group that the session is actually running in.

Custom UI

If using a custom UI (data-ui="custom" in the script tag) then the customer supplied user interface script can conditionally modify the user interface according to which group a session is running in.  The custom user interface script can use new api GLANCE.Cobrowse.Visitor.sessionGroupId(), which returns the groupid for the currently running session, if any.

It is not possible to use a custom ui for one group and the default UI for other groups.

Agent Viewer

Use the following URL format to view a session that was started with a specific visitor ID or a random Session Code:[visitorid|ssncode]

To maximize the viewing area, this URL should be opened in a separate browser window with no address bar or menu:""
+ visitorid, "_blank",

If an agent is not already logged into their Glance account, they will be prompted to log in. Alternatively, single sign-on credentials can also be passed on the Agent Viewer URL.

Optional query string parameterWaitcontrols handling of the case when the session has not started yet. If Wait=1​ is specified, the viewer window will poll waiting for the session to start. Otherwise, the viewer will redirect to an error page.

Agent Side API

The Agent Side API allows you to customize agent side behavior and integrate Glance Cobrowse with the agent's console or CRM.


The GLANCE.Cobrowse.Agent object implements the Agent Side API. A typical use case for the Agent Side API is a page that embeds the cobrowse viewer in an iframe.

Including the API

To include the Agent Side API on a page, add a cobrowse<script> tagfollowing the format of the<script> tagused on the visitor side, but add script=Agent (case sensitive) to thesrcattribute.

Agent side<script>tag example:

<script id="cobrowsescript" type="text/javascript"

When the enclosing page includes the Agent Side API Javascript, the page then has access to the following methods on the GLANCE.Cobrowse.Agent object:


init(viewerFrame) initializes the Agent Side API viewerFrame. This is the iframe containing the agent view.

addEventListener(eventName, listener)

addEventListener(eventName, listener) adds a listener function to be called when the event specified by eventName occurs.

removeEventListener(eventName, listener) removeEventListener(eventName, listener) removes the specified event listener.
addSessionMessageListener(msgName, listener)

addSessionMessageListener(msgName, listener) adds a handler function which is called when a message with the name msgName is received from a visitor. The listener function takes two parameters:

  • msgName: the message name.
  • msg: the message payload object that was sent from the visitor side in sendSessionMessage.
sendSessionMessage(msgName, msg) sendSessionMessage(msgName, msg) sends the message to the visitor side.


lightning2-bold-icon-clear.pngNew in version 3.6.0

navigate() redircts the visitor's browser to the specified URL.  The params object includes the following properties:


url : [url to navigate to],

confirm: { ... },

open: { target: ["_self"|"_blank"], features:[features as defined by] },

link: { target : ["_self"|"_blank"] }


The url may be:

  • A relative URL.  Visitor will be redirected to the specified URL, relative to the current page.
  • An absolute URL.  The host name must be in the list of trusted domains for cross-domain cobrowse as specified on the Cobrowse Settings page.
  • One of the following keywords: forward, back, refresh.

confirm is optional.  If specified, the visitor side will fire a confirm event before navigating.  The object passed to the confirm event handler will include the params passed to navigate(), as well as an accept() method to call if the visitor accepts.

If navigating to a page url (as opposed to forward, back, or refresh) then either open or link should be specified.  

If open is specified, is used to open the specified page.

If link is specified, then an anchor tag is added to the page and programmatically clicked.

leaveSession(url) leaveSession(url) ends the agent’s connection to the session and redirects the Agent Viewer to the specified URL.

addScreenshare(params) adds an already-started screen share session to the cobrowse session. Once a screen share session has been added, it will automatically persist even if the visitor navigates to a new page. The params object includes the following properties:



screenshareView : (string) id of the iframe on the visitor side where the screen share viewer should appear. Use "glance_agentvideo" or "glance_screenshare" for agent video and screen share respectively, if using the standard visitor side user interface.

key, sessionKey : (string) The session key.  Note: In version 3.7.4, this parameter was renamed sessionKey

ssnParams : The parameters that were passed to GLANCE.Client.InvokeGlance() used to start the session or the query string parameters that were passed to the Glance protocol handler to start the session. ssnParams may be an empty object, but supplying the session parameters can assist in rendering the screen share view. For example, ssnParams for a video session may be shown as follows: {type: "forward",video: 1, size: "240x320"}

agentparams : Parameters indicating agent side behavior.


preview : true|false. Set this to true to display the built-in video preview on the agent side. Set this to false to suppress the built-in agent preview. Defaults to false.





Pause or resume the visitor side screen share by triggering a screensharepause or screenshareresume event on the visitor side.

The params object must include the following properties:


screenshareView : The screen share view that was specified in addScreenshare()


Typical usage would be to call these methods before invoking ActionPause or ActionUnpause on the screen share session using the Glance Client Library. The default user interface behavior on the visitor side is to hide the screen share or video view while the session is paused.


The params object includes the following properties:


screenshareView : The screen share view that was specified in addScreenshare()


requestRC(true|false) requestRC(true) sends request to the visitor to enable remote control.  The default visitor side UI prompts the visitor to allow or decline the request.  requestRC(false) stops remote control.
getSessionState(eventname) getSessionState() retrieves information about the session as reported by the specified event. For example, getSessionState("rc") returns the event data reported in the most recent rc event. 
getUserState(name) getUserState() retrieves the user state that was stored on the session by a call to GLANCE.Cobrowse.Visitor.setUserState()

Agent Side Events

Agent Side Events are the events included within theagent side behavior of Glance Cobrowse:

Event Name Object Passed to Event Handler Description



sessionend occurs when the session ends. The object passed to the event handler may be undefined, or may contain a reason code. Please see reason codes listed in the next table.


         visitorversion: "",
         url: ""

navigate occurs when a visitor navigates to a new page. The object passed to the event handler will include information about the browser and URL.


lightning2-bold-icon-clear.png New in version 3.4.0

count : [agent count]
See the visitor side agents event.


lightning2-bold-icon-clear.png New in version 3.4.0

{"response":["accepted" | "declined"] } rcrequest occurs when the visitor responds to a request for remote control.


lightning2-bold-icon-clear.png New in version 3.4.0


enabled : [true | false],

suspended : [true | false]lightning2-bold-icon-clear.png New in version 3.6.0


rc occurs when the remote control state changes. The enabled property indicates whether remote control is currently enabled. The suspended property indicates whether control is temporarily suspended due to visitor mouse or keyboard activity.

See the visitor side rc event.


lightning2-bold-icon-clear.png New in version 3.3.0

screenshareView  : "[glance_agentvideo|glance_screenshare]",
state: "[accepted|declined|joined|ended]"
screenshare occurs on the agent side when a visitor accepts, declines, joins, or ends a screenshare session.


lightning2-bold-icon-clear.png New in version 3.4.0

user state object, as passed in by the visitor side call to GLANCE.Cobrowse.Visitor.setUserState() userstate occurs whenever the visitor side sets user state with the GLANCE.Cobrowse.Visitor.setUserState() method.


lightning2-bold-icon-clear.png New in version 3.7.0

an object describing the access violation.  Properties may include:

rcrequested : The agent attempted to request remote control.

accessdenied occurs whenever the agent attempts to do something for which he or she does not have the appropriate privileges.


sessionend reason codes:

UnsupportedBrowser Agent's browser is not supported for cobrowse.
SSOError SSO authentication failed.
NoSession Session Key is invalid or the session has not started yet.
InvalidSub Authenticated user does not have a valid subscription for viewing cobrowse sessions.
ExpiredCreditCard Credit card on the account has expired.
DeclinedInvoice Credit card for the account was declined.
ConnDrop Agent’s connection to the Glance Cobrowse server dropped.
AgentRefresh Agent refreshed the browser.
AuthError Authentication with the cobrowse service failed.
LookupFailed Agent was unable to connect to the Glance web service to lookup the session.
VisitorLeft Visitor left the session.
AgentLeft Agent left the session. If the agent was the last agent in the session, the session ends.

Glance SessionService

The Glance SessionService Web Services API can be used to obtain information about sessions in progress.

When using the Glance Session Service WSDL, the wsdl:port soap:address location must be changed to


The LookupPartnerCobrowseSession web service determines if a cobrowse session has been started by the visitor, and if so, returns information about the session.

If the session joinurl is found, the call returns a joinurl parameter where the agent can be directed to join the session without additional login information.

An example would be:$1$1423255914$-H3vWwvEwTtEmfRiKBZDuhhI0ygY-ph8Z6Ete6p_9fw

The call takes (and returns in the joinurl) these values:

partnerid partnerid is the same as the cobrowse group ID.
partneruserid partneruserid is any ID convenient for you. For example, an agent employee ID or a CRM login etc., that is assigned to the agent.
ssnkey ssnkey is the cobrowse Session Key/visitor ID.
loginkey loginkey is a time-limited, typically single-use authentication, key for the user.

The partneruserid can be assigned by Glance, but will typically be supplied by you, if you provision users with the Glance Provisioning API. For more information on provisioning, contact Glance support at

See Glance Login Key for Single Sign-On for instructions for generating a Login Key.

Need more help?