{"title":"Identify","description":"Identify users in Altertable Product Analytics so events connect to stable profiles, traits, and business context.","order":300,"askSuggestions":["How do I link anonymous activity to a user after login?","How do I stop events going to the previous user after logout?","Can I use email addresses as user IDs?"],"navigation":true,"body":{"code":"var Component=(()=>{var f=Object.create;var o=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var I=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),w=(n,e)=>{for(var i in e)o(n,i,{get:e[i],enumerable:!0})},d=(n,e,i,s)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let r of m(e))!x.call(n,r)&&r!==i&&o(n,r,{get:()=>e[r],enumerable:!(s=y(e,r))||s.enumerable});return n};var b=(n,e,i)=>(i=n!=null?f(v(n)):{},d(e||!n||!n.__esModule?o(i,\"default\",{value:n,enumerable:!0}):i,n)),D=n=>d(o({},\"__esModule\",{value:!0}),n);var h=I((P,l)=>{l.exports=_jsx_runtime});var S={};w(S,{default:()=>p,frontmatter:()=>g});var t=b(h()),g={title:\"Identify\",description:\"Identify users in Altertable Product Analytics so events connect to stable profiles, traits, and business context.\",order:300,askSuggestions:[\"How do I link anonymous activity to a user after login?\",\"How do I stop events going to the previous user after logout?\",\"Can I use email addresses as user IDs?\"]};function u(n){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",li:\"li\",p:\"p\",ul:\"ul\",...n.components},{DocsPreviewDocument:i,DocsPreviewSection:s,DocsSdkContent:r,DocsSdkSnippetTabs:a}=e;return i||c(\"DocsPreviewDocument\",!0),s||c(\"DocsPreviewSection\",!0),r||c(\"DocsSdkContent\",!0),a||c(\"DocsSdkSnippetTabs\",!0),(0,t.jsxs)(i,{anchors:\"identify-users when-to-call-it sdk-examples api-reference best-practices\",children:[(0,t.jsxs)(s,{sectionId:\"identify-users\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,t.jsx)(e.h1,{id:\"identify-users\",children:\"Identify Users\"}),`\n`,(0,t.jsxs)(e.p,{children:[\"Use \",(0,t.jsx)(e.code,{children:\"identify\"}),\" when you know who a user is. Identification connects anonymous or device-level activity to a stable user ID and stores traits such as plan, role, or account tier.\"]}),`\n`,(0,t.jsxs)(e.p,{children:[\"In practice, \",(0,t.jsx)(e.code,{children:\"identify()\"}),' is the moment when analytics move from \"someone did this\" to \"this user did this\".']}),`\n`]}),(0,t.jsxs)(s,{sectionId:\"when-to-call-it\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,t.jsx)(e.h2,{id:\"when-to-call-it\",children:\"When to call it\"}),`\n`,(0,t.jsxs)(e.p,{children:[\"Call \",(0,t.jsx)(e.code,{children:\"identify()\"}),\" as soon as your application establishes or restores authenticated user state:\"]}),`\n`,(0,t.jsxs)(e.ul,{children:[`\n`,(0,t.jsx)(e.li,{children:\"after sign-up\"}),`\n`,(0,t.jsx)(e.li,{children:\"after login\"}),`\n`,(0,t.jsx)(e.li,{children:\"on application load when the user is already authenticated\"}),`\n`]}),`\n`,(0,t.jsxs)(e.p,{children:[\"Client-side SDKs can link the anonymous activity that happened before login to the stable user ID. Server-side SDKs and direct API clients should pass the \",(0,t.jsx)(e.code,{children:\"distinct_id\"}),\" and traits explicitly.\"]}),`\n`]}),(0,t.jsxs)(s,{sectionId:\"sdk-examples\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,t.jsx)(e.h2,{id:\"sdk-examples\",children:\"SDK examples\"}),`\n`,(0,t.jsx)(e.p,{children:\"Update user or account traits when they change. Keep traits focused on fields you expect to analyze, filter, or join against:\"}),`\n`,(0,t.jsx)(a,{snippetId:\"update-traits\"}),`\n`,(0,t.jsx)(e.p,{children:\"On logout, reset the client identity so later activity is not attributed to the previous user:\"}),`\n`,(0,t.jsx)(a,{snippetId:\"reset\"}),`\n`,(0,t.jsx)(r,{languageIds:[\"react-native\"],children:(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:\"reset()\"}),\" returns a promise that resolves after the new identity is saved. It also clears events that have not been sent yet.\"]})}),`\n`]}),(0,t.jsxs)(s,{sectionId:\"api-reference\",anchors:\"\",ancestors:\"\",index:\"3\",children:[(0,t.jsx)(e.h2,{id:\"api-reference\",children:\"API reference\"}),`\n`,(0,t.jsxs)(e.p,{children:[\"For HTTP request details, response shape, and error codes, see \",(0,t.jsx)(e.a,{href:\"/docs/api-references/product-analytics#post-identify\",children:(0,t.jsx)(e.code,{children:\"POST /identify\"})}),\".\"]}),`\n`]}),(0,t.jsxs)(s,{sectionId:\"best-practices\",anchors:\"\",ancestors:\"\",index:\"4\",children:[(0,t.jsx)(e.h2,{id:\"best-practices\",children:\"Best practices\"}),`\n`,(0,t.jsxs)(e.ul,{children:[`\n`,(0,t.jsx)(e.li,{children:\"Use stable, immutable IDs from your own user system.\"}),`\n`,(0,t.jsxs)(e.li,{children:[\"Avoid mutable identifiers such as email addresses as \",(0,t.jsx)(e.code,{children:\"distinct_id\"}),\".\"]}),`\n`,(0,t.jsx)(e.li,{children:\"Keep traits current as account state changes.\"}),`\n`,(0,t.jsx)(e.li,{children:\"Avoid secrets and regulated sensitive data in traits.\"}),`\n`]})]})]})}function p(n={}){let{wrapper:e}=n.components||{};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(u,{...n})}):u(n)}function c(n,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+n+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return D(S);})();\n;return Component;"},"_id":"docs/product-analytics/identify.mdx","_raw":{"sourceFilePath":"docs/product-analytics/identify.mdx","sourceFileName":"identify.mdx","sourceFileDir":"docs/product-analytics","contentType":"mdx","flattenedPath":"docs/product-analytics/identify"},"type":"Docs","path":"/product-analytics/identify","level":2,"parent":"product-analytics"}