Cobrowse Cross-Domain

If you expect your Cobrowse sessions to involve interactions across multiple domains, additional configuration is required.

To successfully navigate from one domain to another during a cobrowse session, the cobrowse script needs to open a “helper page” on the second domain, write a cookie to that domain, and close the helper. This must be done prior to the transition (see below for implementation options). The helper page will be visible to the visitor briefly, before being closed automatically.

Since the helper page must load completely, it is important that the page be as lightweight as possible, and it must contain the Glance cobrowse JavaScript tag. You can either choose an existing page on the domain to serve as the helper page, or you can use this page as a template:

<html>

<head>
  <title>Glance CB Page</title>
  <script id="cobrowsescript" type="text/javascript" src="https://www.glancecdn.net/cobrowse/CobrowseJS.ashx?group=12345&site=staging" data-groupid="12345" data-site="staging" charset="UTF-8"></script>
</head>

<body>
  <script>
    window.addEventListener("DOMContentLoaded", function() {
      window.setTimeout(function() {
        document.getElementById("glance_yes").click();
      }, 100);
    }); <
    // This is needed for IE 11, which opens a modal that
    // the user must click to accept before the page can be closed.
  </script>
</body>

</html>

Be sure to replace the group ID number with your group’s number (in both locations) as well as the data-site value as appropriate.

Once you have settled on the helper page you are using for each domain, follow these instructions:

  1. As an administrator, log in at glance.net/login.
  2. Click on the Settings tab, scroll to the Cobrowse Settings section near the bottom, and click Manage Your Cobrowse Settings.
  3. Scroll down to the Cross-Domain Cobrowse section.
  4. Add each domain as well as a helper page.

For example: cross domain settings

NOTE: Both the original domain and the destination domain need to be listed. That is, if a session starts on abc.com and continues to def.com, both abc.com and def.com need to be listed here.

If you are navigating between domains with links in anchor tags, then your configuration work is complete.

NOTE: Glance Cobrowse Cross-Domain relies on a query string parameter in IE11. If the target of an anchor tag is a page which strips query string parameters, the session will not follow in IE11.

If you use JavaScript, not links, to redirect the visitor to a new domain, the Cobrowse script exposes an API GLANCE.Cobrowse.Visitor.continueSessionAt(), which can pass the session information on demand to the new domain. It is up to customers to call continueSessionAt() before any domain transition.

NOTE: This is typical in the use of JavaScript links or authentication redirects between domains. If the link clicked is not the end domain that the customer intends to move to or the end domain is unknown, i.e. dynamically generated through code, then this is the method that you will need to use.

On the page where the session is launched, use the continueSessionAt API call to write a cookie to the other domain(s). This can be done at any time before transition, although it is logical to do this either when the session starts or on the navigation event. See below for examples of each implementation.

Setting up Cross-Domain Cobrowse at Session Start

Creating cookies at session start time is recommended in situations where it’s difficult to identify the domain transitions and add the API calls as needed. In addition, if continueSessionAt() is not called synchronously with a mouse click or keystroke event, it can trigger a popup blocker.

The below code would be used to call continueSessionAt() at the start of the cobrowse session.

GLANCE.Cobrowse.Visitor.addEventListener("sessionstart", () => {
  GLANCE.Cobrowse.Visitor.continueSessionAt({
    destination: "example.com",
    oncomplete: function() {
      console.log("Session continued on example.com");
    },
    iewarningsuppressed: true
  });
});

Be sure to replace the “destination” with the destination domain, and delete/replace the console log as desired.

If additional domains need to be cookied, you must call a separate instance of continueSessionAt() for each domain.

Setting up Cross-Domain Cobrowse on Navigation

The below code is an example of calling continueSessionAt() at the time of the transition to the other domain.

This approach is desirable in situations where crossing domains happens infrequently and it would therefore be unnecessary to cookie the alternate domains every time a session is launched.

var redirect = function() {
  // First check to see if a cobrowse session is active
  // If not, proceed with the redirect as normal
  if (!GLANCE.Cobrowse.Visitor.inSession()) {
    window.location = "https://www.example.com";
  }
  // If a session is active, then call continueSessionAt
  if (GLANCE.Cobrowse.Visitor.inSession()) {
    GLANCE.Cobrowse.Visitor.continueSessionAt({
      destination: "example.com",
      oncomplete: function() {
        // Use the oncomplete method to perform the redirect
        // once the cookie has been written
        window.location = "https://www.example.com";
      },
      iewarningsuppressed: true
    });
  }
};

window.addEventListener("load", event => {
  document
    .getElementById("redirect-button")
    .addEventListener("click", redirect);
});

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