← All docs

Form Setup

Set up SourceTag with HTML Forms

If you’re using a custom HTML form (not a form builder plugin), add hidden input elements directly to your form’s HTML.

What you need

  • SourceTag installed on your site
  • An HTML <form> element

Add hidden inputs

Add <input type="hidden"> elements inside your form tag. One for each SourceTag field.

<form action="/submit" method="POST">
  <!-- Your visible fields -->
  <input type="text" name="name" placeholder="Your name" required>
  <input type="email" name="email" placeholder="Your email" required>
  <textarea name="message" placeholder="Your message"></textarea>

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

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

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

See Captured Fields for the full list of available fields.

Leave the value attribute empty. SourceTag’s script finds these fields by their name attribute and fills in the values automatically.

Test

Visit the page with UTM parameters:

?utm_source=test&utm_medium=cpc&utm_campaign=html-test

Open your browser’s developer tools (F12) and inspect the hidden fields before submitting. You should see values populated by SourceTag.

Submit the form and check your server/email for the attribution data.

Tips

  • The name attribute must match exactly. Copy field names from your SourceTag dashboard.
  • Hidden inputs are not visible to visitors.
  • This works with any server-side handler (PHP, Node, Python, etc.) that processes POST form data.
  • For AJAX forms, make sure you serialise all form fields including the hidden ones.

Doesn't answer your question or need more help? Get in touch.