session
    • 2 Minutes to read
    • Dark
      Light

    session

    • Dark
      Light

    Article summary

    Session parameters always refer to a complete session (visit). In the case of transmitting a parameter multiple times during a visit, the system only evaluates the first or last value of the parameter during the visit (based on the configuration in your account).

    An example of the utilization of a session parameter would be the login status of the user. By default, each visit would be indicated as "not logged-in" at the beginning. The successful login is passed to the same parameter and overwrites the first value.

    A session parameter cannot be used to add information to a specific webpage, but only to the complete visit. Please use page parameters if you want to analyze information on a specific page of your website or evaluate multiple values of a parameter in the same visit.

    • loginStatus: Pass the current login status of a user.

    • parameter: Session parameters always refer to a complete session (visit). If the value for the parameter is transmitted during a visit several times, only the first or last value is evaluated, based on the configuration of the Mapp Intelligence GUI.

    Methods

    The session object contains the following four methods, which are contained in the objects data and parameter:

    • set: Overwrites all existing values.

    • add: Overwrites only the corresponding values.

    • get: Returns the current configuration.

    • remove: Removes the current configuration or individual values.

    data

    set

    /**
     * @param {{
     *      [loginStatus=""]: string,
     *      [parameter={}]: {[number]: string}
     * }} data
     *
     * @returns {wtSmart.session.data}
     */
    wtSmart.session.data.set(data);

    add

    /**
     * @param {{
     *      [loginStatus]: string,
     *      [parameter]: {[number]: string}
     * }} data
     *
     * @returns {wtSmart.session.data}
     */
    wtSmart.session.data.add(data);

    get

    /**
     * @returns {{
     *      loginStatus: string,
     *      parameter: {[number]: string}
     * }}
     */
    wtSmart.session.data.get();

    remove

    /**
     * @param {string[]} [removeList]
     *
     * @returns {wtSmart.session.data}
     */
    wtSmart.session.data.remove(removeList);

    Example

    // set session data
    wtSmart.session.data.set({
    	loginStatus: 'login',
    	parameter: {
    		5: 'male'
    	}
    });
    
    // add session data
    wtSmart.session.data.add({
        loginStatus: 'logout'
    });
    
    // get session data
    var data = wtSmart.session.data.get();
      
    // remove all session data
    wtSmart.session.data.remove();
    
    // remove only loginStatus from session data
    wtSmart.session.data.remove(['loginStatus']);

    parameter

    set

    /**
     * @param {{[number]: string}} data
     *
     * @returns {wtSmart.session.parameter}
     */
    wtSmart.session.parameter.set(data);

    add

    /**
     * @param {{[number]: string}} data
     *
     * @returns {wtSmart.session.parameter}
     */
    wtSmart.session.parameter.add(data);

    get

    /**
     * @returns {{[number]: string}}
     */
    wtSmart.session.parameter.get();

    remove

    /**
     * @param {number[]} [removeList]
     *
     * @returns {wtSmart.session.parameter}
     */
    wtSmart.session.parameter.remove(removeList);

    Example

    // set session parameter
    wtSmart.session.parameter.set({
        1: 'male'
    });
    
    // add session parameter
    wtSmart.session.parameter.add({
        7: 'foo.bar'
    });
    
    // get session parameter
    var data = wtSmart.session.parameter.get();
      
    // remove all session parameter
    wtSmart.session.parameter.remove();
    
    // remove only session parameter 1
    wtSmart.session.parameter.remove([1]);

    Code Generator

    Use the code generator to create individual code that you can then integrate directly into the website.


    Was this article helpful?

    What's Next