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.
Install with the CDN
Section titled “Install with the CDN”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.
Queue calls before the bundle loads
Section titled “Queue calls before the bundle loads”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.
Initialize manually
Section titled “Initialize manually”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.
Install as an ES module
Section titled “Install as an ES module”For a React, Next.js, Vue, Svelte, or other bundled application, import the package and create one SDK instance at the application level:
npm install @movcues/sdkimport { 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.
Use and clean up the instance
Section titled “Use and clean up the instance”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.
Verify the installation
Section titled “Verify the installation”- Publish your website with the Movcues script added.
- Visit your website in a browser and open a page.
- 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.
Next steps
Section titled “Next steps”- Read the Quickstart for a short first-event walkthrough.
- Review automatic collection to see what is captured without extra code.
- Add a privacy marker to pages containing sensitive UI.
- Continue to the public API reference, React integration, or Next.js integration.