Create a code event in Userorbit before calling it from your application. The SDK matches the key you pass to track() against that saved event.

1. Create the code event

  1. Open Events in the intended workspace.
  2. Select Add Events.
  3. Enter an Event title, such as Workspace Created, and an Event description explaining when it should fire.
  4. Under Event Type, choose Code.
  5. Set Key to workspace_created.
  6. Select Create.

The title is the readable label used when configuring experiences. The key is the exact string your code passes to track() and the name sent to Analytics for this code event. Keys are case-sensitive and must be unique. The key field is read-only when editing an existing event, so choose it before adding calls to your application.

2. Initialize the browser SDK

Use your workspace's installation snippet or the userorbit-js package. Call initialization once from browser code:

import userorbit from "userorbit-js";

await userorbit.init({
  accountId: "YOUR_ACCOUNT_ID",
  analytics: { enabled: true },
});
JavaScript

Use the Account ID from the workspace that contains the event. Enabling analytics in code does not override unavailable product access or disabled workspace/widget features.

If the person is signed in, identify them with a stable application ID:

await userorbit.identify("usr_demo_1042", {
  attributes: { plan: "business" },
});
JavaScript

Identification is not required before the first event. A browser without an explicit identity may use a generated or stored distinct ID.

3. Track the successful action

After your application has successfully created a workspace, call:

await userorbit.track("workspace_created");
JavaScript

Use the saved Key, not the event title. Fire the call from the successful completion path of your product action. A button click that fails to create a workspace should not count as workspace_created.

The browser track() API is not a general-purpose arbitrary-properties Analytics API. Its optional hiddenFields argument is not forwarded as custom Analytics event properties by the current code-event path. Use the event-only call above for this setup.

4. Verify the result

  1. Open Analytics → Live Events in the project expected to receive the data.
  2. Perform the action once with a dedicated test account.
  3. Find workspace_created and confirm the identity and timestamp.
  4. Repeat a failed or cancelled action and confirm it does not produce this success event.
  5. If the event triggers an experience, test that experience's publication, audience, and delivery rules separately.

A resolved SDK call is not a delivery receipt. Check the received event instead of relying only on a console message.

If the event is missing

Confirm that the event exists with type Code, that the key matches exactly, and that the SDK is using the same workspace. Unknown keys produce an invalid_code SDK error. Check the browser's first failed Userorbit request and the selected Analytics project.

Read SDK Troubleshooting Reference for a fuller diagnostic checklist and How to track product events for naming and instrumentation guidance.

Was this helpful?