Installing Lucida on Gatsby, Docusaurus, Framer, Bubble, Wix, Squarespace and Cordova
All of the web builders below use the same loader every other no-code integration uses: commands go on window.lucidaQueue and the async script lucida.js...
All of the web builders below use the same loader every other no-code integration uses: commands go on window.lucidaQueue and the async script lucida.js drains them. Use your public key (lc_pk_..., never lc_sk_...). The snippet below defaults to consent.mode: "opt_in": no cookie, no storage and no request until you grant consent (see "Consent" at the end).
<script>
window.lucidaQueue = window.lucidaQueue || [];
window.lucidaQueue.push(["init", "lc_pk_YOUR_KEY", { apiHost: "https://capture.lucidace.com", consent: { mode: "opt_in" } }]);
</script>
<script async src="https://lucidace.com/lucida.js"></script>If you have a build step, use the npm package instead: Install by framework. The same snippet is explained step by step on Install on plain HTML.
SPA route changes are captured by default (capturePageview: "history"), so the single-page frameworks below need nothing extra. Apps that route on the URL fragment (/#/settings) set capturePageview: "hash": a pageview then fires on every hashchange and $pathname keeps the fragment route (/#/settings, the fragment's own ?query dropped). apiHost is the capture host (https://capture.lucidace.com); change it if you serve Lucida through your own domain (see the self-hosting reverse-proxy guide).
Gatsby
Either inject the snippet in SSR (loaded on every page, no bundle cost):
// gatsby-ssr.js
const React = require("react");
exports.onRenderBody = ({ setHeadComponents }) => {
setHeadComponents([
<script key="lc-init" dangerouslySetInnerHTML={{ __html: `window.lucidaQueue=window.lucidaQueue||[];window.lucidaQueue.push(["init","lc_pk_YOUR_KEY",{apiHost:"https://capture.lucidace.com",consent:{mode:"opt_in"}}]);` }} />,
<script key="lc" async src="https://lucidace.com/lucida.js" />,
]);
};or bundle the SDK and initialise it once in the browser:
// gatsby-browser.js
import { init } from "@lucida-analytics/browser";
export const onClientEntry = () => {
window.lucida = init("lc_pk_YOUR_KEY", { apiHost: "https://capture.lucidace.com", consent: { mode: "opt_in" } });
};Gatsby routes with history.pushState, so pageviews follow navigation without an onRouteUpdate hook. Gatsby gatsby-ssr.js runs at build time only: never put a secret key in either file.
Docusaurus
// docusaurus.config.js
module.exports = {
scripts: [{ src: "https://lucidace.com/lucida.js", async: true }],
headTags: [
{
tagName: "script",
innerHTML: `window.lucidaQueue=window.lucidaQueue||[];window.lucidaQueue.push(["init","lc_pk_YOUR_KEY",{apiHost:"https://capture.lucidace.com",consent:{mode:"opt_in"}}]);`,
},
],
};Docusaurus navigates client-side via the history API, which is already tracked. The built-in site search is a good fit for siteSearch: { params: ["q"] } autocapture when you use a URL-based search plugin.
Framer
Site settings, General, Custom code, End of
<head>tag: paste the snippet and publish.Framer injects custom code only on the published domain (and a custom domain if connected), not in the editor preview.
Events from components: use a Code component or an Override that calls
window.lucidaQueue.push(["capture", "cta_clicked", { variant: "hero" }]).
Bubble
App, Settings, SEO / metatags, Script/meta tags in header: paste the snippet.
Identify signed-in users with a workflow action Run javascript (needs the Toolbox plugin):
window.lucidaQueue.push(["identify", "<Current User's unique id>", { plan: "<Current User's plan>" }]). Use Bubble's unique id, not an email address, unless you are entitled to send it.On log-out run
window.lucidaQueue.push(["reset"]).
Wix
Dashboard, Settings, Custom code (under Advanced), Add custom code. Paste the snippet, name it "Lucida", set Add code to pages to All pages, Place code in to Head, and apply to Load code on each new page so every navigation runs it (Wix pages can swap content without a full reload).
Custom code needs a Premium plan with a connected domain; it does not run in the editor or on the
wixsite.compreview of an unpublished site. Publish, then open the live site.Velo (Dev Mode) sites: do not paste the snippet into page code. Keep it in Custom code and call Lucida from page code with
window.lucidaQueue.push([...])only inside$w.onReady, for example to identify a member afterwix-members-frontendreportscurrentMember.getMember(): use the member id, not the email address.Wix runs the page in the browser, so there is no secret to protect, but never paste a
lc_sk_key.Cookie banner: Wix's Consent Policy banner calls
wixWindowFrontend.trackingCookiesPolicy. In page code, read it and push["setConsent", { analytics: <policy.analytics> }]; leavemode: "opt_in"in the snippet so nothing runs before that. Wix does not host a place for your own banner callback otherwise.
Squarespace
Settings, Developer Tools, Code Injection (Business plan or higher), Header: paste the snippet, save.
Code Injection runs on the published site only, not inside the editor or the preview.
Squarespace 7.0 templates with AJAX loading, and 7.1 sites with page transitions, change pages through the history API, which is tracked by default. If you see a second pageview per click, disable the template's AJAX loading rather than the Lucida option.
Per-page events: Page settings, Advanced, Page Header Code Injection with a one-line
window.lucidaQueue.push(["capture", "pricing_viewed"]). For Commerce, Settings, Advanced, Order Confirmation Page takes code that runs once per order: capturepurchasethere.Cookie banner: wire the accept action of Squarespace's cookie banner (or your own consent tool) to
["setConsent", { analytics: true }].
Verifying a Wix or Squarespace install
Publish and open the live site in a private window. With
opt_innothing is sent yet; accept your banner.In Lucida, open Live events for the project: a
$pageviewappears within a few seconds, and moving to a second page adds another one with the new$pathname.Nothing arriving: run
lucida doctor --site https://your-site.com, check that the page is the published domain, and look for a blockedlucidace.comrequest in an ad blocker or in a Content Security Policy.
Cordova and Ionic (Cordova) apps
Apps built with Cordova, or Ionic on Cordova rather than Capacitor, install the plugin instead of the web snippet: cordova plugin add @lucida-analytics/cordova. It bridges the native Lucida iOS and Android SDKs (analytics, flags, native session replay, consent, flush); setup and the full API are in the Cordova SDK README. Capacitor apps use @lucida-analytics/capacitor.
Consent
Wire your banner (or the platform's cookie consent element) to:
window.lucidaQueue.push(["setConsent", { analytics: true }]); // accept
window.lucidaQueue.push(["setConsent", { analytics: false }]); // declineThe browser SDK's default consent mode is opt_out: with no consent setting it stores and sends from the first page view. Use mode: "opt_out" only where your legal basis allows tracking until the visitor declines; where consent law requires prior consent set consent: { mode: "opt_in" } (or a geo rule). optIn() grants analytics and replay, and marketing only when you name it: optIn(["analytics", "replay", "marketing"]). lucida doctor --site https://your-site.com checks the snippet, the API host and your Content Security Policy.