--- title: "SessionIdentifier" slug: "sessionidentifier" updated: 2022-02-10T19:45:47Z published: 2022-02-10T19:45:48Z canonical: "docs.datajet.app/sessionidentifier" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.datajet.app/llms.txt > Use this file to discover all available pages before exploring further. # SessionIdentifier ## General: SessionIdentifier ## On a foreign (many-side) table, for the set of records corresponding to each key in the primary (one-side) table, create a sequence counter (an integer discrete field) for each set of records where the elapsed timestamp since the last entry seen is less than the specified duration, in seconds. ## Purpose Use this function to: - Organise timestamped data into user sessions of specified duration ## Return Value | Property | Value | | --- | --- | | **FieldType** | Integer | | **FieldSize** | Continuous | | **DataType** | Continuous | | **DataSize** | Integer | ```shell Example Return Value: 1.....N where N is the number of individual sessions that are identified. ``` ## Parameters | Parameter | JSON | Description | | --- | --- | --- | | **Table** | “targetTable”: “MyTableName” | The target table on which the new field will be created | | **Filter** | “dataset”: {DataSet_JSON} | Optional. If a filter is applied, records not in the filter recordset will be returned as null. | | **Function** | "function":"sessionidentifier" | SessionIdentifier | | **Primary Table** | “p1”: “PrimaryTableName” | A primary table that is linked to the target table on the key identifier. For example, if Table = [transactions], Primary Table could be [customer], where the 2 tables are linked on [cid] [transactions].[cid] ->[customer].[cid] | | **Timestamp** | “p2”:"DateTimeFieldName" | Required. The DateTime Field to use for calculating session intervals. *Supports:* - **DataType:** Continuous - **Field Type:** DateTime | | **Duration Secs** | “p3”:"#120" | Required. The number of seconds in a session. *Supports:* - **DataType:** - **Field Type:** - **Fixed Value:** For the specified primary key (e.g., cid=123): - If *[Record2_Timestamp - Record1_Timestamp]* is greater than [Duration Secs], then a new session identifier will be given to the current record. - If *[Record2_Timestamp - Record1_Timestamp]* is less than [Duration Secs] then the current record will be given the same session identifier as the previous record. Duration Secs must be provided in the format #N. e.g., - #120 = 2 minutes - #600 = 10 minutes | ## JSON Sample ```json { "method": "BuildBakedField", "project": "Internet1", "targetTable": "webaction", "overwrite": true, "name": "Session_10mins", "function": "sessionidentifier", "p1": "UniqueUser", "p2": "timestamp", "p3": "#600" } ``` ## Usage Notes See Also: - Engineering | Expression Field - DateTime fields ## Example | Example | Details | | --- | --- | | **Description** | **Group user transactions into sessions of no more than 2 mins inactivity** | | **Input** | - Table: = [transactions] - Filter: = [No Filter] - **Function: = SessionIdentifier** - Primary Table:= customer - Timestamp:= TimeStampe - Duraton Secs:= #120 - Name: =Session_2mins | | **Sample** | ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/Gen_SessionIdentifier_Example.png) |