Skip to content

Vanilla JavaScript

For a browser-rendered application, put the CDN loader in your shared HTML shell and call the global API only after the user action occurs.

index.html
<head>
<script async src="https://cdn.movcues.com/v1.js" data-site-id="YOUR_SITE_ID"></script>
</head>
billing.js
document.querySelector("[data-upgrade]")?.addEventListener("click", () => {
window.analytics.event("upgrade_clicked", { surface: "billing" });
});
function onSignedIn(user) {
window.analytics.identify(user.id, {
plan: user.plan,
workspace_id: user.workspaceId,
});
}

Do not identify from an untrusted URL parameter or form field. Use the stable ID that your own app has already authenticated.

function onSignedOut() {
window.analytics.reset();
}

reset() creates a fresh anonymous and session context. It prevents the next person using the same browser session from being associated with the previous identity.