# Set up SourceTag with HubSpot Forms

Canonical: https://sourcetag.io/docs/fields-hubspot-forms

HubSpot Forms work differently from WordPress form builders. You need to:
1. Create custom contact properties in HubSpot first
2. Add those properties as hidden fields in the HubSpot form builder
3. SourceTag populates them when the form is embedded on your site

## What you need

- SourceTag installed on your website (where the HubSpot form is embedded)
- HubSpot account with access to contact properties and forms

## Step 1: Create contact properties in HubSpot

Go to **Settings > Properties** in HubSpot. Create a new property for each SourceTag field.

For each property:
- **Object type:** Contact
- **Group:** Create a group called "SourceTag Attribution" (keeps things tidy)
- **Field type:** Single-line text
- **Internal name:** Match the SourceTag field name exactly

### Core properties (create these)

- `st_fc_channel`
- `st_fc_detail_1`
- `st_fc_detail_2`
- `st_fc_detail_3`
- `st_fc_detail_4`
- `st_lc_channel`
- `st_lc_detail_1`
- `st_lc_detail_2`
- `st_lc_detail_3`
- `st_lc_detail_4`
- `st_fc_landing_page`
- `st_lc_landing_page`

### Optional extended properties

If you've enabled extended field groups in your SourceTag dashboard, also create:

- `st_fc_click_id` and `st_lc_click_id` (click IDs)
- `st_visits` (visit count)
- `st_days_to_convert` (days to convert)
- `st_device` (device type)

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


## Step 2: Add hidden fields to your HubSpot form

Go to **Marketing > Forms** and edit your form.

1. From the field panel on the left, drag a field onto the form
2. Search for the property you created (e.g. `st_fc_channel`)
3. Once added, click on the field and toggle **Make this field hidden**

Repeat for all SourceTag properties.


## Step 3: Embed the form on your site

Use HubSpot's embed code to add the form to your website. The page must also have the SourceTag script installed.

SourceTag detects HubSpot forms when they load (using MutationObserver for dynamically embedded forms) and populates the hidden fields.

## Step 4: Test

Visit the page with UTM parameters:

```text
?utm_source=test&utm_medium=cpc&utm_campaign=hubspot-test
```

Submit the form. In HubSpot, go to **Contacts** and find the test submission. Check the "SourceTag Attribution" property group for the data.
## Important notes

- The HubSpot property **internal name** must match the SourceTag field name exactly. HubSpot sometimes modifies internal names (adds underscores, lowercases, etc.), so double-check.
- HubSpot forms embedded via the JS embed method work best. iFrame embeds may not work due to cross-origin restrictions.
- If you use HubSpot's non-HubSpot form feature (tracking forms built outside HubSpot), the process is different. Use hidden fields in your external form builder instead.
