Signed-in users
Pass your own user ID so one person counts once across days and devices, and server events join their visit.
Without cookies, a visitor gets a new ID every day, so the same person on Monday and Tuesday counts twice. Once someone signs in, pass your own ID for them. From then on they count as one visitor across days and devices, and the events your server sends for them join their visit.
Pass the user ID
Use the ID your database already gives the account, such as u_8f2k1x or 4410. Do not use an email address or a name.
Render the ID into the snippet on pages for signed-in people, and leave the attribute out for everyone else.
<script defer src="https://cdn.ultanimus.com/s.js" data-site="YOUR_SITE_ID" data-user="u_8f2k1x"></script>On a page that signs people in without a reload, call identify instead:
ultanimus.identify('u_8f2k1x')To call it before the script has loaded, add the queue line from Custom events above the snippet.
Give Analytics the signed-in user, or null when nobody is.
<Analytics site="YOUR_SITE_ID" user={session?.userId ?? null} />Or call identify where your app learns who signed in:
import { identify } from '@ultanimus/react'
identify(account.id)Read the session in the root layout and pass the ID to Analytics.
<Analytics site="YOUR_SITE_ID" user={session?.userId ?? null} />Or call identify from @ultanimus/next in a client component.
The packages' identify and the user prop work before the script has loaded and during server rendering. Every event after the call carries the ID. With data-user, the user prop or a call before the script loads, the page's own pageview carries it too.
The script keeps the ID in memory until the next full page load. That page starts anonymous until the snippet or your code passes the ID again, so render data-user or the user prop from your layout whenever someone is signed in.
Sign out
Call identify(null), or render Analytics with user={null}. Later events count as an anonymous visitor again.
What changes in the dashboard
- Visitors. A signed-in person counts once over the whole range, on any device, instead of once a day. Pages viewed before the sign-in keep the anonymous ID, so the visit where someone signs in can add one extra visitor.
- Visits. A visit stays one visit when someone signs in halfway through. The pages before the sign-in and after it stay together.
- Funnels. A person who signs in between two steps stays the same person, and a step can be an event your server sends, such as a paid order.
- Server events. An event your server sends with the same
userjoins the person's open visit and takes its source, country and device. See Server events. - People. Each signed-in person gets a page with their visits, pages, events and goals. See People.
- Retention. Cohorts count only signed-in people, from their first visit. See Retention.
- Revenue. A payment whose checkout carries the same ID is credited to the person's visits. See Revenue.
What is stored
Ultanimus stores a hash of your ID and the site ID in place of the visitor ID. Your ID itself is never stored, and the same ID on two of your sites gives two different hashes.
The site's settings show since when the site sends user IDs and when the last one arrived.
The hash stays the same every day and links one person's visits, which makes it personal data in many countries. Mention it in your privacy notice, and check whether your users need to agree to it first. Privacy and data covers the rest.