> AI agents: this is one page of nextanalytica's docs. The full index for agents: https://nextanalytica.app/llms.txt

# Astro user identification

> Tell analytics who signed in to your Astro app, after consent, so one person's visits on every device make one profile.

Updated: 2026-12-01

In Astro, call `identify` with your own user id once the person is signed in, in a script on a page that knows the user. It works only after consent.

## How does it look?

```astro title="src/pages/account.astro"
---
const user = Astro.locals.user // however your app keeps the signed-in user
---
<div id="me" data-id={user?.id} data-plan={user?.plan}></div>

<script>
  import { identify } from '@nextanalytica/tag'

  const el = document.getElementById('me')
  if (el?.dataset.id) identify(el.dataset.id, { plan: el.dataset.plan ?? '' })
</script>
```

On sign-out, call `reset()` from `@nextanalytica/tag`.

## What can you ask your agent?

- "What did user u_4821 do this week?"
- "Which plans do the people who came back belong to?"

## Next steps

- [Astro analytics](/docs/platforms/astro)
- [Identify people](/docs/tracking/identify-people)

Canonical address: https://nextanalytica.app/docs/platforms/astro/identify
