Skip to main content

Track UTMs in Squarespace Forms

Prerequisites

  • A Business plan or higher on Squarespace. Code Injection (used in Step 1) is not available on the Personal plan.
  • Your UTM Simple license key.

Step 1: Add the generic script

Go to Settings → Advanced → Code Injection, and add the following script to the Header box:

<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);
</script>

Replace <license key> with your own UTM Simple license key, then save.

Step 2: Add hidden fields to your form

Squarespace forms don't have a native "hidden field" option, so this is added per form block via the form's Custom HTML / embed option, or by using a Markdown/Code block placed right next to the form containing:

<div style="display:none;">
  <input type="text" name="utm_source" id="utm_source">
  <input type="text" name="utm_medium" id="utm_medium">
  <input type="text" name="utm_campaign" id="utm_campaign">
</div>

The field name attributes must match our naming convention exactly — see What can I track with UTMSimple? for the full list of fields you can capture.

Step 3: Test it

Open your page with some UTM parameters in the URL (e.g. ?utm_source=test&utm_medium=test&utm_campaign=test), submit the form, and check that the submission includes the UTM values.

Note: Squarespace native forms submit via AJAX without a page reload, so the hidden fields need to already be filled in before the visitor clicks submit — the script fills them as soon as it loads, so this works as long as the script and fields are both present on the page.