Privacy-First Analytics
Insights without compromising user privacy.
Inertia Start gives you two privacy-friendly ways to understand your traffic. You can use either one, or both:
- Umami integration — a ready-made connection to Umami, an open-source web analytics platform. Umami is a separate application that you install and run yourself; Inertia Start ships only the code that talks to it.
- Contexts — Inertia Start's own way of following a visitor from their first visit to their first purchase. Built in, always on, nothing extra to host, and by default with no cookie banner to show.
Umami Analytics
Umami is open-source, easy to self-host, and cookieless: it sets no cookies and keeps no identifier on the visitor's device. Inertia Start includes everything needed to connect your app to it.
Umami is a separate, external application
Inertia Start bundles the integration with Umami, not Umami itself. You need to install and run your own Umami instance — on the same server as your app or on another one — before the steps below will work.
Setup
Install Umami
Follow the Umami installation guide to set up Umami on your server. It can live on the same server as your Inertia Start app or on a separate one.
Cloudflare headers
If your Umami instance is behind a Cloudflare proxy, don't forget to enable Cloudflare headers.
Add your website to Umami
In your Umami dashboard, add your website. Umami will generate a Website ID that you'll need in the next steps.
Enable analytics in Inertia Start
Turn on the integration with the I_S_ENABLE_ANALYTICS environment variable:
I_S_ENABLE_ANALYTICS=truePoint Inertia Start at your Umami instance
Fill in the details of the Umami instance you set up in step 1:
# The URL where your Umami instance is reachable.
# If Umami runs on the same server with the default port, this is http://localhost:3000.
I_S_UMAMI_HOST=http://localhost:3000
# The name of the tracking script Umami injects into your pages.
# Defaults to "script.js", unless you changed TRACKER_SCRIPT_NAME on your Umami instance.
I_S_UMAMI_TRACKER_SCRIPT=script.js
# The Website ID that Umami generated when you added your website (step 2).
I_S_UMAMI_WEBSITE_ID=Usage
Changed in v2.2.0That's it! Once the configuration above is in place, Inertia Start automatically collects visitor statistics — there's nothing else to do.
The tracker script loads on every page as soon as analytics is enabled, whatever the context mode. Before v2.2.0, it only loaded on pages where the visitor already had a context, so a new guest's first page view was not counted.
To go further, the useUmami composable lets you track custom events from your Vue components:
import { useUmami } from '@/composables/useUmami';
const { track } = useUmami();
track('signup_button_clicked');The composable also exposes identify(id) to attach data to the current visitor and isAvailable() to check whether the Umami script has loaded.
Contexts
Changed in v2.2.0Umami tells you what happens on your site. Contexts tell you who signs up and buys, and what first brought them in — and they're built right into Inertia Start, so there's nothing to install and nothing to host.
A context is one row per person in the contexts table. It records when they first arrived, where they came from, when they registered, and when they first paid. Contexts are always active: unlike the Umami integration, they don't depend on I_S_ENABLE_ANALYTICS.
How much a context knows about a visitor before they sign up depends on the mode you choose. By default, Inertia Start runs in minimal mode, which stores nothing on a guest's device and needs no cookie banner. Fingerprint mode recognizes guests across visits, but only after they accept a consent banner.
Before v2.2.0
Every guest was fingerprinted on their first visit, without asking, and remembered in a 90-day context cookie. That behavior now needs consent in the EU, so it became the opt-in fingerprint mode, behind a consent banner. If you relied on guest contexts, set I_S_CONTEXT_FINGERPRINTING=true to keep them for the visitors who accept.
What you get
- First-touch attribution — the campaign, landing page and referrer that first brought a visitor in are stored on their context and survive all the way to the purchase, in both modes.
- A history that survives signup — the first visit is preserved when a guest becomes a user, even when they confirm their email address in another browser.
- Conversion insight — you can see how long someone browsed before signing up, how the account was created (
registered_via), and when they became a paying customer (converted_at, which the checkout flow fills in for you). - Umami sessions you can match — signed-in users, and guests who consented in fingerprint mode, have their Umami session identified with the same
context:{contextId}value. - One visitor, one identity across sites — in fingerprint mode, the same consenting guest is recognized across your marketing site, your documentation and your app.
Contexts are queryable through the App\Models\Context model. The admin users page is built on top of them, and every user page shows their whole tracking record.
Choose a mode
| Minimal mode (default) | Fingerprint mode | |
|---|---|---|
| Turned on with | nothing, it's the default | I_S_CONTEXT_FINGERPRINTING=true |
| Cookie banner | not needed | built in, shown to guests |
| Stored on a guest's device | only the session cookie | after consent: a context cookie, a localStorage flag and the consent choice |
| A guest's context is created | when they sign up | when they accept the banner, or when they sign up |
| First-touch attribution | yes | yes |
| Guest recognized on a later visit | no | yes, after consent |
| Guests in the admin users list | no | those who consented |
| Cross-site contexts for guests | no | yes, if each site collects consent |
Not legal advice
The modes are designed around the EU rules on device storage and consent, but whether you need a banner, and what your privacy policy has to say, depends on your whole site: other cookies, embeds and tools you add count too. Check your own case with a lawyer, especially before turning on fingerprint mode.
Minimal mode
Minimal mode is the default. Nothing about contexts is stored on or read from a guest's device:
- no fingerprint is computed, and no
X-Guestheader is sent - no
contextcookie and no localStorage flag are set - no context row is created for guests
Instead, the server keeps the guest's first touch — the landing URL, the external referrer, the UTM parameters and the time of the first visit — in their server-side session, which exists anyway.
When the guest starts signing up, that first touch is copied onto the registration request. The context is then created with the account and starts from it, so the confirmation link still counts the right campaign when it is opened in another browser, such as a mail app's. This works for every way an account can be created: the email signup, external auth providers and a guest checkout.
From then on, signed-in users keep their context as usual: last_seen_at is refreshed while they use the app, the first purchase fills in converted_at, and the admin shows the whole record.
Why no banner is needed. The EU ePrivacy Directive (article 5(3), transposed in Spain by article 22.2 of the LSSI) requires consent before storing or reading information on a visitor's device, unless it is strictly necessary for the service they asked for. In minimal mode, the only thing on the device is the session cookie your application already needs, and the first touch stays on your server.
The trade-off. A guest is not recognized across sessions: someone who leaves and comes back days later, after their session expired, starts a new first touch, and the context created at sign-up is credited to the visit on which they signed up. The admin users list has no guest rows, only people who have an account.
Fingerprint mode
Turn it on in your .env:
I_S_CONTEXT_FINGERPRINTING=trueFingerprint mode adds guest tracking on top of minimal mode, for the guests who agree to it. Guests see a built-in consent banner:
- Accept and Reject are offered side by side, so rejecting is as easy as accepting.
- A Cookie settings link in the footer reopens the banner, so a visitor can change their answer at any time. Withdrawing consent forgets their guest context cookie.
- The answer is kept in a
context_consentcookie for 24 months, after which the banner asks again. Remembering the answer is itself strictly necessary, so that cookie needs no consent. - Signed-in users never see the banner: their context comes from their account, not from their device.
Before the guest answers, or if they reject, fingerprint mode behaves exactly like minimal mode. Once they accept, the browser computes a fingerprint and the guest gets a context of their own, as described below. A guest who accepts in the middle of a visit gets a context that starts from the first touch already kept in their session, not from the page on which they clicked Accept.
Why consent is needed. A fingerprint reads information from the visitor's device — fonts, screen, browser settings — to tell it apart from others. Article 5(3) of the ePrivacy Directive covers reading as well as storing, and the EDPB guidelines 2/2023 on its technical scope name fingerprinting explicitly. A stable identifier used to recognize visitors across visits and sites, and linked to their account later, is not strictly necessary for the service they asked for, so none of the exemptions applies. The context cookie and localStorage flag need consent for the same reason.
Pseudonymous, not anonymous
A guest context holds no name, no email address and no account data: just a SHA-256 hash of the browser fingerprint combined with the IP address (never the raw values), the first touch, and a few timestamps. The hash can't be reversed, but it still singles out one browser, which makes it pseudonymous data — and pseudonymous data is personal data under the GDPR. Mention it in your privacy policy, and treat guest contexts like any other personal data.
How it works
The first touch is kept in the session
On a guest's first request, the SetContext middleware records where they came from in the server-side session, in both modes:
| Field | Contents |
|---|---|
utm_source, utm_medium, utm_campaign, utm_term, utm_content | The campaign parameters found in the landing URL's query string |
landing_url | The first page of yours the visitor opened |
referrer | The page that sent them, when it is not one of your own |
first_seen_at | The time of that first request |
This is first-touch attribution: all these fields describe the same arrival, so they are written once and never changed. A visitor who arrives through a Product Hunt link and then clicks around your site is still credited to Product Hunt — the channel that actually did the work of finding them.
Because the fields are written together, a source from one arrival can never end up paired with a referrer or a campaign from another.
Landing URLs are stored as they arrive
Query strings are recorded verbatim, so avoid putting anything personal in your own campaign links, and be aware that a third party could append parameters to a link they share. Values are truncated (255 characters per campaign parameter, 2000 per URL), and the public context API accepts a landing URL only when it is a well-formed absolute URL.
Fingerprint mode, after consent: the guest gets a context
Inertia Start's top-level layouts call the useContext() composable. For a guest who accepted the banner, it computes a Thumbmark fingerprint and attaches it to Inertia requests in the X-Guest header.
The middleware hashes that fingerprint together with the visitor's IP address, then finds or creates the matching row in the contexts table, starting from the first touch kept in the session. The context ID is remembered in the session and in a first-party context cookie for 90 days, and a localStorage flag tells the browser it no longer needs to send the fingerprint. Guest contexts expire after 90 days, and the scheduled expirable:purge command removes them.
Because the fingerprint is combined with the IP address, the same browser on a different network resolves to a different context. This limits how far a guest can be followed, but it doesn't make the context anonymous.
In minimal mode, or without consent, this step is skipped entirely.
Sign-up creates or claims the context
When the visitor creates an account:
- a guest context they already have (fingerprint mode, after consent) is attached to the new account
- otherwise, a new context is created for it, starting from the first touch kept in the session
registered_atandregistered_viaare filled in
Starting an email signup copies the first touch onto the registration request, so the context created when the confirmation link is opened — maybe in another browser — still gets the right campaign and first visit.
The built-in email signup records signup as the registration method, external auth providers record the provider's driver name (for example google), and an account created by a guest checkout records purchase. The column is a plain string, so your own flows can store whatever describes them best.
From then on, the context ID is handed to Vue as the contextId Inertia prop. To avoid a database write on every request, last_seen_at is refreshed at most once every 5 minutes. Adjust that with I_S_CONTEXT_ACTIVITY_INTERVAL.
The first purchase marks the conversion
When a Stripe Checkout session or a Paddle transaction completes successfully — for a configured product or subscription, through either provider — the transaction timestamp is written to the context's converted_at.
Combined with converted_at, the first touch is what lets you ask which channel produced buyers rather than clicks:
Context::query()
->whereNotNull('converted_at')
->selectRaw('utm_source, count(*) as customers')
->groupBy('utm_source')
->orderByDesc('customers')
->get();Money lives in the billing tables rather than on the context, so join them when you want revenue per channel instead of customers per channel:
Context::query()
->join('product_purchases', 'product_purchases.user_id', '=', 'contexts.user_id')
->selectRaw('contexts.utm_source, count(distinct contexts.id) as customers, sum(product_purchases.amount) as revenue')
->groupBy('contexts.utm_source')
->orderByDesc('revenue')
->get();product_purchases.amount is stored in the currency's minor unit (cents), so group by currency as well if you sell in more than one.
When Umami is enabled, Inertia Start ties the two systems together for every visitor who has a context — signed-in users, and guests who consented in fingerprint mode — using:
window.umami.identify(`context:${contextId}`);so the context and its Umami sessions share a single identifier, ready to paste into Umami's session search. Other visitors are still counted by Umami, just not identified.
What the admin shows
/admin/users lists the contexts. In minimal mode, that means people who have an account; in fingerprint mode, guests who consented appear too.
Every user page in the admin has an Analytics and tracking section built from the columns above:
- Lifecycle — first visit, registration, conversion and last activity, drawn as a timeline with the time elapsed between each step, next to the context ID. Milestones that haven't happened yet stay empty, so a visitor who registered but never paid is obvious at a glance, and the registration method appears as a badge on the registration step.
- Acquisition — the first-touch source (the
utm_source, falling back to the referring host, then to Direct), the rest of the campaign parameters, the landing page and the external referrer. - Umami session — the copyable
context:{contextId}value and a link straight to your Umami sessions. This block only appears when Umami is configured.
Sharing contexts with your other sites
Fingerprint mode only
Other sites can only resolve a guest's context in fingerprint mode. In minimal mode, the endpoint below creates no guest contexts and answers 422.
The consent banner of your application doesn't cover your other sites: each calling site must collect the visitor's consent itself before computing the fingerprint, with a banner where rejecting is as easy as accepting, and skip the call entirely without it.
If your marketing site or your documentation lives on another domain, they can resolve the same context before the visitor ever reaches your app, through the public POST /api/context endpoint.
Allow the other origins
List every first-party origin in your application's .env:
I_S_CONTEXT_FINGERPRINTING=true
I_S_CONTEXT_ALLOWED_ORIGINS=https://www.example.com,https://docs.example.comOrigins are matched exactly: scheme and host, plus the port if there is one — no path, no trailing slash. Your application's own origin is always accepted, so you don't need to list it.
Use the same fingerprinting library
Install Thumbmark on the other site:
npm install @thumbmarkjs/thumbmarkjsKeep the version in sync with the one in your application's package.json. Two different versions can produce two different fingerprints for the same browser, which would split a single visitor into two contexts.
Resolve the context ID, after consent
Once the visitor has accepted your site's consent banner, send the fingerprint to the endpoint in the X-Guest header. The endpoint needs no CSRF token and no API key.
Include the current URL and the referrer in the body as well. The endpoint only ever sees its own URL, so without them a visitor arriving on your marketing site through a campaign link cannot be attributed:
import { Thumbmark } from '@thumbmarkjs/thumbmarkjs';
// Call this only once the visitor has accepted fingerprinting on this site.
export async function resolveContextId(): Promise<string | null> {
try {
const { thumbmark } = await new Thumbmark().get();
const response = await fetch('https://app.example.com/api/context', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'X-Guest': thumbmark,
},
body: JSON.stringify({
url: location.href,
referrer: document.referrer || null,
}),
});
if (!response.ok) {
return null;
}
const { contextId } = (await response.json()) as {
contextId?: number | string;
};
return contextId ? String(contextId) : null;
} catch {
return null;
}
}Always fail quietly like this. Context tracking is a nice-to-have: a rejected or unreachable request should never keep a page from rendering.
Both fields are optional and each is ignored unless it is a well-formed absolute URL of no more than 2000 characters. They are only used the first time a context is created, so sending them on every page view is harmless.
Point Umami at the same identifier (optional)
If that site also runs the Umami tracker, identify its session with the context you just resolved:
resolveContextId().then((contextId) => {
if (!contextId) {
return;
}
const identify = () => window.umami?.identify?.(`context:${contextId}`);
// The tracker script is usually deferred, so it may not be ready yet.
if (window.umami) {
identify();
} else {
document
.querySelector('script[data-website-id]')
?.addEventListener('load', identify, { once: true });
}
});Skip this step if you don't use Umami — cross-site contexts and conversion tracking work perfectly well on their own. Umami itself is cookieless, so it can keep loading for visitors who didn't consent; they just aren't identified.
What the endpoint returns
A successful call replies with the context ID, and the response is never cached:
{
"contextId": 123
}| Status | When |
|---|---|
200 | The context was found or created. |
403 | The request carries an Origin header that is neither your application's own origin nor one of I_S_CONTEXT_ALLOWED_ORIGINS. |
422 | The X-Guest header is missing or empty, or the application runs in minimal mode. |
429 | More than 60 requests per minute from the same client. |
Browser preflight (OPTIONS) requests are handled for you, so there is nothing else to set up on the CORS side.