The Userorbit script connects your website or web application to Userorbit. It loads the widget and initializes the SDK for the current visitor or logged-in user.

Step 1: Get your script snippet

  1. Log in to Userorbit.

  2. Go to Settings → Widget.

  3. Select the HTML tab.

  4. Copy the generated snippet for your workspace.

Step 2: Add the snippet to your site

Paste the snippet before the closing </body> tag, or add it through your site tag manager.

<!-- START Userorbit SDK -->
<script type="text/javascript">
  !function(){
    var apiHost = "https://api.userorbit.com";
    var accountId = "YOUR_ACCOUNT_ID";
    var s=document.createElement("script");
    s.type="text/javascript",s.async=!0,s.src="https://cdn.userorbit.com/userorbit.umd.cjs",
    s.onload=function(){window.userorbit&&typeof window.userorbit.init==="function"&&window.userorbit.init({accountId:accountId,apiHost:apiHost})};
    var e=document.getElementsByTagName("script")[0];
    e.parentNode.insertBefore(s,e);
  }();
</script>
<!-- END Userorbit SDK -->

Step 3: Identify logged-in users

If your app has logged-in users, pass user identity during initialization. In JavaScript apps, you can also initialize through the package API:

import userorbit from "userorbit-js";

await userorbit.init({
  accountId: "YOUR_ACCOUNT_ID",
  apiHost: "https://api.userorbit.com",
  userId: "USER_ID_FROM_YOUR_APP",
  email: "person@example.com",
  name: "Jane Doe",
  attributes: {
    "user.role": "admin"
  }
});

User identity is set during initialization. There is no separate identify() method. Use setEmail() and setAttribute() to update identity after initialization.

Step 4: Verify installation

  1. Open your site in a browser.

  2. Check that the Userorbit script loads from https://cdn.userorbit.com/userorbit.umd.cjs.

  3. Confirm that window.userorbit is available in the browser console.

  4. Open the widget or trigger a test experience from Userorbit.

Was this page helpful?