Display contact widget only for customers logged in the customer portal

Some of our customers wish to display a live chat button or other contact widget in the Customer Portal only to customers that are logged in to the customer portal. Please find the instructions below.

First of all, you need to prepare the first part of the code which we will be using to check if the customer is logged in. We will be checking that via variable {$userLogged} saved in the parameter userLogged.

Please navigate into the Customer portal > Settings > General Configuration - Change > Design > Own HTML > Footer HTML, and place to this field the following code snippet which will cooperate with the contact widget integration code.

var userLogged='{$userLogged}';

The second step will be editing the contact widget integration code, where we add a condition to review if the customer is logged in. We will be doing that in Customer portal > Settings > General Configuration - Change > Tracking codes > Before </BODY>. Here is the code snippet to use:

Do not forget to replace mycompany.ladesk.com with your real LiveAgent account URL, and xxxxxxxx with the real ID of your contact widget from the original integration code.

Before </BODY>:

<script type="text/javascript">
(function(d, src, c) { var t=d.scripts[d.scripts.length - 1],s=d.createElement('script');s.id='la_x2s6df8d';s.async=true;s.src=src;s.onload=s.onreadystatechange=function(){var rs=this.readyState;if(rs&&(rs!='complete')&&(rs!='loaded')){return;}c(this);};t.parentElement.insertBefore(s,t.nextSibling);})(document,
function(e){ LiveAgent.createButton('xxxxxxxx', e); });

Once you save your work, you are done. Feel free to check out customer portal and see contact widget only once you log in into the portal.