# Email-to-Web Identity Linking

Link email clicks to website sessions automatically

When a contact clicks a link in one of your emails and lands on your website, Mailnaptic can automatically **link that email contact to their browser session**. This means every page view and custom event from that browser is attributed to a known contact — without the visitor needing to log in or fill out a form.

## How identity linking works

The process is fully automatic once site tracking is installed:

1. A contact clicks a tracked link in your email campaign or automation.
2. Mailnaptic's click tracker redirects the contact to the destination URL and appends a one-time `_mn` query parameter containing a secure, single-use identity token.
3. When the page loads, the Mailnaptic tracking snippet detects the `_mn` parameter and sends an `identify_token` event to Mailnaptic's ingest endpoint.
4. The server validates the token, resolves it to the contact's ID, and retroactively attributes any recent anonymous events from that browser to the contact.
5. The token is consumed and cannot be reused, preventing token sharing or replay attacks.

## What happens to anonymous events

Before a visitor is identified, their events are tracked under an anonymous session ID stored in a first-party cookie (`_mn_aid`). Once identification occurs:

- All **past anonymous events** from that browser session are updated with the contact's ID.
- All **future events** from that browser are automatically attributed to the contact.
- The anonymous session cookie is retained so the link persists across page loads.

## Requirements

For identity linking to work, you need:

- The **Mailnaptic tracking snippet** installed on the pages your email links point to.
- **Click tracking enabled** on the campaign or automation (this is on by default).
- The destination page must be on a domain where the tracking snippet is present. Links to third-party sites cannot trigger identification.

## Privacy and security

Identity tokens are designed with privacy in mind:

- Each token is a **64-character cryptographically random hex string**.
- Tokens are **single-use** — once consumed, they are deleted from the database.
- Tokens expire after **24 hours** if not used.
- The `_mn` parameter is removed from the browser's address bar by the snippet to keep URLs clean.

## Troubleshooting

| Symptom | Possible cause | Fix |
| --- | --- | --- |
| Web events not attributed to contacts | Tracking snippet missing on landing page | Verify the snippet is loaded in your browser's network tab |
| Identity works once then stops | Cookie blocked by browser privacy settings | Ensure first-party cookies are allowed for your domain |
| Token param visible in URL after page load | Snippet not executing or erroring | Check the browser console for JavaScript errors |

> **Note:** Identity linking respects your contacts' privacy preferences. If a contact has opted out of tracking, the identification event is discarded.
