# Squarespace

Track UTM parameters on your Squarespace site and capture them in form submissions.

# Track UTMs in Squarespace Forms

Capture UTM parameters in your native Squarespace form submissions, even when the visitor lands on one page and submits the form on another.

### Before you start

- **Squarespace plan:** Code Injection is required, which is available on the **Core, Plus and Advanced** plans (and legacy Business/Commerce plans). It is **not** available on the Basic plan.
- **Your UTM Simple license key.**

### Step 1: Add hidden fields to your form

Edit your form block and add a **Hidden** field for each value you want to capture, named exactly:

- `utm_source`
- `utm_medium`
- `utm_campaign`
- `utm_term`
- `utm_content`

Squarespace renames these automatically (for example `utm_source` becomes `SQF_UTM_SOURCE`). That's expected, and the script in Step 2 accounts for it.

See [What can I track with UTMSimple?](https://docs.utmsimple.com/books/101-lets-start/page/what-can-i-track-with-utmsimple) for other values you can capture, such as `gclid` or `fbclid`.

### Step 2: Add the script

Go to **Settings → Developer Tools → Code Injection** (on older sites: **Settings → Advanced → Code Injection**) and paste the following into the **Header** box. Replace `<license key>` with your license key, then save.

```html
<script>
handl_custom_params=[];var handl_js=document.createElement("script");handl_js.setAttribute("src","https://track.utmsimple.com/utm.js?license=<license key>"),document.head.appendChild(handl_js),handl_js.onload=function(){
  var fields = ["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];
  var all = HandL.getAll(), url = new URL(window.location.href);
  fields.forEach(function (x) {
    if (all[x]) url.searchParams.set("SQF_" + x.toUpperCase(), all[x]);
  });
  history.replaceState(null, "", url.toString());
};
</script>

```

If you added extra hidden fields in Step 1 (for example `gclid`), add the same names to the `fields` list in the script.

### Step 3: Test

1. Open your site with test UTMs, for example `?utm_source=test&utm_medium=test&utm_campaign=test`.
2. Go to the page with your form (it can be a different page) and submit it.
3. Check the submission (in your form's storage, such as email or Google Sheets). The UTM values should appear in the hidden fields.

Need help? Reach out via chat or at support@utmsimple.com.