# Advanced Matching

Advanced matching allows Whop to match events to users more accurately by sending customer identifiers alongside the event.

**Important:** Unlike TikTok and Meta, Whop expects customer fields in **plain text**. HandL sends them unhashed by design. Do not hash emails or phone numbers before passing them.

### How It Works

1. **Data Collection:** When users fill out forms, HandL automatically captures customer details. Data is stored in localStorage with keys such as `em` (email) and `ph` (phone).
2. **Automatic Merging:** Every call to `HandL.sendWhopEvent()` merges any stored customer values into the event payload. Fields you pass directly always override the stored values.
3. **External ID:** Uses the `first_handlID` cookie as `external_id`. This is automatically generated on first visit.
4. **Full Name:** When a first or last name is available, HandL composes `name` automatically.

### Manual Data Collection

You can pass customer fields directly on any event:

```javascript
HandL.sendWhopEvent('lead', {
    event_id: 'lead_8f21c0',
    email: 'visitor@example.com',
    first_name: 'Jane',
    last_name: 'Doe',
    phone: '+15551234567'
});

```

### Advanced Matching Parameters

Whop supports the following identifiers (all sent as plain text):

<table id="bkmrk-parameterdescription"><thead><tr><th>Parameter</th><th>Description</th><th>Source</th></tr></thead><tbody><tr><td>`email`</td><td>User's email address</td><td>`localStorage.getItem('em')`</td></tr><tr><td>`first_name`</td><td>User's first name</td><td>`localStorage.getItem('fn')`</td></tr><tr><td>`last_name`</td><td>User's last name</td><td>`localStorage.getItem('ln')`</td></tr><tr><td>`name`</td><td>Full name</td><td>Composed from first and last name</td></tr><tr><td>`phone`</td><td>User's phone number</td><td>`localStorage.getItem('ph')`</td></tr><tr><td>`city`</td><td>User's city</td><td>`localStorage.getItem('ct')`</td></tr><tr><td>`state`</td><td>User's state</td><td>`localStorage.getItem('st')`</td></tr><tr><td>`postal_code`</td><td>User's postal code</td><td>`localStorage.getItem('zp')`</td></tr><tr><td>`country`</td><td>User's country</td><td>`localStorage.getItem('country')`</td></tr><tr><td>`external_id`</td><td>Unique identifier</td><td>`Cookies.get('first_handlID')`</td></tr></tbody></table>

Empty fields are dropped automatically and never sent.

### Verification

To verify advanced matching is working:

1. Open browser DevTools (F12)
2. Go to the Network tab
3. Filter for `t.whop.tw`
4. Inspect the request payload and confirm your customer fields are present