Developer Reference5 min read

SDK API Reference

Methods on the global optimo object — track, identify, get variants, consent.

Browse docs

SDK API Reference

The Otter A/B SDK exposes a global optimo object you can call from anywhere on the page. Use it to track events, identify users, look up variant assignments, and manage consent.

Most of the SDK is invisible — variant assignment, DOM application, conversion tracking for click and pageview goals all happen automatically. The methods below are what you reach for when you need to drive the SDK from your own code: tracking custom events, attributing revenue, identifying logged-in users for cross-device assignment, and reading the current variant so you can branch your application logic.

The object lives at window.optimo once the SDK has loaded. Since the script is async, you can queue calls before the SDK is ready by pushing onto the queue at window.optimoq — the install snippet initializes that array for you, and the SDK replays the queue once it's initialized.

// Track a custom event
optimo.track("signup_complete", {
  plan: "pro",
  source: "landing_page"
});

// Track revenue
optimo.revenue({
  value: 49.99,
  currency: "USD",
  order_id: "ORDER-1234" // optional: counts this order only once
});

More methods you can call

optimo.converted("test-key")

Record a conversion on a test’s main goal from your own code — for a custom in-app action that isn’t a plain click or page visit. Counts once per visitor.

optimo.uuid()

Returns a promise with the visitor’s anonymous ID once the SDK is ready. Pass it to your server so a conversion you record from the backend is tied to the right visitor.

optimo.reload()

Ask Otter A/B to fetch the visitor’s active tests again. The SDK already does this on in-app navigation, so you only need it for manual control in a single-page app.

optimo.execute("test-id")

Re-apply a specific test’s changes to the page. Useful if your single-page app re-rendered and wiped a variant’s changes.

Frequently asked questions

Quick answers to the questions teams ask most about this part of Otter A/B.