Dual-Mode Identity & User Identification
Choose per site between zero-storage cookie-less analytics and persistent first-party visitor IDs, plus optional logged-in user identification.
How does TrimStats dual-mode visitor identity work?
Every TrimStats site defaults to strictly cookie-less mode (zero cookies, zero localStorage, 24-hour rotating 32-byte SHA-256 daily salts). When you need multi-week retention cohorts, 30-day funnels, or 90-day timelines, you can explicitly opt in per site to First-Party ID mode (_ts_vid, _ts_attr) or call identify(userId) for logged-in users.
Cookie-less vs First-party ID
Analytics tools face a real trade-off between zero browser storage and multi-day memory. In cookie-less mode, rotating the hashing salt every midnight UTC mathematically erases the link between yesterday and today: great for zero-banner privacy, which also means the same person returning 5 days later looks like a brand-new visitor.
Every site in TrimStats defaults to Cookie-less mode, requiring zero browser storage and zero consent banners. Whenever a site needs multi-day visitor timelines, weekly retention cohorts, 30-day funnels, or 90-day revenue attribution, opt in to First-party ID mode on a per-site basis.
| Capability | Cookie-less (Default) | First-party ID (`first-party`) | Identified (`identify()`) |
|---|---|---|---|
| Browser storage | None (zero cookies, zero localStorage) | _ts_vid + _ts_attr in localStorage | In-memory uid (plus _ts_vid if first-party) |
| Consent banner typically required? | No | Depends on jurisdiction (ePrivacy / GDPR) | Depends on your logged-in privacy notice |
| Unique visitors & sessions | Same UTC day | Cross-day on same browser | Cross-day & cross-device |
| Funnels | Within same day | Up to 30-day window | Up to 30-day window across devices |
| Weekly retention cohorts | Excluded from cohorts | Full 2 to 12 week cohorts | Full 2 to 12 week cohorts |
| Revenue attribution lookback | Same-day or metadata fallback | Full 90-day ClickHouse lookback | 90-day lookback by user ID |
How visitor IDs are derived server-side
The collector resolves every incoming beacon to an opaque 64-bit unsigned integer (visitor_id) using SHA-256 in the following strict priority order:
- Identified (`identified`): If
uidwas passed viawindow.trimstats('identify', userId), the collector hashesuid:{siteId}:{externalUserId}. - First-party (`first_party`): If the site has First-party ID enabled in Site settings AND the script sent a client
vid, the collector hashesfp:{siteId}:{clientVid}. - Cookie-less (`cookieless`): Otherwise, the collector fetches a 32-byte random salt rotated every UTC day (
salt:YYYY-MM-DD) and hashescl:{dailySalt}:{siteId}:{clientIp}:{userAgent}. Once the UTC day passes and the salt expires, old hashes can never be linked back to a person or IP.
Enabling first-party mode
data-mode="first-party" on your <script> tag.- 1
Enable First-party ID in Site settings
Open your site, navigate to Site settings -> General & Privacy, select First-party ID, and click Save changes.
- 2
Add data-mode="first-party" to your script tag
Update your
<script>tag to includedata-mode="first-party". The tracker will generate a random UUID inlocalStorage._ts_vidand save the visitor first-touch attribution snapshot inlocalStorage._ts_attr.HTML<script defer src="https://collect.trimstats.com/t.js" data-site="pk_live_your_key" data-mode="first-party"></script>
If your site displays a cookie or analytics consent banner before enabling first-party mode, render data-mode="first-party" only after the user opts in, or keep the default cookie-less snippet without data-mode for visitors who decline.
Identifying logged-in users
For SaaS applications with authenticated accounts, call window.trimstats?.('identify', userId) after login or session hydration. Pass an opaque database UUID or customer ID (up to 128 characters), not a raw email address.
1// Call after authentication succeeds2if (session?.user?.id) {3 window.trimstats?.('identify', session.user.id);4}56// Subsequent events and window.trimstats.attribution() now carry uid7window.trimstats?.('event', 'workspace_created', { teamSize: 4 });Passing the same userId as client_reference_id (Stripe) or inside metadata.uid (Paddle, Polar, or Custom webhooks) lets TrimStats attribute subscription renewals and cross-device upgrades back to the exact acquisition source.
identify() elevates a visitor badge to Identified, linking return visits, custom event properties, and server-verified Stripe payments into a single timeline.Common technical questions
What is the server-side priority order between identify(), first-party ID, and cookie-less?
Can I keep my marketing site cookie-less while using First-Party ID inside my SaaS app?
Related guides
Details on EU infrastructure in Germany, zero IP storage, sub-processors, GDPR/ePrivacy posture, and automatic retention expiration.
Learn how multi-step conversion funnels and weekly retention cohorts work, how to spot your biggest drop-off leaks, and how TrimStats computes them in ClickHouse.
Connect payment provider webhooks directly to TrimStats to attribute one-time orders, subscriptions, renewals, and refunds to referrers, UTM campaigns, and landing pages.