# Event types

Everything that is measured in HeyMySocial enters as an event: a page view from the site script, a lead from a form, a sale from your CRM. The event log holds only the types below, whichever door an event came through. An event with any other `type` is refused with `validation_failed`.

<div class="table-scroll"><table><thead><tr><th>Type</th><th>Name in the app</th><th>Needs an existing lead</th><th>Moves the lead to</th></tr></thead><tbody><tr><th scope="row"><code style="white-space:nowrap">page_view</code></th><td>Page view</td><td>No</td><td>No change</td></tr><tr><th scope="row"><code style="white-space:nowrap">link_click</code></th><td>Link click</td><td>No</td><td>No change</td></tr><tr><th scope="row"><code style="white-space:nowrap">form_started</code></th><td>Form started</td><td>No</td><td>No change</td></tr><tr><th scope="row"><code style="white-space:nowrap">lead_created</code></th><td>Lead created</td><td>No</td><td><code style="white-space:nowrap">new</code> New</td></tr><tr><th scope="row"><code style="white-space:nowrap">lead_contacted</code></th><td>Lead contacted</td><td>Yes</td><td><code style="white-space:nowrap">contacted</code> Contacted</td></tr><tr><th scope="row"><code style="white-space:nowrap">lead_qualified</code></th><td>Lead qualified</td><td>Yes</td><td><code style="white-space:nowrap">qualified</code> Qualified</td></tr><tr><th scope="row"><code style="white-space:nowrap">lead_disqualified</code></th><td>Lead disqualified</td><td>Yes</td><td><code style="white-space:nowrap">disqualified</code> Disqualified</td></tr><tr><th scope="row"><code style="white-space:nowrap">appointment_booked</code></th><td>Appointment booked</td><td>Yes</td><td>No change</td></tr><tr><th scope="row"><code style="white-space:nowrap">opportunity_created</code></th><td>Opportunity created</td><td>Yes</td><td><code style="white-space:nowrap">opportunity</code> Opportunity</td></tr><tr><th scope="row"><code style="white-space:nowrap">quote_sent</code></th><td>Quote sent</td><td>Yes</td><td><code style="white-space:nowrap">opportunity</code> Opportunity</td></tr><tr><th scope="row"><code style="white-space:nowrap">sale_won</code></th><td>Sale won</td><td>Yes</td><td><code style="white-space:nowrap">won</code> Won</td></tr><tr><th scope="row"><code style="white-space:nowrap">sale_lost</code></th><td>Sale lost</td><td>Yes</td><td><code style="white-space:nowrap">lost</code> Lost</td></tr><tr><th scope="row"><code style="white-space:nowrap">sale_refunded</code></th><td>Sale refunded</td><td>Yes</td><td>No change</td></tr></tbody></table></div>

The first column is the value you send as `type`. The envelope around it (`event_id`, `occurred_at`, `properties` and the rest) is described under [server events](https://heymysocial.com/docs/tracking/server-events).

## Three kinds of event

**Behaviour** is `page_view`, `link_click` and `form_started`. These describe a visit, not a lead. They need a `session_id` and are tied to a visit only with consent: on a tracking site that requires consent only when `consent_state` is `granted`, on a site where consent is optional unless it is `denied`, and through the API without a site only when it is `granted` or `not_applicable`. Without that, the event is logged but no session and no touchpoint is made from it.

**`lead_created`** makes a lead. It needs no existing lead, but `properties.contact` must hold a name, an email address or a phone number.

**Everything else** says what happened to a lead that already exists, so it must name the lead: `lead_id` (the id HeyMySocial gave it) or `lead_external_id` (the `external_id` you sent with its `lead_created`). A lead is never found by a name or an email address in these events.

## What each type does

### Visits

- `page_view` opens or continues the visitor's session. It can give the session a touchpoint: the click a signed reference (`hms_ref`) names, a visit with campaign parameters (`utm_source`, `utm_medium`, `utm_campaign`, `utm_content`, `utm_term`), or, for the first view of a session, a visit from an outside referrer (`referrer_host`) or a direct visit.
- `link_click` is written by a [tracked link](https://heymysocial.com/docs/tracking/links) when someone follows it.
- `form_started` is kept with the session. It makes no touchpoint.

### Leads

- `lead_created` takes `properties.contact` (`name`, `email`, `phone`, `company`), up to 40 answers in `properties.form`, and optionally `status`, `note`, `tracking_link` (a tracked link's code), `hms_ref`, `contact_consent` (true or false) and `contact_consent_source`. Send an `external_id`: it is how later events find the lead, and a second `lead_created` with the same source and `external_id` returns the first lead instead of making another.
- `lead_contacted` moves a new lead to contacted. For a lead that is already further on, only the time of first contact is kept, when it is the earliest known.
- `lead_qualified` and `lead_disqualified` take `properties.reason`. A disqualification without one is stored with "Reported by the source."
- `appointment_booked` changes no status. It sets the lead's next step from `properties.title` and `properties.starts_at`.

### Opportunities and sales

- `opportunity_created` adds an opportunity from `properties.name`, `estimated_value` or `estimated_value_minor`, and `currency`.
- `quote_sent` marks the lead's newest open opportunity as quoted, or adds one when there is none.
- `sale_won` records a sale. It needs `properties.amount` (main unit) or `properties.amount_minor` (smallest unit). `currency` falls back to the workspace's currency, `revenue_basis` to `booked` and `verification_source` to `manual` (to `crm` when the event's `source` is `crm`). Its `external_id` identifies the sale.
- `sale_lost` closes the lead's open opportunities as lost and takes `properties.reason`.
- `sale_refunded` needs an amount and names its sale with `properties.sale_id` or `properties.sale_external_id`. When it names none, or one that is not known, and the lead has exactly one sale, that sale is used. A refund must be above zero and at most what is left of the sale. It changes no status.

Only sales on the `booked` basis count as revenue in results, net of their refunds.

## A status only moves forward

A reported event may skip steps forward, never backward. `lead_contacted` for a lead that is already an opportunity changes no status; the event is still stored. A person in the app moves a lead one allowed step at a time; see [lead statuses](https://heymysocial.com/docs/reference/lead-statuses).

To set something right, send a new event with `corrects_event_id` naming the `event_id` it corrects. For a status event, the lead is set to that status as a correction. For `sale_won`, the amount of the sale is corrected. The original event stays in the log.

```json
{
  "events": [
    {
      "event_id": "crm-deal-7781-amount-fix",
      "type": "sale_won",
      "occurred_at": "2026-11-20T10:15:00Z",
      "lead_external_id": "crm-lead-5521",
      "corrects_event_id": "crm-deal-7781",
      "properties": { "amount": 4500, "currency": "DKK" }
    }
  ]
}
```

## An event that arrives before its lead

An event that names a `lead_external_id` nobody has sent yet is stored and answered with `"warning": "unmatched_lead"`. It is listed under **Items to review** on the Funnels screen and applied by itself when a `lead_created` with that `external_id` arrives. A refund whose sale cannot be found is answered with `"warning": "unmatched_sale"` and listed in the same place.

## Duplicates and test events

An event is recognised as already seen by its source and `event_id`, or by its source, `type` and `external_id`. It is answered with `"status": "duplicate"` and the ids of the first one, and nothing changes. Sending the same event twice is therefore safe.

An event with `"test": true` is shown as received and changes nothing: no lead, no sale, and it does not count toward the month's tracked events.
