# Session (web analytics)

In web analytics, a session, or visit is a unit of measurement of a user's actions taken within a period of time or with regard to completion of a task. Sessions are also used in operational analytics and provision of user-specific recommendations. There are two primary methods used to define a session: time-oriented approaches based on continuity in user activity and navigation-based approaches based on continuity in a chain of requested pages.

## Definition

The definition of "session" varies, particularly when applied to search engines. Generally, a session is understood to consist of "a sequence of requests made by a single end-user during a visit to a particular site". In the context of search engines, "sessions" and "query sessions" have at least two definitions. A session or query session may be all queries made by a user in a particular time period or it may also be a series of queries or navigations with a consistent underlying user need.

## Uses

Sessions per user can be used as a measurement of website usage. Other metrics used within research and applied web analytics include session length, and user actions per session. Session length is seen as a more accurate alternative to measuring page views.
Reconstructed sessions have also been used to measure total user input, including to measure the number of labour hours taken to construct Wikipedia. Sessions are also used for operational analytics, data anonymization, identifying networking anomalies, and synthetic workload generation for testing servers with artificial traffic.

## Session reconstruction

Essential to the use of sessions in web analytics is being able to identify them. This is known as "session reconstruction". Approaches to session reconstruction can be divided into two main categories: time-oriented, and navigation-oriented.

### Time-oriented approaches

Time-oriented approaches to session reconstruction look for a set period of user inactivity commonly called an "inactivity threshold." Once this period of inactivity is reached, the user is assumed to have left the site or stopped using the browser entirely and the session is ended. Further requests from the same user are considered a second session. A common value for the inactivity threshold is 30 minutes and sometimes described as the industry standard. Some have argued that a threshold of 30 minutes produces artifacts around naturally long sessions and have experimented with other thresholds. Others simply state: "no time threshold is effective at identifying [sessions]".
One alternative that has been proposed is using user-specific thresholds rather than a single, global threshold for the entire dataset. This has the problem of assuming that the thresholds follow a bimodal distribution, and is not suitable for datasets that cover a long period of time.

### Navigation-oriented approaches

Navigation-oriented approaches exploit the structure of websites - specifically, the presence of hyperlinks and the tendency of users to navigate between pages on the same website by clicking on them, rather than typing the full URL into their browser. One way of identifying sessions by looking at this data is to build a map of the website: if the user's first page can be identified, the "session" of actions lasts until they land on a page which cannot be accessed from any of the previously-accessed pages. This takes into account backtracking, where a user will retrace their steps before opening a new page. A simpler approach, which does not take backtracking into account, is to simply require that the HTTP referer of each request be a page that is already in the session. If it is not, a new session is created. This class of heuristics "exhibits very poor performance" on websites that contain framesets.