Cobrowse Visitor Events

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

Session Lifecycle Events

To keep track of a session's lifecycle status, monitor these status events.

sessionstarting

A session in the process of starting posts this sessionstarting event. It is followed by sessionstart, or by error if the session fails to start. It can take a few moments for a session to start.

sessionstart

sessionstart means the session has started.

sessioncontinue

sessioncontinue is fired when the session is first established (after sessionstart), and again every time the visitor navigates to a new page while in the session.

statereceived

A session posts statereceived after a visitor has navigated to a new page and the initial session state has been received from the session server.

While handling this event call GLANCE.Cobrowse.Visitor.getSessionState() to retrieve the state information.

sessionend

A session posts sessionend when it has ended. It passes an object describing the reason, e.g.:

{reason: 'agent' || 'visitor' || 'error'}

Abnormal-Condition Events

error

A session posts error when an error occurs. It passes this object describing the error

{ msg : [a description of the error],
  { code : [error code],
      msg: [message]
  } }

Possible error codes include these:

  • "service": A connection could not be established to the cobrowse service
  • "conndrop": The connection to the cobrowse service dropped and could not be re-established.
  • "dupkey": A session is already running with the specified session key or visitor id, and the group is configured to prevent duplicate keys.
  • "maskingerror": fires if there is an error determining masked fields.

connection

The connection event means 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 "reconnecting" status will be followed by either another connection event with the status "ok", or an error event with the "conndrop" code. connection includes an object identifying the status.

{status : ["ok" | "reconnecting"] }

Session Information Events

accessibility

The accessibility event means accessibility features (such as screen -reader support) are turned on or off. It includes an object showing the accessibility-feature state.

{enabled :[true | false]}

agents

The agents event means updated session participant information is available. This event occurs when a page first loads, and again whenever an agent or guest joins the session. It includes an object containing an array of information about the agents/guests viewing the session, for example:

{
   "count": 3,
   "agentlist": [
       {
           "username": "abc.glance.net",
           "partnerid": 12345,
           "partneruserid": "abc@company.com",
           "name": "Janet Wills",
           "title": "Senior Representative",
           "role": "agent",
           "guestid": 1162611,
           "num": 1,
           "agentrole": "Account Support" //available in Cobrowse 5.2 or later.
       },
       {
           "username": "def.glance.net",
           "partnerid": 12345,
           "partneruserid": "def@company.com",
           "name": "Mary Supervisor",
           "title": "Supervisor",
           "role": "agent",
           "guestid": 1217257,
           "num": 2,
           "agentrole": "Supervisor"//available in Cobrowse 5.2 or later.
       },
       {
           "role": "guest",
           "name": "Betty Rubble",
           "guestid": 1164652162,
           "num": 3
       }
   ]
}

  • Most sessions have just one agent, but it is possible to have multiple agents participating.
  • "role" allows you differentiate between additional agents versus non-authenticated guests that are admitted to the session.
  • "title” in the agent information comes from the Public Title, which currently can be set only by Glance. If a Public Name is specified for the agent, that name will be sent in agentlist instead of the agent’s profile name.

Note: Agent name, title, partneruserid, Glance Address are not included in the agentlist by default, but can be included if enabled by Glance Support. This capability is available only in Cobrowse version 4.10.1 or later. Allowing additional "guests" to join sessions is only available in Cobrowse 5.0 or later.

blur

A session posts blur 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

A session posts focus when the visitor clicks on the window, making it the active session window.

sessionpaused

A session posts sessionpaused when the session is paused or unpaused. It includes an object describing the current state of the session:

{ paused: [true|false] }

Document Sharing Events

documentviewed

The documentviewed event occurs any time the document viewer is launched. The event object includes some information about the file being shared, as well as who is doing the sharing.

For files that are shared by the visitor:

{
    "name": "example_file.xlsx",
    "visitorselected": true,
    "date": "Fri Jan 21 2022 15:47:57 GMT-0500 (Eastern Standard Time)"
}

For files that are shared by the agent:

{
    "name": "example_file.xlsx",
    "agentselected": true,
    "date": "Fri Jan 21 2022 15:49:12 GMT-0500 (Eastern Standard Time)"
}

visitordownload

The visitordownload event occurs when the visitor downloads a file shared by the agent. For example:

{
    "name": "example_file.xlsx",
    "agentselected": true,
    "date": "Fri Jan 21 2022 15:49:35 GMT-0500 (Eastern Standard Time)"
}

agentdownload

The agentdownload event occurs when the agent downloads a file shared by the visitor. For example:

{
    "name": "example_file.xlsx",
    "date": "Fri Jan 21 2022 16:32:35 GMT-0500 (Eastern Standard Time)"
}

