Can I pass UTM parameters through my form?

In Cognito Forms, you can prefill form fields from other forms or from other pre-defined content. Prefilling form fields makes it easy to track UTM parameters alongside user entries.

This example script will fill forms on your site with fields named “UTM Source”, “UTM Medium”, etc. with the appropriate UTM parameters from your site’s Url.

<script>
var urlParams = new URLSearchParams(window.location.search);

var utm_params = {
  "UTMSource": urlParams.get('utm_source'),
  "UTMMedium": urlParams.get('utm_medium'),
  "UTMCampaign": urlParams.get('utm_campaign'),
  "UTMTerm": urlParams.get('utm_term'),
  "UTMContent": urlParams.get('utm_content'),
};

Cognito.prefill(utm_params);
</script>

To learn more about prefilling forms, jump to our tutorial.

If you need further assistance setting up your prefill code, please get in touch with our support team.