# Sources and campaigns

crowne gives each visit one source. It reads the source from the first page of the visit, so later pages in the same visit do not change it.

## How a visit gets its source

crowne uses the first match in this order:

1. A `utm_source` tag on the landing URL.
2. A `ref` or `source` tag, such as `ref=producthunt`.
3. An ad click id: `gclid` gives Google, `fbclid` gives Facebook, and `msclkid` gives Bing. The medium becomes `cpc`. crowne keeps only the kind of id, never the id itself.
4. The referring site, such as Google or GitHub.

A visit with none of these is **Direct / none**. A referrer on one of the site's own domains is a page change inside the site, so it does not set a source.

## UTM tags

Add tags to the links you share. crowne reads all the standard tags and the extra tags of Google Analytics 4:

| Tag                    | Panel             |
| ---------------------- | ----------------- |
| `utm_source`           | Sources           |
| `utm_medium`           | Mediums           |
| `utm_campaign`         | Campaigns         |
| `utm_content`          | Ad content        |
| `utm_term`             | Search terms      |
| `utm_id`               | Campaign IDs      |
| `utm_source_platform`  | Source platforms  |
| `utm_creative_format`  | Creative formats  |
| `utm_marketing_tactic` | Marketing tactics |

```url
https://example.com/pricing?utm_source=newsletter&utm_medium=email&utm_campaign=launch&utm_id=c-42
```

crowne trims each value and keeps at most 100 characters. It drops an empty tag. The **Campaigns** panel shows each campaign with its source and medium, such as `newsletter / email / launch`.

## Show the panels

The dashboard shows Sources and Campaigns by default. To show other panels, open the site's **Settings**, select them under **Dashboard**, and save.

## Filter by a tag

Click a row in any panel to filter the dashboard by it. The [Stats API](./api.md) takes the same filters, with the tag's panel name:

```sh
curl "https://api.crowne.io/v1/sites/YOUR_SITE_ID/report?period=30d&filter=campaign_id:is:c-42" \
  -H "Authorization: Bearer $CROWNE_KEY"
```
