Adding Lead Source as a Hidden Field to Web-to-Lead Forms
Overview
The following article describes adding a hidden field to a web to lead capture form. The provided example will add "lead_source" as a hidden field with a value of "Campaign". To start, we will create a web to lead capture form through the Create Lead Form tool in the Campaigns module. To access this tool navigate to the Campaigns module and click "Create Lead Form" from the Campaigns tab. Please note that a campaign must be created before you can define a lead form.
Beginning with version 9.1.0, each user's license type (e.g., Sugar Serve) determines what functionality is available as described in the License Types Matrix documentation. Please note that the Campaigns module is not available for Sugar Serve users.
Choose the Lead Form Fields
The first step in the "Create Lead Form" tool shows three columns. The first column shows all the available fields for the Leads module. The second and third columns represent the two columns that SugarCRM will create when generating the web to lead capture form. Drag the fields you would like to have on the form from the available fields column into the two layout columns.
Define the Lead Form Properties
Click the "Next" button and choose the campaign you would like to associate to this lead form.
Define the Lead Form Layout
Click the "Generate Form" button and make any desired changes to the lead form using the TinyMCE WYSIWYG editor.
Add the Custom Field
Click the "Save Web To Lead Form" button and download the generated HTML file. Open the generated HTML file in a standard text editor such as Wordpad. Look for the following within the HTML file (spacing and newline characters have been added to improve readability):
<input id="campaign_id" name="campaign_id" type="hidden" value="71ac8f35-21ec-8a58-6539-4b01cabd595f" />
<input id="assigned_user_id" name="assigned_user_id" type="hidden" value="1" />
<input id="team_id" name="team_id" type="hidden" value="9abf4efb-0493-0c97-6bd6-4ae788ab1398" />
<input id="req_id" name="req_id" type="hidden" value="last_name;" />
Add the custom hidden field (lead_source in this case) and save the file:
<input id="campaign_id" name="campaign_id" type="hidden" value="71ac8f35-21ec-8a58-6539-4b01cabd595f" />
<input id="assigned_user_id" name="assigned_user_id" type="hidden" value="1" />
<input id="team_id" name="team_id" type="hidden" value="9abf4efb-0493-0c97-6bd6-4ae788ab1398" />
<input id="req_id" name="req_id" type="hidden" value="last_name;" />
<input id="lead_source" name="lead_source" type="hidden" value="Campaign" />
Provide the modified lead form to your web server administrator to be included on your company's website. Leads submitted using this form will now have the "Lead Source" field set to "Campaign". This can be used to filter incoming leads in workflows.