Advanced Cobrowse Cross-Domain
This page highlights additional situations that may arise when setting up Cobrowse Cross-Domain.
Multiple Group IDs
Organizations utilizing multiple Glance group IDs will need to add a helper page to support the dynamic specification of the group ID and datasite attributes based on parameters in the helper page's URL.
The helper url should have the following format:
https://glancepro.online/helper.html?groupid=<GROUP ID>&datasite=<staging||production>
Below is a sample code that would need to be added to the helper page:
function addCobrowseScript() {
var allowedGroupIDs = ["12345", "23456", "34567", "45678", "56789"];
var urlParams = new URLSearchParams(window.location.search);
var groupId = urlParams.get("groupid");
// Check to make sure the group id in the query string is on the allowed list
if (!allowedGroupIDs.includes(groupId)) {
// If no group ID found in the query string, or there is one that's not on the allowed list
// replace with the desired default group id
groupId = "12345";
}
// Use production as the default, unless staging is specified
var dataSite =
urlParams.get("datasite") === "staging" ? "staging" : "production";
var theCobrowseScript = document.createElement("script");
theCobrowseScript.setAttribute("id", "glance-cobrowse");
theCobrowseScript.setAttribute("type", "text/javascript");
theCobrowseScript.setAttribute("data-groupid", groupId);
theCobrowseScript.setAttribute("data-site", dataSite);
theCobrowseScript.setAttribute("charset", "UTF-8");
theCobrowseScript.setAttribute(
"src",
`https://www.glancecdn.net/cobrowse/CobrowseJS.ashx?group=${groupId}&site=${dataSite}&script=XDOM`
);
document.head.append(theCobrowseScript);
}
window.addEventListener("load", addCobrowseScript);
NOTE: The group IDs in the above sample must be replaced with the group IDs for the organization