Skip to main content
Source code Package

Session source

Standalone session detection and management that can be composed with any walkerOS source.

Installation

Install the packages:

Loading...

Configure in your code:

Loading...

Detection methods

The session source uses two complementary methods:

MethodStorageUse Case
WindowNonePrivacy-first, per-page session
StoragelocalStorageCross-page session tracking

Window-based detection

Without storage, session detection relies on browser signals:

Navigation type:

Loading...

Marketing parameters:

UTM and other marketing parameters trigger session start. The following are recognized by default:

Loading...

To capture additional URL parameters, pass a parameters map. Each entry maps a URL parameter name to the property name it should be stored as in the session data:

Loading...

Storage-based detection

With storage: true, sessions persist across page loads:

Loading...

Session lifecycle:

┌─────────────────────────────────────────────────────────────┐
│ Session Timeline │
├─────────────────────────────────────────────────────────────┤
│ │
│ User visits Page 2 Page 3 30min idle │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ [Session 1] ─────────────────────────────► [Expires] │
│ id: abc123 │
│ │
│ User returns │
│ │ │
│ ▼ │
│ [Session 2] │
│ id: def456 │
└─────────────────────────────────────────────────────────────┘

Storage keys:

KeyDefaultDescription
sessionKeyelbSessionIdlocalStorage key for session ID
deviceKeyelbDeviceIdlocalStorage key for device ID

Session start event

When a new session is detected, the source pushes a session start event and sets the user's session and device IDs on the collector:

Loading...

isStart vs isNew:

FieldMeaning
isStart: trueA new session began on this page load
isNew: trueThis is the device's very first session ever (storage mode only)

A returning visitor starting their second session has isStart: true but isNew: false. isNew only appears in storage mode since window-only mode has no device memory.

Click ID parameters are stored twice: clickId identifies which platform originated the click (e.g. 'gclid'), and a separate field stores the actual value (e.g. gclid: 'AW-123...'). This makes it easy to filter by platform without inspecting the value.

Configuration

PropertyTypeDescriptionMore
storagebooleanEnable persistent storage for session/device IDs
consentstring | arrayConsent key(s) required to enable storage mode
lengthnumberSession timeout in minutes
pulsebooleanKeep session alive on each event
sessionKeystringStorage key for session ID
sessionStorage'local' | 'session'Storage type for session
deviceKeystringStorage key for device ID
deviceStorage'local' | 'session'Storage type for device
deviceAgenumberDevice ID age in days
cbfunctionCustom session callback function or false to disable

Session detection adapts to consent state:

Consent StateBehavior
No consentWindow-only detection (no storage)
Consent grantedStorage-based with device ID
Consent revokedFalls back to window-only
Loading...

Pulse mode

With pulse: true, the source updates the session's last-seen timestamp on each page load without counting it as a new page view and without triggering a new session start event. Use this for heartbeat-style presence tracking where you want to extend session lifetime without inflating runs:

Loading...

Custom session callback

The cb setting lets you hook into session detection. It receives the detected session data, the collector instance, and the default callback:

Loading...

Set cb: false to completely disable the default behavior — no user commands and no session start event will be emitted. This is useful when you want full control over what happens after detection.

Next steps

💡 Need implementation support?
elbwalker offers hands-on support: setup review, measurement planning, destination mapping, and live troubleshooting. Book a 2-hour session (€399)