Sending data
Identify users
Beacon counts visitors anonymously. When someone signs in to your site, tell Beacon your ID for them, and their visits link to that user from then on.
Identify someone
// After someone signs in, with your own ID for them
beacon('identify', 'user_8f3a2c');From then on, every event from this browser carries that user ID, and the visitor's earlier visits are linked to it too. In Sessions you can search for the ID and follow everything they did. Beacon remembers it in this browser, so calling it once after sign-in is enough; calling it on every page is also fine.
// Wherever your app knows who is signed in
if (currentUser) {
beacon('identify', currentUser.id);
}On sign-out
// When they sign out
beacon('reset');This forgets the user ID and the anonymous visitor ID in this browser, stops any session recording, and starts a fresh anonymous visitor. Call it when someone signs out, so the next person on a shared computer isn't counted as them.
Across devices
Each browser starts as its own anonymous visitor. When the same person signs in on their phone and their laptop, both carry your user ID from then on: search for it in Sessions to find their visits from every device. Experiments and feature flags can also split by user, so someone sees the same version on every device. See the reference for every command.