onInit ( data )

Is triggered after the chat widget initializes in one of the statuses (Online/Offline).

The data object is passed as an argument, containing the following properties:

PropertyTypeDescription
status integer New status that the chat widget initialized in. 1 -- Online, 2 -- Offline.
real boolean true if that is a status change and false if repeat initialization of the chat widget took place (for instance, when arriving at a new page)

Example

The example demonstrates the ability to send from your webstie and into Netrox SC the data about the visitor.

var clientName  = "James";    // The visitor name is written into a variable. 
                                // For instance, it is inserted here by the server script.
var clientID    = "CL_5646542"; // ID of the buyer, for instance, in an Internet store

// Event handler
function setClientData() {
    // Let us send the visitor name into the system, having checked tha the name has not been recorded yet
    if (nsc_Visitor.getParameter("nick") == "") {   
        nsc_Visitor.setParameter("nick", clientName);
    }
    // Let us send the buyer ID into the system
    nsc_Visitor.setParameter("custom1", clientID);

    // The transferred ID will be available to the operators in the "Field 1" field of the visitor list
}

/*
 * Using jQuery
 */
$(document).on("netroxinit", function(event, data) {
    if (!data.real) {   // Not status change but chat window initialization on a new page
        setClientData();
    }
});       

/*
 * Or via the nsc_API object.
 */

nsc_API = {
    onInit: function(data) {
        if (!data.real) setClientData();
    }
};      

All rights reserved. Copyright © 2017 Netrox SC
Host CMS