Install Lucida on plain HTML (no build step)
Add Lucida to a site with no bundler using the classic script and the global lucida queue: snippet, CSP, optional proxy, consent and a first-event check.
This is the one page where the classic <script> snippet is the main path. It is for sites with no build step: static HTML, tag managers and site builders. If you have a bundler, use the npm package instead (all frameworks).
1. Install
There is nothing to install. The loader lucida.js is served from your Lucida app host (the host that serves the console, https://lucidace.com; not the capture host). lucida init --framework html [--app-host URL] prints the snippet with its integrity hash (CLI 0.1.6 or later) and writes no files.
2. Init with the key
Paste this in <head>. Commands go on window.lucidaQueue and the async script drains them:
<script>
window.lucidaQueue = window.lucidaQueue || [];
lucidaQueue.push(["init", "lc_pk_YOUR_PUBLIC_KEY", {
consent: { mode: "opt_in" },
modules: ["replay", "heatmaps", "forms"]
}]);
</script>
<script async src="https://lucidace.com/lucida.js"></script>Only the public key (lc_pk_...) is required. The default capture host is https://capture.lucidace.com, so apiHost is not needed on the cloud. Set it only when you self-host or use a reverse proxy. modules are optional; each is fetched from https://lucidace.com/static/v<version>/<name>.js, next to the loader. Set assetHost only if those files live elsewhere (SDK pinning).
After the script loads, the client is window.lucida. Before it loads, push commands onto the queue:
<script>
lucidaQueue.push(["setConsent", { analytics: true }]);
</script>Page views follow history changes by default. Pages that route on the URL fragment set capturePageview: "hash".
3. Content Security Policy
script-src 'self' https://lucidace.com;
connect-src 'self' https://capture.lucidace.com;script-src needs the loader host (and the assetHost if you set one) for lucida.js and its modules; a strict nonce-based policy with 'strict-dynamic' admits the modules. Add nonce to the init options so the SDK's own <style> elements carry it. To lock the script version, copy the pinned snippet with its integrity hash from SDK pinning. Full list: Content Security Policy.
4. Reverse proxy (optional)
Serve capture from your own domain so ad blockers do not break it. Set apiHost and uiHost:
lucidaQueue.push(["init", "lc_pk_YOUR_PUBLIC_KEY", { apiHost: "https://example.com/lc", uiHost: "https://lucidace.com" }]);Then add a rule that forwards /lc/* to https://capture.lucidace.com/ (nginx, Vercel, Cloudflare Worker examples are in Serve Lucida from your own domain). Serve the loader and module files from your own origin too, or set assetHost; do not point assetHost at /lc.
5. Consent
The SDK default is opt_out: with no consent setting it stores and sends from the first page view. The snippet above sets consent: { mode: "opt_in" }, so nothing is stored or sent until you grant it. Wire your banner to:
window.lucidaQueue.push(["setConsent", { analytics: true }]); // accept
window.lucidaQueue.push(["setConsent", { analytics: false }]); // declineFor Cookie Munch add "consent" to modules (Cookie Munch consent). Regional defaults: Consent by location.
6. Check the first event
Terminal:
lucida doctor --site https://example.comchecks the live page's policy against the loader script and API host.App: the Install wizard (onboarding page) waits for the first event and tells you when it arrives.
If nothing arrives, look for Refused to connect or Refused to load in the console (CSP).
More
Site builders (Gatsby, Docusaurus, Framer, Bubble, Wix, Squarespace), Browser extension, quickstart, all frameworks.