Cryptique automatically assigns anonymous IDs to track users. When you know who a user is (e.g., after login or wallet connection), use identify() to link their anonymous activity to their known identity.
Cryptique’s CQ Intelligence merge engine automatically consolidates user profiles across sessions, devices, and wallets when you call identify().
// After user logs inCryptique.identify('user_12345');// Using emailCryptique.identify('user@example.com');// Using wallet addressCryptique.identify('0x742d35Cc6634C0532925a3b844Bc9e7595f5bB21');
async function handleLogin(email, password) { const user = await login(email, password); // Identify after successful login Cryptique.identify(user.id); // Optionally set user properties Cryptique.people.set({ email: user.email, plan: user.subscription, signupDate: user.createdAt });}
2
After Signup
When a new user creates an account:
async function handleSignup(userData) { const newUser = await createUser(userData); // Identify the new user Cryptique.identify(newUser.id); // Track signup event Cryptique.track('Signup Completed', { source: userData.referralSource }); // Set initial user properties Cryptique.people.set({ email: newUser.email, signupDate: new Date().toISOString() });}
3
On Page Load (Returning Users)
When a logged-in user returns:
// On app initializationasync function initApp() { await Cryptique.init({ siteId: 'your-site-id' }); // If user is already logged in const currentUser = getCurrentUser(); if (currentUser) { Cryptique.identify(currentUser.id); }}
Cryptique can merge user profiles across domains when you use the same identifyId:
// On app.example.comCryptique.identify('user_12345');// On dashboard.example.com (same user)Cryptique.identify('user_12345');// Cryptique merges all sessions for user_12345 automatically
function handleLogout() { // Clear user session in your app logout(); // Reset Cryptique identity Cryptique.reset(); // Future events will use a new anonymous ID}
Always call reset() when a user logs out. Without this, the next user on the same device could be associated with the previous user’s data.
You can use wallet addresses as the primary identifier:
// When wallet connectsfunction handleWalletConnect(address) { // Use wallet address as identity Cryptique.identify(address); // Also register with walletAddress for enrichment Cryptique.walletAddress(address);}
Using wallet addresses as identifiers works well for Web3 apps where users may not have traditional accounts. The same user with multiple wallets will have separate profiles unless you link them with a common identifier.
New User: If the identifyId hasn’t been seen before, the current anonymous profile is converted to an identified profile.
Existing User, Same Device: If the identifyId matches a profile already on this device, sessions merge seamlessly.
Existing User, New Device: If the identifyId exists from another device, Cryptique’s CQ Intelligence merges the profiles automatically.
Group memberships: When the server returns group_memberships for this user, the SDK restores them locally so group assignments stay in sync across devices.
// Bad - Calling identify too frequentlyfunction onClick() { Cryptique.identify(userId); // Don't identify on every action Cryptique.track('Button Clicked');}// Good - Identify once per sessionasync function initApp() { await Cryptique.init({ siteId: 'your-site-id' }); if (currentUser) { Cryptique.identify(currentUser.id); }}