Spectacle JS
Load
Initialize Spectacle tracking
The load() method initializes Spectacle tracking and must be called before using other methods like page(), track(), identify(), or group().
Method Signature
spectacle.load(workspaceId, options?)
Parameters
- workspaceId (required):
string- Your Spectacle workspace ID - options (optional):
LoadOptionsobject with:baseUrl?: string- Default: "https://t.spectaclehq.com"cookieDomain?: string- Explicitly define the domain to place the cookie on. Can be used when users land on subdomain A and later convert on subdomain B.autoTrackForms?: boolean- Automatically track form submissions as Identify (in case an email was found in the form data) and as Event. Default: falseautoTrackHubspot?: boolean- Automatically track HubSpot form (any version) submissions as Identify (in case an email was found in the form data). Default: trueautoTrackCalendly?: boolean- Automatically track Calendly bookings. Default: trueautoTrackUtmEmail?: boolean- Automatically track an Identify ifutm_emailis found in the URL. Default: trueexternalAnonCookie?: string- Rely on another cookie than the Spectacle cookie for the vistor's anonymous id.lens?: boolean- Enable Lens. Default: false
Key Features
- Sets up user identification cookies
- Initializes tracking analytics
- Enables automatic form tracking by default
- Handles cross-subdomain tracking via cookieDomain
Basic Usage
spectacle.load('workspace_123')
With Options
spectacle.load('workspace_123', {
cookieDomain: 'example.com',
autoTrackForms: true,
})