# segment identify call missing userId error

## TL;DR
identify binds traits to a user, so calling it without a user ID is meaningless and gets rejected or dropped. Find the call site, wait until authentication gives you a real user ID before calling identify, and let anonymous visitors keep their generated anonymous ID without an identify call. Confirm in the Segment debugger that identify events now carry IDs.

```text
segment identify call missing userId error
```

## Use this when

- Segment debugger shows identify calls without userId
- Identify calls error or get dropped in the pipeline
- User traits never attach to profiles

## Not for this skill when

- Track calls missing properties (different call, different fix)
- Destination mapping errors on valid identify calls
- Anonymous ID generation issues in the Segment snippet

## Steps

### Step 1: Find the offending call

Search the codebase for identify calls and find the one firing without a user ID. Expected: you locate the exact call site and its trigger.

### Step 2: Wait for authentication

Move the identify call to after login completes, so a real user ID is available. Expected: identify only fires when there is an identity to bind.

### Step 3: Handle anonymous visitors

For logged-out users, skip identify entirely and let the snippet's anonymous ID do its job. Expected: no more ID-less identify calls for anonymous traffic.

### Step 4: Verify in the debugger

Trigger the flow and watch the Segment debugger. Expected: every identify event carries a userId and traits attach to the profile.

### Step 5: Add a guard

Add a check or test that fails the build if identify is called without an ID. Expected: the bug cannot be reintroduced silently.

## Tool compatibility

Segment analytics.js and server-side libraries; Segment debugger; identify, alias, and track call semantics.

## Variant phrasings

### Variant 1

segment identify missing userId validation error

### Variant 2

segment analytics identify without user id

### Variant 3

segment identify call failed no userId

## Why it happens

Segment's identity model has two halves: anonymousId for unknown visitors and userId for known users, and identify is the call that attaches traits to the known user. Calling identify with neither gives the pipeline nothing to attach traits to, so it errors or drops the event. The bug usually comes from firing identify on page load before authentication resolves, a race between the auth state and the analytics init. Server-side code has the same trap: a background job calling identify with a null user field. The fix is ordering, identity first, identify second, enforced by a guard so the race cannot return.

## Edge cases / pitfalls

- Use alias to merge the anonymous history into the known user at signup; identify alone does not merge.
- Group calls have the same requirement for groupId; check those call sites too.
- Some destinations require userId and silently drop anonymous events; know each destination's rules.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_AcDndM55OkH3X51va5_RHQ
