Perform an action in a custom code before chat launch

I would like to set a cookie or do any other action for the visitor who is about to launch chat window, how can I do that?

For embedded chat window installation:

Please see LiveHelpNow JS SDK call back functions to accomplish custom functionality based on events, such as chat window open, closed, etc.

Here's an example of adding custom functionality upon pre-chat form being shown.


function lhnJsSdkPreChatShown(){
  // This function will be called when the prechat form is shown.
  //Do something



For popup window (legacy):

You would need to override LiveHelpNow chat launch code by adding "CustomOpenLHNChat" JavaScript function to your page.
This assumes that you have LiveHelpNow chat button code installed on the page.

Please replace LHNACCOUNTID with NUMERIC portion of your LiveHelpNow account #  and YOUR_CODE with whatever action you would like to perform for the visitor.


function CustomOpenLHNChat(){

if (typeof lhnWin !== 'undefined' && lhnWin){

if (!lhnWin.closed){


setTimeout(lhnWin.focus(), 10);

return false;




var wleft = (screen.width - 580-32) / 2;

var wtop = (screen.height - 420 - 96) / 2;

YOUR_CODE;'' + lhnDepartmentN + '&zzwindow=' + lhnWindowN, 'lhnchat',
'left=' + wleft + ',top=' + wtop +',width=580, height=435,toolbar=no,location=no,directories=no, status=yes,menubar=no,scrollbars=no,copyhistory=no,resizable=yes');

return false;



Related articles