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

  1. workspaceId (required): string - Your Spectacle workspace ID
  2. options (optional): LoadOptions object 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: false
    • autoTrackHubspot?: boolean - Automatically track HubSpot form (any version) submissions as Identify (in case an email was found in the form data). Default: true
    • autoTrackCalendly?: boolean - Automatically track Calendly bookings. Default: true
    • autoTrackUtmEmail?: boolean - Automatically track an Identify if utm_email is found in the URL. Default: true
    • externalAnonCookie?: 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,
})
Previous
Calendly
Next
page()