Optimize for non-Webflow sites

Get started with Optimize APIs

Updated

Learn what each Optimize API does and where to find details.

Optimize provides a set of JavaScript and REST APIs to help you control variation delivery, define targeting attributes, and track goals. This page gives a high-level overview of each API and links to detailed documentation for implementation.

JavaScript API setup

All JavaScript APIs must be wrapped in a ready() callback to ensure they run after the snippet loads.

API Description
ready() Required wrapper for all JavaScript API calls

Trigger snippet activation

Single-page apps (SPAs) must manually trigger the Optimize snippet using activate().

API Description
activate() Manually activates the snippet in single-page apps

Track recorded variations

Use onVariationRecorded() to register a callback that logs which variation was seen.

API Description
onVariationRecorded() Registers a callback when a variation is recorded

Attribute APIs

Use these APIs to set, retrieve, or delete custom attributes for targeting, personalization, or machine learning.

API Description
setAttributes() Set user or pageview-scoped attributes
getAttributes() Get specific attributes by name
getAllAttributes() Retrieve all attributes for a given scope
deleteAttributes() Remove one or more attributes
deleteAllAttributes() Clear all attributes in a scope

Track custom goals

Use the sendEvent() API to trigger goal tracking for actions like form submissions or purchases.

API Description
sendEvent() Trigger custom goal tracking with optional monetary value

Track offline conversions

If your customer journey ends offline — e.g., over the phone, in-person, or through a CRM — you can use this API to attribute those conversions back to your Optimize optimizations.

API Description
setUserId() Client-side API that identifies a visitor using a known user ID
POST /event Server-side HTTPS API that sends offline conversion data to Optimize

Fetch optimization data

The REST API provides read-only access to your optimization and variation configuration as JSON.

API Description
GET /customer/{accountId} Returns experience and variation config via JSON

Deprecated APIs

These APIs have been replaced by onVariationRecorded() and are no longer recommended:

API Description
getSelectedVariationIds() Returned a map of variation IDs per optimization
getSelectedVariationNames() Returned verbose metadata including campaign info

Important

Deprecated APIs may not capture all variation recordings. Use onVariationRecorded() instead.