# Set up SourceTag with Microsoft Dynamics 365

Canonical: https://sourcetag.io/docs/setup-microsoft-dynamics

When a visitor submits a form with SourceTag data, the attribution fields need somewhere to go in Dynamics 365. You need to create custom contact fields that match the SourceTag field names.

## What you need

- SourceTag installed and form hidden fields set up
- Microsoft Dynamics 365 account with admin access

## Step 1: Go to custom fields settings

In Dynamics 365, navigate to the custom fields settings.
## Step 2: Create custom fields

Create a new custom text field for each SourceTag data point:

### Core fields (create these)

| Field name | Label | Type |
|-----------|-------|------|
| `st_fc_channel` | First Click Channel | Single line of text |
| `st_fc_detail_1` | First Click Smart Field 1 | Single line of text |
| `st_fc_detail_2` | First Click Smart Field 2 | Single line of text |
| `st_fc_detail_3` | First Click Smart Field 3 | Single line of text |
| `st_fc_detail_4` | First Click Smart Field 4 | Single line of text |
| `st_lc_channel` | Last Click Channel | Single line of text |
| `st_lc_detail_1` | Last Click Smart Field 1 | Single line of text |
| `st_lc_detail_2` | Last Click Smart Field 2 | Single line of text |
| `st_lc_detail_3` | Last Click Smart Field 3 | Single line of text |
| `st_lc_detail_4` | Last Click Smart Field 4 | Single line of text |
| `st_fc_landing_page` | First Click Landing Page | Single line of text |
| `st_lc_landing_page` | Last Click Landing Page | Single line of text |

### Optional extended fields

| Field name | Label | Type |
|-----------|-------|------|
| `st_fc_click_id` | First Click Click ID | Single line of text |
| `st_lc_click_id` | Last Click Click ID | Single line of text |
| `st_visits` | Visit Count | Number |
| `st_days_to_convert` | Days to Convert | Number |
| `st_device` | Device Type | Single line of text |

See [Captured Fields](https://sourcetag.io/docs/captured-fields) for the full list of available fields.

## Step 3: Map form fields to CRM fields

If your form builder sends data to Dynamics 365 via an integration (Zapier, native feed, webhook, etc.), make sure the SourceTag form fields are mapped to the corresponding Dynamics 365 custom fields.
## Step 4: Test

Submit a form with UTM parameters and check the contact record in Dynamics 365. The custom fields should be populated with attribution data.
## Tips

- Add SourceTag fields to a dedicated form section (e.g. "SourceTag Attribution") to keep things organised.
- Dynamics 365 adds a publisher prefix to custom field names (e.g. `new_st_fc_channel`). Make sure your field mapping accounts for this prefix.
- Test with a fresh contact (not one that already exists) for the cleanest test.
