Basic Initialization
The only required parameter is your Constructor.io API key:Configuration Options
Required Parameters
Your Constructor.io API key. This authenticates your application with the Constructor.io service.
Service URLs
Customize API endpoints for different Constructor.io services:The base URL for Constructor.io API requests (search, autocomplete, browse, recommendations).
The base URL for the Quizzes API.
The base URL for the AI Shopping Agent API.
The base URL for the Media API (banner ads and display advertising).
User Identification
Identify and segment users for personalized experiences:A unique identifier for the current client/device. If not provided, the SDK automatically generates one using the
constructorio-id module.In DOM-less (server-side) environments, you must provide a
clientId.A unique identifier for the current user session. If not provided in browser environments, the SDK automatically generates one using the
constructorio-id module.In DOM-less (server-side) environments, you must provide a
sessionId.Your internal user identifier. Use this to tie Constructor.io events to your own user tracking system.
An array of user segment names for personalization. See User Segments for more details.
Key-value pairs defining A/B test assignments for the user. See User Segments for more details.
Tracking Configuration
Control how tracking events are sent to Constructor.io:When
true, enables automatic sending of tracking events to Constructor.io. Events are queued and sent asynchronously.Delay in milliseconds before sending queued tracking events. This helps batch events and avoid sending too many requests.
Include the page referrer (origin URL) with tracking events. Also includes UTM parameters if present.
Event Dispatcher Options
Configure the event dispatcher for custom event handling:Configuration for the internal event dispatcher that emits custom DOM events.
Event Dispatcher Properties
Event Dispatcher Properties
Whether to dispatch custom events on the
window object (e.g., cio.client.instantiated).Wait for the Constructor.io beacon to load before dispatching events. The beacon is loaded from legacy Constructor.io integrations.
Network Configuration
Custom fetch implementation. By default, the SDK uses the native Fetch API. Provide your own if you need custom request handling.
Global network settings applied to all requests.
Network Parameters
Network Parameters
Request timeout in milliseconds. Can be overridden in individual method calls.
Advanced Options
Options passed to the
constructorio-id module for client and session ID generation.Storage location for the humanity check flag. Use
'session' for sessionStorage or 'local' for localStorage.The humanity check prevents bot traffic from being tracked.Enable beacon mode for tracking requests. When enabled, adds a
beacon=true parameter to POST requests.Complete Configuration Example
Updating Configuration at Runtime
You can update certain client options after initialization using thesetClientOptions method:
Only the following options can be updated at runtime:
apiKeyuserIdsegmentstestCellssendTrackingEventssessionId(only in DOM-less environments)
Server-Side Usage
When using the SDK in a server-side (DOM-less) environment, you must provideclientId and sessionId: