Skip to main content
Sends a session start event to Constructor.io’s API. This should be called when a user first arrives on your site or when a new session begins.

Method Signature

constructorio.tracker.trackSessionStart(networkParameters?)

Parameters

networkParameters
object
Optional parameters for the network request

Returns

Returns true on success or an Error object if the tracking call fails validation.

Example

import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';

const constructorio = new ConstructorIOClient({
  apiKey: 'YOUR_API_KEY',
});

// Track session start
constructorio.tracker.trackSessionStart();

Example with Network Parameters

// Track session start with custom timeout
constructorio.tracker.trackSessionStart({
  timeout: 5000,
});

When to Use

Call trackSessionStart() in these scenarios:
  • When a user first lands on your site
  • After a period of inactivity (session timeout)
  • When a user logs in or creates an account
  • At the start of a new browsing session

Session Management

The SDK automatically generates and manages session IDs. Each session start event is associated with:
  • Session ID: Unique identifier for the current session
  • Client ID: Unique identifier for the user’s browser
  • User ID: Optional user identifier if set via client options

API Endpoint

This method sends a GET request to:
/behavior?action=session_start

Build docs developers (and LLMs) love