JavaScript SDK

The Edgewise JavaScript SDK provides a simple way to integrate Edgewise with your website. Built on top of the Edgewise GraphQL API, the SDK provides tools for adding Edgewise-powered components, tracking visitor activity, and accessing Edgewise data directly from JavaScript.

Edgewise Components

Edgewise Components are ready-to-use UI components for adding Edgewise functionality to your website, including:

  • Lead registration and contact forms
  • Project inventory and availability
  • Edgewise Messenger, our AI-powered website chatbot

Components connect directly with Edgewise, reducing the amount of custom integration work required to build common website experiences.

Visitor Tracking

The SDK can identify and track returning website visitors, allowing activity on your website to be associated with leads in Edgewise.

This provides additional context around a lead's engagement and can be used by other Edgewise features and automations.

API Access

The SDK provides a convenient JavaScript interface to the Edgewise API. Common data and operations can be accessed through simple SDK methods without having to write GraphQL queries directly.

For more advanced use cases, the underlying GraphQL API remains available when additional flexibility is required.

Installation

To use the Edgewise JavaScript SDK, include edgewise.js on your website. The SDK is hosted on the Edgewise CDN.

For most websites, we recommend loading and initializing the SDK in the <head> of every page and assigning the instance to window.edgewise:

<head>
  <script src="https://libs.edgewise.cloud/edgewise.js@1"></script>
  <script>
    window.edgewise = Edgewise()
  </script>
</head>

Initializing the SDK on every page allows Edgewise to begin tracking a visitor as soon as they enter your website. Attribution information, including UTM parameters, is preserved as the visitor navigates between pages.

This allows Edgewise to retain the original attribution even when a visitor lands on one page but later submits a registration or contact form from another.

The initialized SDK is then available throughout the page using window.edgewise.

Edgewise Components

The JavaScript SDK includes Edgewise Components, a collection of ready-to-use UI components for adding Edgewise functionality to your website.

Components can be used to build experiences such as lead registration forms, project inventory and availability, and Edgewise Messenger.

For installation, configuration, and available components, see Edgewise Components.

API Access

The JavaScript SDK provides a convenient interface for accessing data from the Edgewise GraphQL API without having to write GraphQL queries directly.

Projects

Retrieve a project by ID:

const project = await window.edgewise.projects.get(PROJECT_ID)

Units

Retrieve all units for a project:

const units = await window.edgewise.units.list({
  projectId: PROJECT_ID
})

Retrieve a unit by ID:

const unit = await window.edgewise.units.get(UNIT_ID)

Floor Plans

Retrieve all floor plans for a project:

const floorPlans = await window.edgewise.floorPlans.list({
  projectId: PROJECT_ID
})

Retrieve a floor plan by ID:

const floorPlan = await window.edgewise.floorPlans.get(FLOOR_PLAN_ID)

These methods provide a simple interface for common data queries while handling the underlying GraphQL requests for you.

Edgewise Analytics

Edgewise Analytics provides website and visitor tracking through the Edgewise JavaScript SDK. If you're familiar with tools like Google Analytics or Meta Pixel, the basic model should feel familiar.

Once the SDK is initialized, you can initialize an Analytics tracker and begin sending events to Edgewise.

Creating a Tracker

Before tracking events, create a tracker in Edgewise under your organization's settings. Each tracker has a unique Tracker ID that identifies the source of the events.

Initialize Analytics using your Tracker ID:

window.edgewise.analytics.init("TRACKER_ID")

If you followed the recommended SDK installation and initialized window.edgewise on every page, no additional SDK installation is required.

Tracking Events

Events are tracked using analytics.push(). The method accepts an event name and, optionally, additional properties associated with the event.

For example, to track a page view:

window.edgewise.analytics.push("PageView")

To include additional properties:

window.edgewise.analytics.push("Contact form submit", {
  form: "Contact Us"
})

Edgewise automatically captures additional context with each event, such as the page URL, browser, and screen size.

Page Views

Edgewise Analytics does not automatically track page views. To record a page view, explicitly push the standard PageView event:

window.edgewise.analytics.push("PageView")

This gives you control over when a page view is recorded and also supports websites where navigation does not always correspond directly to a page load.

PageView is a standard Edgewise event. Analytics also supports custom events for tracking other interactions and activity on your website.


Table of Contents