nsc_Visitor.getCurrentPage()

Returns the object describing the site's current page.

Return object structure

PropertyTypeDescription
href String Page full URL Corresponds to window.location.href
search String Request string parameters for the page. Corresponds to window.location.search
start Integer Date and time of page entrance. Presented as the number of milliseconds that have passed since the midnight of January 1, 1970 GMT
title String Page title Recorded as of the time of chat widget code upload
The majority of properties in the context of the current page are not very useful due to that fact that they can be obtained via the window.location properties or via document.title. The start property can be of interest, capable of being used to calculate the time spent on the page.

Use-case

/* The obtaining of information on the time spent on the page by the visitor as of the time of sending out the message */

$(function() {
    // Adding the listener of the message sending event
    $(document).on('netroxmessagesend', function(event) {
        
        var currentTime = (new Date()).getTime(),               // Current time
            startTime   = nsc_Visitor.getCurrentPage().start,   // Time of entering the page
            timeOnPage = Math.round((currentTime - startTime)/1000);    // Bringing it down to seconds and rounding off to an integer value
            
           alert("Message sent after " + timeOnPage + " seconds of staying on the current page");

    });
});

All rights reserved. Copyright © 2017 Netrox SC
Host CMS