Remote Control Events

rcrequested

The rcrequested event means an agent is requesting remote control of the visitor's browser. It includes this object containing two callback functions.

   {accept : [callback function],
    decline: [callback function] }

To handle this event, call either accept() or decline() once you determine whether the visitor will grant remote control permission.

rc

The rc event means remote control has started or ended.
When remote control is active, this rc event also occurs whenever the visitor navigates to a new page. It includes an object showing the remote-control state.

{enabled :[true | false]}

rcevent

Occurs each time the agent performs an action in the visitor's browser like a click or input change. It should include an object with the following information, inlcluding an optional PUID, order in which the agent joined the session, and URL path.

{
    "type": "[click | inputchanged]",
    "agent": {
        "username": "user.glance.net",
        "puid": "user@company.com",
        "num": 1
    },
    "path": "[data-gid=\"148\"]"
}

Reverse Session Events

Agents can request reverse sessions from within existing sessions.

reverseconfirm

The reverseconfirm event means an agent is asking the visitor to join a reverse session. It includes this object containing two callback functions.

     {accept : [callback function],
      decline: [callback function] }

To handle this event, call either accept() or decline() once you determine whether the visitor wishes to join the reverse session.

reverseended

The reverseended event means the agent has ended a reverse session. The reverse session will automatically end for the visitor. If a reverse session confirmation dialog is still waiting for a visitor response, hide it when getting reverseended.

Screenshare Session Events

screenshare

The screenshare event means a screenshare session has started or ended . It includes this object.

{ screenshareView:[viewname],
  agentnum : [the agent number of the agent who is sharing their screen],
  state: ["new"|"continued"| "ended"],
  paused: [true|false]
}

screenshareView has the value "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.

screensharepause

The screensharepause event means the agent has paused a screen share session. It is typically handled by hiding the corresponding screenshare viewer, or by replacing it with a static image. It includes an object identifying the screen share session.

{ screenshareView:[viewname] }

screenshareresume

The screenshareresume event means the agent has resumed a paused screen share session. It includes an object identifying the screen share session.

{ screenshareView:[viewname] }

viewerinfo

The viewerinfo means screenshare viewer information is available. It occurs after a Screen Share session is first started, and whenever 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.

{ screenshareView:[viewname],
  screen : { width: [w],height : [h]},
  scaledview: { width: [w], height : [h]},
  glance_viewer: {
    stats: {fpslimit: [n], viewerfps: [n], displayfps: [n]}
  }
 }

screenshareView identifies the screen share session to which the 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.

Legacy Event

urlstartwarning

This deprecated urlstartwarning event means parameters have been passed onto the page URL signaling that a session should continue on a new domain. This event, used for cross domain cobrowse, provides legacy support for old Microsoft Internet Explorer.

      {accept : [callback function],
       decline: [callback function] }

Visitor Video Events

visitorvideo

Occurs when

  • a visitor video session first starts
  • when the video session resumes after navigation
  • when an inactive browser tab regains focus

Note that even if the visitor's camera is unavailable, visitorvideo still fires to indicate that the video session has started in an error state.

Object Passed to Event Handler

{ video : "large" | "small", camerastatus : "blocked" | "nocamera" | "available" | "error" }

visitorvideorequested

Occurs when the agent has requested that the visitor initiate a video session. To accept the request, call the accept callback and the visitor's video session will start. Typically visitorvideorequested is handled by presenting a preview dialog with the ability to select a camera and pause video.

To control how the visitor's video will start, pass VideoParams (see the documentation for GLANCE.Cobrowse.Visitor.startSession) to the accept callback.

Object Passed to Event Handler

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

visitorvideostarted

Occurs when the visitor video session first starts.

Object Passed to Event Handler

{ width : [video resolution width], height : [video resolution height]}

visitorvideostopped

Occurs when the visitor video session ends.

visitorvideopaused

Occurs when the visitor video session has completed the "pause" process after a call to toggleVideo(). After the visitorvideopaused event, a subsequent call to toggleVideo() will unpause the video. visitorvideopaused also occurs on page navigation immediately after visitorvideo if the video session is in a paused state.

visitorvideoresumed

Occurs when the visitor video session has completed the "unpause" process after a call to toggleVideo(). After the visitorvideoresume event, a subsequent call to toggleVideo() will pause the video.

visitorvideoerror

Object Passed to Event Handler

{ error : [errorcode] }

viewerclosing

Occurs when participants in a multiway video session are unable to play videos due to their browser/network.

{ closereason: "PlayerTooSlow"}

Invoking The 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.

Parameters

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.

Methods

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

Method Description
init

(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.

Example

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

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.

Example:

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