Add Custom Browser Data to Who's On

Who's On allows Agents and Administrators to keep tabs on who is visiting their site and allows them to initiate live conversations with the visitors.  Oftentimes it is necessary to show additional information about the visitor that may be unavailable to SmarterTrack.  Examples include shopping cart contents, usernames, or browser size.
 
NOTE: As the Who's On code uses JavaScript, a strong knowledge of this scripting language is required. SmarterTools can not troubleshoot issues with code changes to any existing products, changes made to style sheets or any other customization created that change how a product looks and/or performs. Please be aware that malformed code or other changes made to the products can break things, and, therefore, these changes are made at your own risk.
 
In this example, we will show how to modify the embedded Who's On script to include information about the size of the user's browser window.
 
By default, a live chat script looks like the one below.  NOTEIt is important that for your configuration, you use the script generated from Who's On Settings as your starting point, and not the exact code below, as the URL will be different in your script.
 
<script>
  function smarterTrackWhosOn_TrackPage(a) {
    a.TrackPage();
  }
  (function() {
    var c = document.createElement('script');
    c.type = 'text/javascript'; c.async = true;
    c.src = "http://smartertrack.example.com/ST.ashx?scriptonly=true";
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(c,s);
  })();
</script>
To add a variable, you'll add a call to a.SetSTVariable(name,val) right below a.TrackPage().  SetSTVariable can be called as many times as necessary.  Our adjusted example can be found below, with the adjusted code in red:
 
<script>
  function smarterTrackWhosOn_TrackPage(a) {
    a.TrackPage();
    try {
      var width = window.innerWidth || 
                  document.documentElement.clientWidth || 
                  document.body.clientWidth;
      var height = window.innerHeight || 
                  document.documentElement.clientHeight || 
                  document.body.clientHeight;
      a.SetSTVariable('Resolution', width + 'x' + height);
    } catch {}
  }
  (function() {
    var c = document.createElement('script');
    c.type = 'text/javascript'; c.async = true;
    c.src = "http://smartertrack.example.com/ST.ashx?scriptonly=true";
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(c,s);
  })();
</script>
 

 

Learn more about SmarterTrack’s helpdesk system, which includes live chat, a self service portal and knowledge base software.