xiaohongshu
xiaohongshu
fullstory-identify-users
Comprehensive guide for implementing Fullstory's User Identification API (setIdentity) across web applications. Teaches proper uid handling, property passing, re-identification behavior, and session management. Includes detailed good/bad examples for login flows, multi-account scenarios, and SPA ...
Full skill instructions
Fullstory's User Identification API allows developers to associate session data with your own unique customer identifiers. By calling FS('setIdentity'), you link a user's Fullstory session to their identity in your system, enabling you to:
This skill covers implementation patterns, best practices, and common pitfalls for browser/web applications using the v2 Browser API.
setIdentity immediately after a successful authenticationsetIdentity on every page load if the user is logged insetIdentity is called. User is tracked via the fs_uid first-party cookie but not linked to your system.setIdentity, the session is permanently linked to the provided uid.Fullstory uses a first-party cookie (fs_uid) to track users across sessions.
| Aspect | First-Party (Fullstory) | Third-Party |
|---|---|---|
| Domain | Set on YOUR domain (example.com) | Set on external domain (ads.tracker.com) |
| Browser blocking | ✅ Not blocked by browsers or ad-blockers | ❌ Often blocked by default |
| Cross-site tracking | ❌ Cannot track users across different sites | ✅ Can track across sites |
| Privacy | ✅ Data stays within your domain context | ❌ Aggregates data across web |
Key Benefit: Because Fullstory uses first-party cookies on YOUR domain, user identity cannot be connected between multiple sites using Fullstory. Each site has its own separate
fs_uidcookie - your customers' data is isolated to your site only.
fs_uid cookie links all sessions from the same browser/device together (persists for 1 year unless deleted)setIdentity is called: ALL previous anonymous sessions with that same fs_uid cookie are retroactively merged into the identified useruid is used on different devices, all sessions across all devices are linked┌─────────────────────────────────────────────────────────────────────────┐
│ Session Merging on Identification │
├─────────────────────────────────────────────────────────────────────────┤
│ Day 1: Anonymous visit fs_uid: abc123 → "Anonymous User" │
│ Day 3: Anonymous visit fs_uid: abc123 → Same anonymous user │
│ Day 7: User logs in, setIdentity(uid: "user_456") │
│ ↓ │
│ Result: ALL sessions (Day 1, 3, 7) now linked to "user_456" │
└─────────────────────────────────────────────────────────────────────────┘
Important: This means a user's entire journey from first visit through conversion can be tracked, even if they only identify on their 5th session.
Reference: Why Fullstory uses First-Party Cookies
setIdentity with a different uid, Fullstory automatically splits the session into a new sessionsetIdentity as early as possible after authentication| Scenario | Use This API | Why |
|---|---|---|
| User logs in | setIdentity | Links session to user identity |
| Initial user properties at login | setIdentity with properties | Convenient to include with identification |
| Update user properties later | setProperties (type: 'user') | Don't re-identify just to update properties |
| Properties for anonymous user | setProperties (type: 'user') | Works without identification! |
Important: The
propertiesobject insetIdentityis a convenience - you can include initial properties when identifying. However, for updating properties after identification or for anonymous users, usesetPropertieswithtype: 'user'instead. See the fullstory-user-properties skill for details.
// At login - identify with initial properties
FS('setIdentity', {
uid: user.id,
properties: {displayName: user.name, email: user.email, plan: user.plan},
})
// Later - user upgrades plan (DON'T re-identify!)
FS('setProperties', {
type: 'user',
properties: {plan: 'enterprise', upgraded_at: new Date().toISOString()},
})
FS('setIdentity', {
uid: string, // Required: Your unique user identifier
properties?: object, // Optional: Additional user properties
schema?: object // Optional: Type inference for properties
});
| Parameter | Type | Required | Description |
|---|---|---|---|
uid | string | Yes | A unique identifier for the user from your system. Must be stable and unique. Maximum 256 characters. |
properties | object | No | Key/value pairs of additional user information |
schema | object | No | Type hints for property values (see Custom Properties) |
| Field | Type | Description |
|---|---|---|
displayName | string | Shown in session list and user card in Fullstory app |
email | string | Enables search via HTTP API and email-based lookups |
| Type | Description | Examples |
|---|---|---|
str | String value | "premium", "enterprise" |
strs | Array of strings | ["admin", "beta-tester"] |
int | Integer | 42, -5, 0 |
ints | Array of integers | [1, 2, 3] |
real | Float/decimal | 99.99, -3.14 |
reals | Array of reals | [10.5, 20.0] |
bool | Boolean | true, false |
bools | Array of booleans | [true, false, true] |
date | ISO8601 date | "2024-01-15T00:00:00Z" |
dates | Array of dates | ["2024-01-01", "2024-02-01"] |
// GOOD: Call setIdentity immediately after successful login
async function handleLogin(credentials) {
try {
const response = await authenticateUser(credentials)
const user = response.user
// Identify user in Fullstory right after successful auth
FS('setIdentity', {
uid: user.id, // Use stable database ID, not email
properties: {
displayName: user.fullName,
email: user.email,
accountType: user.plan,
signupDate: user.createdAt, // ISO8601 format
},
})
// Continue with login flow
redirectToDashboard()
} catch (error) {
handleLoginError(error)
}
}
Why this is good:
// GOOD: Check authentication state and identify on every page load
function initializeFullstory() {
const currentUser = getCurrentAuthenticatedUser()
if (currentUser && currentUser.id) {
// User is logged in - identify them
FS('setIdentity', {
uid: currentUser.id,
properties: {
displayName: currentUser.name,
email: currentUser.email,
role: currentUser.role,
companyId: currentUser.organizationId,
plan: currentUser.subscription.plan,
trialEndsAt: currentUser.subscription.trialEnd,
},
})
}
// If not logged in, user remains anonymous (default state)
}
// Call on app initialization
document.addEventListener('DOMContentLoaded', initializeFullstory)
Why this is good:
// GOOD: React hook for Fullstory identification
import {useEffect} from 'react'
import {useAuth} from './auth-context'
function useFullstoryIdentity() {
const {user, isAuthenticated, isLoading} = useAuth()
useEffect(() => {
// Wait for auth state to be determined
if (isLoading) return
if (isAuthenticated && user) {
FS('setIdentity', {
uid: user.id,
properties: {
displayName: `${user.firstName} ${user.lastName}`,
email: user.email,
role: user.role,
teamSize: user.team?.memberCount,
features: user.enabledFeatures, // Array of strings
lastLoginAt: new Date().toISOString(),
},
})
}
}, [user, isAuthenticated, isLoading])
}
// Usage in App component
function App() {
useFullstoryIdentity()
return <AppContent />
}
Why this is good:
// GOOD: Identify user after OAuth callback
async function handleOAuthCallback() {
const urlParams = new URLSearchParams(window.location.search)
const code = urlParams.get('code')
if (!code) {
redirectToLogin()
return
}
try {
// Exchange code for tokens and user info
const {user, tokens} = await exchangeOAuthCode(code)
// Store tokens
setAuthTokens(tokens)
// Identify in Fullstory BEFORE redirecting away
FS('setIdentity', {
uid: user.id,
properties: {
displayName: user.name,
email: user.email,
authProvider: 'google', // Track SSO provider
ssoOrganization: user.hostedDomain,
},
})
// Now safe to redirect
redirectToDashboard()
} catch (error) {
handleOAuthError(error)
}
}
Why this is good:
// GOOD: Using schema for explicit type control
FS('setIdentity', {
uid: 'usr_a1b2c3d4e5',
properties: {
displayName: 'Sarah Johnson',
email: '[email protected]',
accountBalance: 1500.5,
loginCount: 42,
isPremium: true,
signupDate: '2023-06-15T00:00:00Z',
permissions: ['read', 'write', 'admin'],
},
schema: {
accountBalance: 'real',
loginCount: 'int',
isPremium: 'bool',
signupDate: 'date',
permissions: 'strs',
},
})
Why this is good:
// BAD: Using email as the unique identifier
FS('setIdentity', {
uid: user.email, // BAD: PII as uid
properties: {
displayName: user.name,
},
})
Why this is bad:
CORRECTED VERSION:
// GOOD: Use stable database ID
FS('setIdentity', {
uid: user.id, // Stable, non-PII identifier
properties: {
displayName: user.name,
email: user.email, // Email as a searchable property, not the uid
},
})
// BAD: Calling setIdentity before auth is confirmed
function handleLoginClick() {
const credentials = getFormCredentials()
// BAD: Identifying with form data before server confirms identity
FS('setIdentity', {
uid: credentials.username,
properties: {
email: credentials.email,
},
})
// This might fail - user isn't actually authenticated yet!
authenticateUser(credentials)
}
Why this is bad:
CORRECTED VERSION:
// GOOD: Only identify after successful authentication
async function handleLoginClick() {
const credentials = getFormCredentials()
try {
const response = await authenticateUser(credentials)
// Only identify AFTER server confirms auth
FS('setIdentity', {
uid: response.user.id,
properties: {
displayName: response.user.name,
email: response.user.email,
},
})
redirectToDashboard()
} catch (error) {
// Login failed - user remains anonymous
showLoginError(error)
}
}
// BAD: Trying to switch users without proper anonymization
function switchUserAccount(newUser) {
// This will cause a session split, not update the identity!
FS('setIdentity', {
uid: newUser.id,
properties: {
displayName: newUser.name,
},
})
}
Why this is bad:
CORRECTED VERSION:
// GOOD: Properly handle account switching
async function switchUserAccount(newUser) {
// First, anonymize the current session
FS('setIdentity', {anonymous: true})
// Then identify as the new user (starts fresh session)
FS('setIdentity', {
uid: newUser.id,
properties: {
displayName: newUser.name,
email: newUser.email,
},
})
}
// BAD: Over-calling setIdentity
function handleButtonClick(buttonId) {
// BAD: Don't call setIdentity on every interaction!
FS('setIdentity', {
uid: currentUser.id,
properties: {
displayName: currentUser.name,
lastAction: buttonId, // Trying to track actions via identity
},
})
performAction(buttonId)
}
Why this is bad:
CORRECTED VERSION:
// GOOD: Identify once, use events for actions
// On page load / auth
FS('setIdentity', {
uid: currentUser.id,
properties: {
displayName: currentUser.name,
email: currentUser.email,
},
})
// For tracking actions - use trackEvent instead
function handleButtonClick(buttonId) {
FS('trackEvent', {
name: 'Button Clicked',
properties: {
buttonId: buttonId,
buttonSection: getButtonSection(buttonId),
},
})
performAction(buttonId)
}
// BAD: Minimal identification with no useful properties
FS('setIdentity', {
uid: user.id,
// No properties at all!
})
Why this is bad:
CORRECTED VERSION:
// GOOD: Rich user context
FS('setIdentity', {
uid: user.id,
properties: {
displayName: user.fullName || user.username,
email: user.email,
role: user.role,
plan: user.subscriptionPlan,
companyName: user.organization?.name,
signupDate: user.createdAt,
},
})
// BAD: Wrong value formats for intended types
FS('setIdentity', {
uid: 'usr_123',
properties: {
displayName: 'John Doe',
loginCount: '42', // BAD: String instead of number
accountBalance: '$150.00', // BAD: Currency symbol in number
isPremium: 'yes', // BAD: Should be boolean
signupDate: 'June 15 2023', // BAD: Not ISO8601 format
},
schema: {
loginCount: 'int',
accountBalance: 'real',
isPremium: 'bool',
signupDate: 'date',
},
})
Why this is bad:
CORRECTED VERSION:
// GOOD: Properly formatted values
FS('setIdentity', {
uid: 'usr_123',
properties: {
displayName: 'John Doe',
loginCount: 42, // Number type
accountBalance: 150.0, // Clean number
currency: 'USD', // Currency as separate field
isPremium: true, // Boolean type
signupDate: '2023-06-15T00:00:00Z', // ISO8601 format
},
schema: {
loginCount: 'int',
accountBalance: 'real',
isPremium: 'bool',
signupDate: 'date',
},
})
┌─────────────────┐
│ Anonymous │ ← Initial state (no setIdentity called)
│ Session │
└────────┬────────┘
│ User logs in
▼
┌─────────────────┐
│ Identified │ ← setIdentity({ uid: 'xxx' }) called
│ Session │
└────────┬────────┘
│ User logs out
▼
┌─────────────────┐
│ New Anonymous │ ← setIdentity({ anonymous: true }) called
│ Session │
└─────────────────┘
// For apps where users can switch between accounts
class FullstoryIdentityManager {
currentUserId = null
identify(user) {
if (this.currentUserId && this.currentUserId !== user.id) {
// Different user - must anonymize first
this.anonymize()
}
FS('setIdentity', {
uid: user.id,
properties: {
displayName: user.name,
email: user.email,
},
})
this.currentUserId = user.id
}
anonymize() {
FS('setIdentity', {anonymous: true})
this.currentUserId = null
}
updateProperties(properties) {
// Use setProperties for property-only updates
FS('setProperties', {
type: 'user',
properties: properties,
})
}
}
// For apps with guest checkout → account creation flow
class ProgressiveIdentification {
// During guest checkout - don't identify yet
handleGuestCheckout(cart) {
// User remains anonymous
// Track the checkout event instead
FS('trackEvent', {
name: 'Guest Checkout Started',
properties: {
cartValue: cart.total,
itemCount: cart.items.length,
},
})
}
// When guest creates account after checkout
handleAccountCreation(user) {
// NOW identify them - this links all prior anonymous activity
FS('setIdentity', {
uid: user.id,
properties: {
displayName: user.name,
email: user.email,
accountCreatedDuringCheckout: true,
},
})
}
}
// setIdentity can include properties
FS('setIdentity', {
uid: user.id,
properties: {
displayName: user.name,
email: user.email,
plan: 'starter', // Initial plan at signup
},
})
// Later, update properties without re-identifying
// (user upgraded their plan)
FS('setProperties', {
type: 'user',
properties: {
plan: 'professional',
upgradedAt: new Date().toISOString(),
},
})
// Identify user
FS('setIdentity', {
uid: user.id,
properties: {displayName: user.name},
})
// Events are automatically linked to identified user
FS('trackEvent', {
name: 'Feature Used',
properties: {
featureName: 'Advanced Export',
exportFormat: 'CSV',
},
})
// User identity
FS('setIdentity', {
uid: user.id,
properties: {displayName: user.name},
})
// Page context (separate concern)
FS('setProperties', {
type: 'page',
properties: {
pageName: 'Dashboard',
dashboardView: 'analytics',
},
})
Symptom: User appears anonymous despite calling setIdentity
Common Causes:
Solutions:
await FS('setIdentityAsync', {...})Symptom: User has many fragmented sessions
Common Causes:
Solutions:
Symptom: User properties don't show in Fullstory
Common Causes:
Solutions:
When helping developers implement User Identification:
Always emphasize:
Common mistakes to watch for:
Questions to ask developers:
Integration considerations:
This skill document was created to help Agent understand and guide developers in implementing Fullstory's User Identification API correctly for web applications.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience