bool onMessageSend ()

The message sending event in the online chat widget window. This has to return the "true" or "false" value (and ether send or not send a message accordingly).

Examples

  1. Using jQuery 
    $(document).on("netroxmessagesend", function(event) {
    
            // Your handler code
    
            return true;
    
    });       
  2. Using the nsc_API object
    nsc_API = { /* ... */ };
    
    nsc_API.onMessageSend = function() {
    
            // Your handler code
    
            return true;
    
    };        
  3. Google Analytics integration using the Universal Analytics engine (analytics.js)

    This code will enable you to track the number of chats as a Google Analytics goal. It can be placed in the <head> section of the website pages where GA is on. If you initialized Google Analytics with a modified function title, correct the value in the line 11 of this code.

    Note that starting June 2015 it is not neccessary to send data to analytics engine this way because of introducing of the analytics engine integration built-in feature.
    <!-- START NETROX SC Google Analytics Integration Code -->
    <script type="text/javascript">
        /*
         *  Let's create a handler function.
         */
    
        function netrox2GA() {
            var minVisitorMessages  = 2,        // Minimum number of visitor messages 
                                                // that triggers the filing of an established chat 
                counterVariableName = "flag1",  // Visitor variable for message counter storage
                gaFunction          = ga,       //  Google Analytics interface function.
                                                // The default name is ga
                categoryName        = "Netrox", // Category name in GA
                actionName          = "Chat";   // Action name in GA  
    
            // Obtaining the number of messages prior to sending a new one
            var messageCount = nsc_Visitor.getParameter(counterVariableName);   
    
            // If there are fewer messages than the analytics forwarding threshold,
            // just increase the counter by 1
            if (messageCount < minVisitorMessages) 
            {
                nsc_Visitor.setParameter(counterVariableName, messageCount + 1);
            }
            // If the sending threshold is reached, carry out the data send
            else if (messageCount == minVisitorMessages)
            {
                if (typeof gaFunction != "undefined") gaFunction(
                    'send', 
                    'event', 
                    categoryName, 
                    actionName, 
                    { 'nonInteraction': 1}
                );
                nsc_Visitor.setParameter(counterVariableName, messageCount + 1);
            }
            return true;
        }
    
        if (typeof nsc_API == "undefined") nsc_API = {};
        nsc_API.onMessageSend = netrox2GA;        
    </script>
    <!-- END NETROX SC Google Analytics Integration Code -->
Remember that the functions must necessarily be either "true" or "false". The return of an undefined value equals to prohibition on message sending ("false").

All rights reserved. Copyright © 2017 Netrox SC
Host CMS