Cobrowse Cross-Domain

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

This document applies to Cobrowse 4.10 and higher.

Setting up Helper Pages

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, the helper page will be visible to the visitor briefly, before closing automatically.

For the fastest and most reliable domain transitions, Glance recommends putting a lightweight helper page on each domain, using this page as a template:

<!DOCTYPE html>
<html>
<head>
  <title>Glance Cobrowse Cross Domain Helper</title>
  <script
    id="glance-cobrowse"
    data-groupid="72"
    data-site="staging"
    src="https://www.glancecdn.net/cobrowse/CobrowseJS.ashx?groupid=72&site=staging&script=XDOM">
  </script>
</head>
<body>
</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.

Info
  • The helper URL cannot be a page that redirects somewhere else.
  • The helper URL cannot require authentication to access.

Alternatively, you can use any existing page on the website which contains a Cobrowse script tag.

Configuring Domains and Helper Pages on your Account

Once you have settled on the helper page you are using for each domain, you need to configure the domains and helper page URLs in Glance. Glance will only allow session information to be passed to and from these trusted domains.

Follow these instructions to configure cross-domain Cobrowse:

  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: Enable Enable

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.

Domains vs. Subdomains

If your website includes multiple “sub-domains” for the same domain, generally only the top level domain needs to be included. For example, if you have pages on a.mycompany.com and b.mycompany.com, you only need to add one entry for mycompany.com.

An exception would be in the case where data-cookiedomain is specified in the Cobrowse script tag in order to specify that the cookie be written on the subdomain. In this case, you would would use the subdomain specified in the data-cookiedomain attribute. So for example if your script tag has data-cookiedomain=“a.mycompany.com” then you would need to add a.mycompany.com to the list of domains for cross-domain Cobrowse.

Moving from One Domain to Another

At some point during a Cobrowse session, the session information must be passed to all of the domains other than the one on which the session starts. There are several options for making this happen, depending on how your website visitors navigate from one domain to another.

If your visitors navigate to another domain by clicking on an anchor tag <a> link, Glance manages the domain transition automatically. The first time a customer clicks on such a link, a popup helper window appears briefly before the browser redirects to the page specified in the anchor tag. From that point on during the session, the visitor may navigate seamlessly between all domains. If you are navigating between domains with links in anchor tags, then your configuration work is complete.

JavaScript Domain Transitions

If your website uses JavaScript, not static links, to redirect the visitor to a new domain, you will need to call the JavaScript method GLANCE.Cobrowse.Visitor.crossDomain() to pass the session information to the other domains.

You can call GLANCE.Cobrowse.Visitor.crossDomain() at any time before a domain 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.

If you would like to ask the visitor for permission before continuing the session on other domains, call GLANCE.Cobrowse.VisitorUI.promptCrossDomain(), which shows a confirmation message with Yes / No buttons. The message displayed can be customized on the Account Cobrowse Settings page.

Pop-up Blockers

Because crossDomain() opens a new window, it must be called in response to a user action such as a click or keystroke, in order to avoid triggering a pop-up blocker. promptCrossDomain() does not trigger a pop-up blocker because the user clicks “Yes” to start the cross domain process.

Examples

Setting up Cross-Domain Cobrowse at Session Start

Calling crossDomain() or promptCrossDomain() at session start time is good option in situations where it’s difficult to identify the domain transitions and add the API calls as needed.

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

    jQuery(document).ready(function () {
       GLANCE.Cobrowse.Visitor.addEventListener("sessionstart", function () {
                GLANCE.Cobrowse.Visitor.crossDomain();
        });
    });

The sample above works on most browsers. Visitors using Apple Safari may see a pop-up blocker warning the first time they run a cobrowse session.

Use promptCrossDomain() instead to avoid pop-up blockers, or if a confirmation prompt is desired.

Setting up Cross-Domain Cobrowse on Navigation

The code below is an example of calling crossDomain() at the time of the transition to the other domain. This approach is appropriate in situations where crossing domains happens infrequently and it would therefore be unnecessary to send session information to the other domains every time a session is launched.

In this example, the website has a button which redirects to a page on another domain using JavaScript.

Info

crossDomain() only needs to be called once during a session, although it’s ok to call it multiple times.

<button id="redirect-button">...</button>
function redirect() {
    // 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";
        return;
    }

    // In a cobrowse session, send the session information to
    // other domains and then open // https://www.example.com
    GLANCE.Cobrowse.Visitor.crossDomain(
      { url : "https://www.example.com",
        target : "_self"});
};

jQuery(document).ready(function () {
    jQuery("#redirect-button").click(redirect);
});

In the following example, crossDomain() is called to send session information to other domains, and then a new window is opened on another domain.

GLANCE.Cobrowse.Visitor.crossDomain().then(function() {
    window.open("https://www.example.com", "_blank");
});

Troubleshooting

  • If you experience Cross-Domain Cobrowse issues where the agent does not follow the visitor, verify that the Cobrowse script tag is identical on the main website and all helper pages.
  • If your organization utilizes multiple Glance groups and you want to deploy one set of code that references all the groups, refer to the Advanced Cross-Domain page.