Installation

Install SourceTag on Any HTML Site

If your site isn’t built on WordPress, Webflow, Squarespace, or another platform with a dedicated guide, you can install SourceTag by adding a single script tag to your HTML.

This works for static HTML sites, custom-built sites, PHP sites, Node.js apps, and anything else that serves HTML pages.

Step 1: Copy your script tag

In your SourceTag dashboard, go to your site’s detail page and copy the script tag. It looks like this:

<script src="https://cdn.sourcetag.io/scripts/YOUR_SITE_ID/st.js" async></script>

Replace YOUR_SITE_ID with your actual Site ID from the dashboard.

Step 2: Paste the script before the closing head tag

Open your site’s HTML (or the template/layout file that generates every page) and paste the script tag just before the closing </head> tag.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Your Site</title>
  <!-- other head elements -->

  <!-- SourceTag -->
  <script src="https://cdn.sourcetag.io/scripts/YOUR_SITE_ID/st.js" async></script>
</head>
<body>
  <!-- page content -->
</body>
</html>

The async attribute means the script loads without blocking the rest of the page. It should be present on every page of your site, not just the page with the form.

Why every page? SourceTag needs to read the URL parameters and referrer on whichever page the visitor lands on. If the script only runs on your contact page, you’ll miss attribution data from visitors who land on other pages first.

Step 3: Add hidden fields to your forms

SourceTag automatically detects <form> elements on the page and injects hidden fields. However, for the data to be included in the form submission, the hidden fields need to exist in the form before submission.

If SourceTag’s auto-injection is working (which it does for standard HTML forms), you don’t need to add the hidden fields manually. The script handles it.

If you prefer to add them manually (for example, if your form uses a non-standard setup), add hidden input elements inside your form:

<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 core hidden fields -->
  <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">

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

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

See Add Hidden Fields to HTML Forms for the full list of available fields including optional extended fields.

Step 4: Test with UTM parameters

Visit your site with test UTM parameters appended to the URL:

https://yoursite.com/?utm_source=test&utm_medium=cpc&utm_campaign=html-install-test

Open your browser’s developer tools (F12 or Cmd+Option+I on Mac) and check the following:

  1. Script loaded: In the Network panel, filter for st.js. It should show a 200 status.
  2. Cookie set: In Application > Cookies, look for _sourcetag on your domain.
  3. Hidden fields populated: In the Elements panel, find your form and expand it. You should see hidden inputs with values like st_fc_channel = Paid Search.

Submit the form and check wherever submissions are received (email notification, server logs, CRM) to confirm the attribution data came through.

See Testing SourceTag for a detailed testing walkthrough.

Common setups

Static site generators (Hugo, Jekyll, Eleventy, Astro)

Add the script tag to your base layout template. In most static site generators, this is a file like base.html, _default.html, or Layout.astro that wraps every page.

PHP sites

Add the script tag to your header include file (commonly header.php or includes/head.php).

Server-rendered apps (Express, Django, Rails, Laravel)

Add the script tag to your main layout template that renders the <head> section.

Troubleshooting

Script returns 404: Make sure you have clicked Generate Script in the SourceTag dashboard. The script file is only created after you generate it.

Cookie not being set: Check the browser console for errors. If another script on the page is throwing an error before SourceTag runs, it could interfere (though this is uncommon).

Hidden fields not appearing: Verify the form uses a standard <form> HTML element. If it doesn’t, you can set a custom form selector in Advanced Mode on the Fields page in the dashboard.