Hide the chat widget on specific pages

To hide the chat widget on specific pages of your website, apply the following changes to your installation code:

  1. Find your Chaport widget config
w.chaportConfig = {
   appId : '55ccb98067193d440e367a53'
};

and change it like this:

w.chaportConfig = {
   appId : '55ccb98067193d440e367a53',
   session: {
       autoStart: false
   }
};
  1. Add these lines after the installation code:
<script>
    (function() {
        // list the pages you want to hide the chat widget on
        var hideOnPages = [
            'www.your-domain-name.com/hide-page-1/',
            'hide-page-2'
        ];
        
        // don't modify code below unless you know what you are doing
        if (!isPageOneOf(window.location.href, hideOnPages)) {
            window.chaport.q('startSession');
        }
 
        function isPageOneOf(url, patterns) {
            for (var i = 0, len = patterns.length; i < len; i++) {
                if (typeof patterns[i] === 'string') { // look for substring match
                    if (url.indexOf(patterns[i]) !== -1) return true;
                } else if (typeof patterns[i].test === 'function') { // presume regex
                    if (patterns[i].test(url)) return true;
                }
            }
 
            return false;
        }
    })();
</script>   

In this part of the code:

<script>
(function() {
    var hideOnPages = [
        'www.your-domain-name.com/hide-page-1/',
        'hide-page-2'
    ];

don’t forget to change 'www.your-domain-name.com/hide-page-1/', 'hide-page-2' to the URL or a part of the URL of a page / pages where you want to hide the chat widget.

Please note: This code is a part of JavaScript API that is only available on our paid plans.