Skip to content

Installation

Install Movcues with a script tag for the quickest setup, or use the ES module in a bundled application. Both methods expose the same core tracking API. After installing, use the verification steps below to confirm the SDK is running.

Add the loader once to your HTML document, before the closing </head> tag. The data-site-id attribute lets the SDK initialize automatically.

<script
async
src="https://cdn.movcues.com/v1.js"
data-site-id="YOUR_SITE_ID"
></script>

The Site ID is required. The browser SDK uses this public identifier; do not put secret keys, private API URLs, or server credentials in the script tag.

If code needs to call Movcues before the asynchronous script has loaded, create the command queue first:

<script>
window.analytics = window.analytics || function () {
(window.analytics.q = window.analytics.q || []).push(arguments);
};
window.analytics("event", "pricing_opened", { source: "header" });
</script>
<script async src="https://cdn.movcues.com/v1.js" data-site-id="YOUR_SITE_ID"></script>

The loader drains queued commands when it installs. A queued init command takes precedence over automatic initialization from the script tag.

If your app receives the Site ID after it starts, initialize the browser global when the value is available:

analytics.init({
siteId: "YOUR_SITE_ID",
debug: false,
});

Call init() once. The runtime ignores duplicate initialization.

For a React, Next.js, Vue, Svelte, or other bundled application, import the package and create one SDK instance at the application level:

Terminal window
npm install @movcues/sdk
import { createAnalytics } from "@movcues/sdk";
const analytics = createAnalytics({
siteId: "YOUR_SITE_ID",
debug: false,
});
analytics.event("app_started");

createAnalytics() initializes the instance immediately and registers page-lifecycle cleanup. Keep it in a shared application module or provider instead of creating one instance per component.

The returned instance provides the same core methods as the CDN global:

analytics.identify("usr_123", { plan: "pro" });
analytics.event("invite_sent", { method: "email" });
analytics.page();

Call destroy() when the application is torn down. It stops collection, clears in-memory pending events, removes route observers, and releases the module singleton for a later initialization.

This is a browser SDK. Create the instance only in client-side code, not during server rendering. See the Next.js integration for a client-side example.

  1. Publish your website with the Movcues script added.
  2. Visit your website in a browser and open a page.
  3. In your Movcues dashboard, select the same site and open Observe → Events. Look for a page view from your visit.

If you don’t see it after a short wait, check that the script is on the published website and that its Site ID matches the site you selected in the dashboard. For more help, see troubleshooting.