Shape · Time series

Sessionize

Groups events into sessions: a new session starts when the gap since the last event is longer than you set, such as 30 minutes.

Also known as: Clickstream sessions

How it works

Pick, usually, a Group by column such as the user id so sessions are numbered per user, and the Timestamp column. The Inactivity gap is a whole number of seconds, minutes, hours or days, 30 minutes by default. Within each group the rows are ordered by time and a new session starts when the time since the previous event is longer than the gap; a gap exactly equal to it stays in the session. The node appends session_id, counting 1, 2, 3 per group, and with Add session_seq also the event's 1-based position in its session. Rows with a NULL timestamp get NULL ids.

Inputs and outputs

Inputs

  • data — Table

Outputs

  • data — Table

Settings

The Attributes panel of Sessionize, as in the app: the controls work, but nothing runs — there is no data behind it.

The same settings, as the Assistant writes them
{
  timestampColumn: string
  partitionBy?: string[]
  gapValue: number
  gapUnit: "seconds"|"minutes"|"hours"|"days"
  includeSeq?: boolean
}

appends session_id (1, 2, … per partition; a new session starts when the time since the previous event EXCEEDS the gap) and, with includeSeq, session_seq (1-based index within the session); NULL timestamps get NULL ids

Example

Web events per visitor with a 30-minute timeout: group by user_id, timestamp column ts, gap 30 minutes, session_seq on.

user_idtssession_idsession_seq
u110:0011
u110:2012
u111:0521
u210:0211