Lots of Hatchbuck users ask us if it's possible to capture a lead source when a form is submitted. The term Lead Source means different things to different people, but for most use cases, the referring page's URL is enough. Luckily, this can be captured using a simple script and a bit of configuration.
The first thing to do is to create a custom field to house the data. In this example, I named the custom field "Lead Source".
Next, this custom field needs to exist on your form. Don't worry, we'll hide it from view later and automatically populate it with the correct data. Just create a form and use the Custom Textbox option to add a field and hook it up to your newly-created custom field.
If your custom field has an ID that differs from "input_5," you will need to change the above script to match it. What this script does is find an element with the ID of "input_5" and set the value property to the referral URL. That means if someone clicked a link on http://hatchbuck.com/partners that led them to your site, this now-hidden input field will be given a value of "http://hatchbuck.com/partners", which will be pushed into your custom field when the form is submitted.
Here's a look at the final code: