Quickstart
Get Lucia capturing events in under 5 minutes. By the end you'll have the SDK installed, initialized with your API key, and your first pageview showing up in the dashboard — the foundation every attribution report is built on.
You install a single lightweight SDK and initialize it once. From there, Lucia resolves the events you send into one customer journey per person and credits each conversion to the campaign that earned it — across web2 and web3.
What you'll need
- A Lucia account → Sign up
- Your API key from the dashboard (below)
- A web app you can add a
<script>tag or an npm package to
Step 1 — Get your API key
- Log in to your Lucia dashboard.
- Open Settings → API Keys.
- Copy your key. You'll pass it to the SDK in the next step.
Never hard-code your API key in source you commit. Store it in an .env file and read it
from import.meta.env / process.env, as shown below.
Step 2 — Install & initialize the SDK
Pick the path that matches your stack. Both do the same thing: load the SDK and initialize it with your API key.
- CDN (script tag)
- npm / yarn
Add the script to your page <head>. With the data-api-key attribute, the SDK
auto-initializes — there's nothing else to call.
<script
src="https://cdn.luciaprotocol.com/lucia-sdk-latest.min.js"
data-api-key="YOUR_API_KEY"
></script>
Works with any site or framework, single-page or multi-page. To also capture clicks on
every button and link automatically, add data-auto-track-clicks="true".
Install the package:
npm install lucia-sdk
# or
yarn add lucia-sdk
Initialize it once at your app's entry point:
import LuciaSDK from 'lucia-sdk';
LuciaSDK.init({
apiKey: import.meta.env.VITE_LUCIA_API_KEY, // or process.env.LUCIA_API_KEY
});
Using Vite, React, or Next.js? The framework guides pick up from here with copy-paste setup: Vite + TypeScript · React + JavaScript · Next.js.
Step 3 — Track your first event
Pageviews are the backbone of attribution. If you used the CDN tag, the initial
pageview is captured automatically. To record pageviews on client-side route changes — or
if you installed via npm — call pageView when the route changes:
import LuciaSDK from 'lucia-sdk';
LuciaSDK.pageView(window.location.pathname);
That's all it takes to start collecting. The next section shows the events that turn raw pageviews into attributed journeys.
Step 4 — Verify it's working
- Open your app and navigate between a couple of pages.
- In the Lucia dashboard, open Insights.
Within a few seconds you should see your pageview events appear.
The three most common causes are the snippet placed on a page that wasn't reloaded, an
ad-blocker on your own browser, or the wrong API key. Turn on debug: true in
LuciaSDK.init() to log SDK activity to the console.
That's it — Lucia is live.
Step 5 — Add the events attribution is built from
With the SDK initialized, a few extra calls let Lucia credit the campaign behind each conversion and resolve a visitor's wallets and sessions into one profile.
- Track a conversion
- Track a click
- Identify a user
- Connect a wallet
Record the outcomes you care about — a purchase, signup, or subscription. This is what campaigns get credited for.
await LuciaSDK.trackConversion('purchase', 49.0, {
currency: 'USD',
product: 'Pro Plan',
});
Attribute a specific call-to-action:
await LuciaSDK.buttonClick('start-trial');
Tie events to a known user so sessions across devices resolve into one profile:
await LuciaSDK.userInfo('user-123', { email: 'jane@example.com' });
Link an on-chain wallet to the same customer, so web2 and web3 sit in one profile:
await LuciaSDK.sendWalletInfo(connectedAccount, 1, 'Metamask');
Next steps
- SDK API Reference → — every method and option.
- Links and Campaigns → — generate tracked links and measure campaigns.
- Conversion Tracking → — model the outcomes that matter.
- Privacy & Compliance → — what's collected and how it's handled.