Overview
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
Log in to Userorbit.
Go to Settings > Widget.
Select the HTML tab.
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's tag manager.
<!-- START Userorbit SDK -->
<script type="text/javascript">
!function(){
var apiHost = "https://api.userorbit.com";
var accountId = "YOUR_ACCOUNT_ID";
var userId = "YOUR_USER_ID"; // optional
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,userId:userId})};
var e=document.getElementsByTagName("script")[0];
e.parentNode.insertBefore(s,e);
}();
</script>
<!-- END Userorbit SDK -->Use the generated accountId from Userorbit. If you self-host or proxy the API, update apiHost; otherwise leave it as https://api.userorbit.com.
Step 3: Identify logged-in users
If your app has logged-in users, pass a stable user ID 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"
}
});Step 4: Verify installation
Open your site in a browser.
Check that the Userorbit script loads from
https://cdn.userorbit.com/userorbit.umd.cjs.Confirm that
window.userorbitis available in the browser console.Open the widget or trigger a test experience from Userorbit.