Functions

Overview

The Cubed tag has a couple of functions that can be overidden to implement custom clientside logic, realtive to the current state of the Cubed vscr object.
These should be added with the base tag, after setAccount has been called.

Pre Tag Fire

This function is to allow you to set any clientside logic based on the state of vscr object before the tag is fired to our server. The state objects hold properties such as visitor token and the visit token, see table below for more details.
This function is not intended as a way to manipulate the vscr object or its state. It is provided as a way of using the current state of the tag to perform other actions on the page.

vscr.push(["onPreFire", function(state) {

}]);

Note

Do NOT use this function to set/modify state object variables, please use the relative functions mentioned above.

Tag Fire Complete

This function is called once the page has recieved a response from our Data Collection Server. The function is called with the Visitor Token, and CASK (Cubed Authentication Server Key).
These can be used together to make requests to our external APIs, such as the VisScore Service.

vscr.push(["onTagComplete", function(vid, cask) {

}]);

Note

The CASK is relative to the Visitor Token, and can only be used with that Id to obtain information.

Example (using jQuery):

vscr.push(["onTagComplete", function(accountToken, visitorId, sessionId, cask) {
    jQuery.ajax({
        url: 'https://api.withcubed.com/visscore',
        type: 'get',
        data: {
            'aid': accountToken,
            'vid': visitorId,
            'cask': cask,
        },
        success: function(data) {

        },
    })
}]);