Sessions

Prev Next

1 Overview

Session parameters refer to an entire visit (also known as a session). They are used when you want to persist a value throughout the entire visit rather than just a single page view or interaction.

A common example is the login status of a user. Initially, a session might be classified as "not logged-in". Once the login occurs, the value can be updated to reflect the new status. Depending on your configuration, only the first or last value passed during the session will be considered.

Note: A session in Mapp Intelligence corresponds to a Visit in the frontend. Technically, the terms "session" and "visit" are used interchangeably.


2 Configurable Properties

Property

Description

Request Parameter

loginStatus

Indicates whether a user is logged in during a session. This value can be passed once per visit.

cs800

parameter

Tracks additional custom data points for a session. More details below.

cs[ID]

2.1 Parameters

Session parameters are additional attributes that can be configured to collect custom data relevant to the entire session. You must define these parameters in the system configuration (Configuration > Custom Parameters > Session Parameter), including the ID and the data type (text or number).

  • Values can be analyzed in Visitors > Session Parameters if they are of type text, or as metrics if they are of type number.

Note: If a session parameter is passed multiple times during a visit, Mapp Intelligence will evaluate either the first or last value based on the system configuration.

For setup instructions: How to Set Up Custom Parameters


3 Objects and Methods

Mapp Intelligence provides two tracking objects for sessions:

  • data: Use this object to configure the full session setup.

  • parameter: Use this object to manage session parameters independently.

Each object supports four methods:

Method

Description

set()

Overwrites all existing values.

add()

Adds or updates values. Existing values remain unchanged unless replaced.

get()

Returns the current configuration.

remove()

Deletes the entire configuration or selected values.

3.1 data – Full Session Configuration

/**
 * @param {{
 *      [loginStatus=""]: string,
 *      [parameter={}]: {[number]: string}
 * }} data
 *
 * @returns {wtSmart.session.data}
 */
wtSmart.session.data.set(data);
/**
 * @param {{
 *      [loginStatus]: string,
 *      [parameter]: {[number]: string}
 * }} data
 *
 * @returns {wtSmart.session.data}
 */
wtSmart.session.data.add(data);
/**
 * @returns {{
 *      loginStatus: string,
 *      parameter: {[number]: string}
 * }}
 */
wtSmart.session.data.get();
/**
 * @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']);

3.2 parameter – Session Parameters Only

/**
 * @param {{[number]: string}} data
 *
 * @returns {wtSmart.session.parameter}
 */
wtSmart.session.parameter.set(data);
/**
 * @param {{[number]: string}} data
 *
 * @returns {wtSmart.session.parameter}
 */
wtSmart.session.parameter.add(data);
/**
 * @returns {{[number]: string}}
 */
wtSmart.session.parameter.get();
/**
 * @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]);

4 Code Generator

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