> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unifygtm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Capture user logins

> Identify users when they sign in to your application.

## Overview

All the activity you track in your application is associated with a *visitor*
who may or may not have a known identity. When a user signs in, you can send an
Identify event. This associates all their past and future activity with a known
person (and optionally a company) in Unify.

## Prerequisites

* Ensure you've already installed the Unify Intent client in your application.
  See [Set up the Unify Intent client](https://docs.unifygtm.com/developers/guides/product-usage-data/unify-intent-client.md)
  for instructions.

## Walkthrough

### Identify on login

Call `identify` as soon as the user is authenticated. Include useful traits for
the person and (optionally) the company they belong to.

```ts theme={null}
// Determine the current user however you normally do so
const currentUser = getCurrentUser();

// Send an "Identify" event
unify.identify(currentUser.emailAddress, {
  // Link this visitor to a Person
  person: {
    email: currentUser.emailAddress,
    first_name: currentUser.firstName,
    last_name: currentUser.lastName,
  },

  // If possible, link this visitor to a Company as well
  company: currentUser.organization
    ? {
        domain: currentUser.organization.domain,
        name: currentUser.organization.name,
      }
    : undefined,
});
```

### Send custom event (optional)

You may also want to track that the user logged in. Identify events link
visitors to people or companies, but they don't record an activity that can be
seen or used in Unify. If you want to see when users log in or filter plays based
on login activity, you should also send a custom event.

```ts theme={null}
unify.track('User Logged In');
```

As with all custom events, you can also include additional properties to provide
more context about the login.

## Capture interactions

Now that visitors to your application are identified, you can start tracking key
in-app interactions to power plays. For more information, see [Capture user interactions](https://docs.unifygtm.com/developers/guides/product-usage-data/user-interactions.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.