# Set up SourceTag with Squarespace Forms

Canonical: https://sourcetag.io/docs/fields-squarespace

Squarespace's native form blocks have limited support for hidden fields. The most reliable approach is to use a **Code Block** with a custom HTML form instead of the built-in form builder.

## The limitation

Squarespace's native Form Block supports hidden fields, but auto-generates field names with an `SQF_` prefix. You cannot set custom `name` attributes, which means SourceTag can't match fields by name. Because of this, SourceTag cannot populate fields in a native Squarespace form directly.

There are two workarounds:

1. **Code Block with custom HTML form** (recommended) - full control over field names
2. **Third-party form embed** - use a form builder that supports hidden fields (e.g. Tally, JotForm, Fillout) and embed it on your Squarespace page

This guide covers option 1.

## What you need

- SourceTag installed on your Squarespace site (added via Settings > Advanced > Code Injection)
- A Squarespace page where you want the form

## Step 1: Add a Code Block to your page

1. Edit the page in Squarespace
2. Click to add a new content block
3. Choose **Code** from the block options


## Step 2: Build your HTML form

In the Code Block, paste a custom HTML form. Here is a starting template:

```html
<form action="https://your-form-handler-url" method="POST" id="contact-form">
  <!-- Visible fields -->
  <label for="name">Name</label>
  <input type="text" name="name" id="name" required>

  <label for="email">Email</label>
  <input type="email" name="email" id="email" required>

  <label for="message">Message</label>
  <textarea name="message" id="message"></textarea>

  <!-- SourceTag core hidden fields -->
  <input type="hidden" name="st_fc_channel" value="">
  <input type="hidden" name="st_fc_detail_1" value="">
  <input type="hidden" name="st_fc_detail_2" value="">
  <input type="hidden" name="st_fc_detail_3" value="">
  <input type="hidden" name="st_fc_detail_4" value="">
  <input type="hidden" name="st_lc_channel" value="">
  <input type="hidden" name="st_lc_detail_1" value="">
  <input type="hidden" name="st_lc_detail_2" value="">
  <input type="hidden" name="st_lc_detail_3" value="">
  <input type="hidden" name="st_lc_detail_4" value="">
  <input type="hidden" name="st_fc_landing_page" value="">
  <input type="hidden" name="st_lc_landing_page" value="">

  <!-- SourceTag optional fields -->
  <input type="hidden" name="st_fc_click_id" value="">
  <input type="hidden" name="st_lc_click_id" value="">
  <input type="hidden" name="st_visits" value="">
  <input type="hidden" name="st_days_to_convert" value="">
  <input type="hidden" name="st_device" value="">

  <button type="submit">Send</button>
</form>
```

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

Replace `https://your-form-handler-url` with your actual form handler endpoint. This could be a service like Formspree, Basin, Zapier Webhooks, or your own backend.


## Step 3: Style the form (optional)

You can add CSS within a `<style>` tag in the same Code Block to match your Squarespace site's look and feel:

```html
<style>
  #contact-form label { display: block; margin-top: 1rem; font-weight: 600; }
  #contact-form input, #contact-form textarea { width: 100%; padding: 0.5rem; margin-top: 0.25rem; border: 1px solid #ccc; }
  #contact-form button { margin-top: 1rem; padding: 0.75rem 2rem; background: #000; color: #fff; border: none; cursor: pointer; }
</style>
```

## Step 4: Test

Visit the page with UTM parameters:

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

Submit the form. Check your form handler for the submission data. The hidden fields should contain your attribution data.
## Tips

- Since you are using a Code Block, you have full control over the HTML. This is the same as the plain HTML form setup, just hosted on Squarespace.
- Make sure SourceTag is installed via **Settings > Advanced > Code Injection > Header** so it loads on every page.
- If you prefer not to build a custom HTML form, embed a third-party form builder (Tally, Fillout, JotForm, etc.) that supports hidden fields. See the relevant guide for that form builder.
- The Code Block approach bypasses Squarespace's built-in form handling. You will need an external form handler to receive submissions.
