Integration
Identity & session attributes
setUserId, user_name, and custom identify fields.
Anonymous visitors get a stable label from fingerprint. After sign-in, call setUserId and identify() so Visitors, Lobby, and replay show real names and custom attributes.
Before and after
Fluffy Cotton Candy
fp_a8f3c2e91b4d…
Stable anonymous label until you identify.
No setUserId or identify yet.
Alex Morgan
acct_7f2a9c1e
user_name is the headline; user_id stitches sessions.
- → Tracuto.setUserId("acct_7f2a9c1e")
- → Tracuto.identify({ user_name: "Alex Morgan", plan: "pro" })
Fields
| Field | API | When | Notes |
|---|---|---|---|
| user_id | setUserId(id) | After login | Stable id from your auth system |
| user_name | identify({ user_name }) | After login | Display name in the dashboard |
| utm_* | automatic on tag load | Landing URL | utm_source, utm_medium, etc. from ?query on new sessions—Custom attributes |
| custom keys | identify({ key }) | Anytime | plan, cohort, etc.—shown under Custom attributes |
Example
if (window.Tracuto?.isReady?.()) {
window.Tracuto.setUserId(user.id);
window.Tracuto.identify({
user_name: user.displayName || user.email,
plan: user.plan,
cohort: user.cohort,
});
window.Tracuto.flush();
}
// On logout:
if (window.Tracuto?.isReady?.()) {
window.Tracuto.clearUserId();
window.Tracuto.flush();
}Google Tag Manager dataLayer
If your site already pushes identity into the GTM dataLayer, enable Tag Manager dataLayer in Project settings. The hosted SDK then reads it automatically: user_id maps to setUserId, and every other string, number, or boolean key becomes a custom attribute via identify(). Plain object pushes and gtag command tuples (set / config / event, including user_properties) are both supported. Pushes made before the SDK loads are replayed; later pushes apply live. Push { event: "user_logout" } or ['event', 'user_logout'] to clear the user id.
// Plain object (GTM-style):
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
user_id: 'acct_7f2a9c1e', // → setUserId
user_name: 'Alex Morgan', // → identify
plan: 'pro',
});
// gtag-style commands (also work via gtag()):
window.dataLayer.push(['set', { user_id: 123 }]);
window.dataLayer.push(['set', 'user_properties', { cohort: 'beta' }]);
gtag('config', 'G-XXXX', { user_id: 'acct_7f2a9c1e', plan: 'pro' });
// On logout:
window.dataLayer.push({ event: 'user_logout' });
// or: window.dataLayer.push(['event', 'user_logout']);Nested objects (e.g. ecommerce), gtm.* internals, and gtag system keys (send_page_view, items, …) are ignored. Nested user_properties are flattened one level. Avoid pushing emails or other personal data into the dataLayer — or keep the setting off and call identify() explicitly.