# Attribution

Attribution answers one question for every lead: what did this lead touch before it arrived? HeyMySocial answers it with fixed rules. A lead is tied to a touchpoint only through something that was actually recorded, and when nothing was, the answer is "unknown". Nothing is guessed, and nothing is estimated.

## What ties a lead to a touchpoint

A touchpoint is one recorded contact: a click on a tracked link, a visit with campaign parameters, a visit from another site, or a direct visit. A lead is tied to a touchpoint in four ways only:

1. **Its own session.** The lead was sent from a visit the site script was following, with the visitor's consent. Every touchpoint of that session belongs to the lead.
2. **A signed click reference.** A [tracked link](https://heymysocial.com/docs/tracking/links) adds `hms_ref` to its destination. A form that hands it back ties the lead to that exact click, without a cookie.
3. **A tracked link it named.** Whoever sent the lead (a file row, an API call, an assistant passing on what the person said) gave the link's code. This is recorded as stated: no click was measured.
4. **A campaign it named.** The sender gave a campaign reference with the lead. No touchpoint exists; the lead is tied to the campaign itself.

Touchpoints that are never used: one recorded where consent was refused, one that happened after the lead arrived, and one older than the window.

## The two models

Every lead gets a result from both models. They look at the same touchpoints and pick differently.

| Model | Value | Picks |
|---|---|---|
| First touch | `first_touch` | The earliest touchpoint in the window |
| Last non-direct touch | `last_non_direct` | The latest touchpoint in the window that was not a direct visit |

Reports, the Leads table, exports and assistant tools use `last_non_direct` unless you choose otherwise. On **Analytics**, the filter **Attribution model** switches between the two. On a lead's page, the card **Where it came from** shows both, each with its reason.

## The four outcomes

| Outcome | Value | When |
|---|---|---|
| Matched | `matched` | The picked touchpoint says where the visit came from: a tracked link, campaign parameters or a referring site. Also when there is no touchpoint but the sender named a campaign |
| Direct | `direct` | First touch: the earliest touchpoint was a direct visit. Last non-direct touch: every touchpoint in the window was a direct visit |
| Unknown | `unknown` | No touchpoint could be tied to the lead, the only ones are older than the window, or the touchpoint does not say where the visit came from |
| No consent | `no_consent` | Tracking consent was refused for the lead, so no touchpoint is used at all |

A matched result carries what the touchpoint names: the campaign, the tracked link, the post or the ad, and a channel. The channel comes from the tracked link, from `utm_medium` (paid social, organic social, email, referral, otherwise "other"), from a referring site (referral), or from the kind of the named campaign.

Each result stores its reason as a sentence. The stored sentence is English; the app shows it in your language.

```text
The first touchpoint in the 30-day window was the tracked link "Spring offer".
The last touchpoint that was not a direct visit in the 30-day window was a visit with campaign parameters (newsletter / email / spring).
The sender named the tracked link "Spring offer" with the lead. No click was measured.
The only touchpoints are older than the 30-day window.
No tracking consent was given, so no touchpoint is used for this lead.
```

## The window

The window is how far back before a lead arrived a touchpoint still counts. It is one setting for the whole workspace, in days.

<div class="table-scroll"><table><thead><tr><th>Window</th><th>Use</th></tr></thead><tbody><tr><th scope="row">7 days</th><td>Can be chosen</td></tr><tr><th scope="row">14 days</th><td>Can be chosen</td></tr><tr><th scope="row">30 days</th><td>Default for a new workspace</td></tr><tr><th scope="row">60 days</th><td>Can be chosen</td></tr><tr><th scope="row">90 days</th><td>Can be chosen</td></tr></tbody></table></div>

To change it, open **Analytics**, find the card **Attribution window**, choose the number of days and press **Change window**. Every lead in the workspace is then attributed again. It takes the `manage_workspace` ability.

The same number is under **Settings**, **Workspace**, and an assistant can set it with [update_workspace](https://heymysocial.com/docs/assistant/tools/update-workspace). Set there, the new window is used for each lead the next time that lead is calculated; it does not start a recalculation of every lead by itself.

## Versions and recalculation

A result records what it was calculated with: the model, the model version, the window in days and the time. The lead's page shows all of them under the reason.

A lead is calculated when it arrives, and again when something arrives that can change the answer:

- a touchpoint that reaches the lead's session after the lead did;
- a sale or a refund recorded for the lead;
- a new window chosen on **Analytics**;
- a lead that came in through a CRM connection and has no result yet.

When the answer changes, the earlier result is not overwritten. It is kept as history and marked as no longer current, and the new one becomes the current result. When the answer is the same, only the time of calculation moves. Reports always read the current result.

## What is and is not attributed

Attributed, each to the lead's current result for the chosen model:

- the lead itself, and what it became: qualified, won, lost, disqualified;
- revenue from sales on the booked basis, net of refunds, per currency.

Not attributed, by design:

- **Nobody is matched by guesswork.** There is no fingerprinting, no matching on address or device, and no joining of visits across devices. A lead whose visit was not followed is unknown.
- **Views are not touchpoints.** Someone who saw a post or an ad and did not click leaves no touchpoint.
- **Platform numbers stay apart.** Leads and conversions that an ad platform reports are counted by its own rules. They are shown beside the leads matched here and never added to them.
- **Duplicates count once.** A second lead from the same person within the duplicate period is kept and left out of results.
- **Currencies are never added together.** Revenue is shown per currency.

A missing number is shown as "N/A", never as zero. Coverage, the share of leads with a matched result, is shown with the results so you can see how much of the picture is known.

<div class="callout callout-note"><p class="callout-title">Association, not cause</p>

A result says what a lead touched before it arrived. It does not prove that the channel caused the lead, and HeyMySocial never presents it as proof.

</div>


## Read it with an assistant

[get_results](https://heymysocial.com/docs/assistant/tools/get-results) returns leads, qualified leads, sales and revenue with coverage, and takes `model` (`first_touch` or `last_non_direct`). [get_lead](https://heymysocial.com/docs/assistant/tools/get-lead) returns one lead with its attribution and reason. [get_funnel_matrix](https://heymysocial.com/docs/assistant/tools/get-funnel-matrix) sets spend beside the matched outcomes of each campaign.
