Associate known user data with Snitcher visitor sessions for enhanced lead intelligence.
When a visitor logs in, fills out a form, or otherwise reveals their identity, you can use the identify method to associate their information with the Snitcher session. This enables richer lead data and better attribution.
// After successful authenticationasync function handleLogin(credentials) { const user = await login(credentials); // Identify the user to Snitcher Snitcher.identify(user.email, { name: user.name, user_id: user.id, plan: user.subscription.plan, account_created: user.createdAt });}
// Example with IntercomIntercom('onUserEmail', function(email) { Snitcher.identify(email);});// Example with Driftdrift.on('emailCapture', function(data) { Snitcher.identify(data.email, { source: 'drift_chat' });});
For login methods that don’t use traditional forms—Google Sign-In, GitHub OAuth, SAML SSO, or magic links—you’ll need to call identify manually after authentication completes.
Snitcher’s automatic form tracking captures emails from standard forms, but OAuth and SSO flows bypass form submission entirely. Manual identification is required.
// Using Google Identity Servicesgoogle.accounts.id.initialize({ client_id: 'YOUR_CLIENT_ID', callback: handleCredentialResponse});function handleCredentialResponse(response) { // Decode the JWT to get user info const payload = decodeJwt(response.credential); // Identify to Snitcher Snitcher.identify(payload.email, { name: payload.name, auth_provider: 'google', google_id: payload.sub }); // Continue with your auth flow authenticateWithBackend(response.credential);}
// When user clicks magic link and lands on your appasync function handleMagicLinkAuth() { const token = getTokenFromURL(); const user = await verifyMagicLink(token); if (user) { // Identify to Snitcher Snitcher.identify(user.email, { name: user.name, auth_provider: 'magic_link' }); }}
Only identify users who have consented to tracking. In regions with strict privacy laws (GDPR, CCPA), ensure you have appropriate consent before calling identify.
If you’re using consent management:
Copy
// Only identify after consentif (hasUserConsent()) { Snitcher.identify(user.email, { name: user.name });}