Session types

Discover the session-related types available in CQL.

Session types refer to data types representing information about a single user interaction with your application.

Each session type is specific to a channel, like web or mobile. This distinction is important to account for the unique characteristics of each context. For example, a web session includes the initial page the user landed on, which is not relevant for a mobile session where there is no concept of a page.

This summary provides an overview of the session-related types:

TypeDescription
Web sessionA summary of a user's activity in a web application.
Web session statisticsAggregate statistics about a web session.

Web session

This type represents a summary of a user's activity in a web application, providing valuable insight into user behavior and engagement.

In addition to the properties listed below, the web session allows for additional properties called custom attributes. These attributes are useful if you want to store additional information that is only relevant during the session. For example, you could set a plan attribute to store the plan the user selected and use it later in the session for personalization purposes.

Although these custom attributes are not part of the type definition, you can access them just like any other property:

session's plan
Try in Playground

When accessing a property, if there is a custom attribute and a predefined attribute with the same name, the custom attribute takes precedence. However, it does not overwrite the predefined attribute — it simply hides it. Removing the custom attribute would make the predefined attribute visible again.

Properties

These are the available properties:

start

The start time of the session, corresponding to the time of the first interaction in the session.

end

The end time of the session, corresponding to the time of the last interaction in the session.

duration

The duration of the session until the last interaction. It is calculated as the difference between the start time and the end time.

landingPage(optional)

The URL of the page the user landed on in the current session. It is not available if the starting page is unknown.

referrer(optional)

The URL of the page that linked to the page the user landed on in the current session. It is not available if the initial page is accessed directly.

stats

The aggregate statistics of the session.

<attribute>(optional)

A custom attribute, where /*<attribute>*/ is the name of the attribute.

Web session statistics

This type provides aggregate information about a user's web session. It is intended to provide helpful overall metrics, such as total page views, tab views, and orders placed.

Properties

These are the available properties:

pageviews

The number of page views in the session. It starts at 1 when the session starts and increases each time the user navigates to a page other than the one they are currently on.

tabviews

The number of times the user has switched tabs during the session. It starts at 1 when the session begins and is incremented each time the user switches back to the tab.

orders

The number of orders placed during the session. It starts at 0 when the session begins and is incremented each time the user places an order.