Chatstack Javascript API Launched

Chatstack Javascript API Launched

We’re excited to announce the release of our Chatstack Javascript API. Detailed documentation is available at along with several Javascript code samples.

To use the Javascript API please ensure you have installed the latest build available and your live chat HTML code is updated. The Chatstack Javascript API will constantly evolve as we release new updates to our live chat software.

Using the API, you can monitor events such as when the live chat status mode changes e.g. from online to offline. Additionally, you can also detect when a chat is accepted by a team member and also when the initiate chat status changes. These events could be used to dynamically change parts of your website or even track events within Google Analytics. For example, you could track an event in Google Analytics when a customer’s chat is accepted by your team.

We’ve updated the live chat HTML code to support a new events object and changed the global variable to Chatstack. Your existing live chat HTML code will still function however you should update the live chat HTML code to the new code if you wish to use the Chatstack Javascript API. The updated live chat HTML code is shown below for your reference.

<script type="text/javascript">
    var Chatstack = { server: '' };
    (function(d, undefined) {
        Chatstack.e = []; Chatstack.ready = function (c) { Chatstack.e.push(c); }
        var b = d.createElement('script'); b.type = 'text/javascript'; b.async = true;
        b.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + Chatstack.server + '/livehelp/scripts/js.js';
        var s = d.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(b, s);

Remember that you need to update the domain within the code above to your own domain where your live chat is installed.

An example for monitoring the chat status mode changed event would be possible using the following code. You could use this code as a starting point to modify sections of your website depending if your live chat is available.

Chatstack.ready(function () {
  // Place Event Code Here'StatusModeChanged', function (e, data) {
    // Status Mode Changed Event Received
    if (data.status === 'Online') {
      // Online
    } else {
      // Offline, Be Right Back or Away

Please contact us via. live chat or email if you require any technical support or advice for using the Javascript API. If you’d like to see a particular property or event added to the API then please also contact us as we’d love to discuss your situation.