What are Pre-fill parameters and how to use them?
Prefill parameters are used to populate question values in the online form. Population is performed when the online form is displayed in the browser, or rendered on the web page in the case of an embedded online form.
List of all Pre-fill parameters can be accessed in Online form Editor via option Pre-fill Parameters
Question - Select a question to display all its pre-fill parameters
Pre-fill parameter Name - Name of the Question pre-fill parameter that is used in the link or embedded form
Field Options/Field Option ID - Visible only for questions type of Dropdown, Radio Button, Multi-select checkbox. In the first column the visible option is displayed and in the second column Field Option ID is displayed. Field Option ID must be always used when doing pre-fill of online form via Javascript
Personalization - Visible only when the question includes pre-fill marker in Question Title or description.
Example of Personalization (pre-fill marker in Question Description):
Example of URL with pre-fill parameters
https://example.com/view-form?
cf_first_name=John&
cf_last_name=Doe&
cf_tshirt_size_contact_id=01889b11-cc4e-fff1-5bad-4d3d31937c93
Example of Embedded code with pre-fill parameters
<ppl-online-form-embed id="bbe744baca1f36c9d55b"
data-cf_first_name="John"
data-cf_last_name="Doe"
data-cf_tshirt_size_contact_id="">
</ppl-online-form-embed>
Embedding Online form via Javascript and data pre-fill
Follow the Steps in Get Embedded Code window to embed the Online form on your website.
Show Pre-fill -> This option helps to generate the embedded code with specific pre-fill parameters that can be filled later programmatically
Pre-fill on Form initialization
Pre-fill values of online form can be populated when the online form is initialized in your Website, by providing custom values to every data attribute.
Code example (pre-filling on form initialisation):
//Online Form SDK
<script src="https://static-webapps.pipelinersales.com/online-form/production/latest/online-form.js" defer></script>
//Online form was initialized on website with ID=bbe744baca1f36c9d55b
<ppl-online-form-embed id="bbe744baca1f36c9d55b" >
</ppl-online-form-embed>
//Dropdown, Radio Button, Multi-select checkbox requires Field Option ID for correct population
<ppl-online-form-embed id="bbe744baca1f36c9d55b"
data-cf_satisfaction_rating="custom_value"
data-cf_first_name="custom_value"
data-cf_last_name="custom_value"
data-dropdown="01889b11-cc4e-fff1-5bad-4d3d31937c93"
data-contact.2853409f-dc70-002c-e9ba-c91f4649cb7b="custom_value"
data-record-id="">
</ppl-online-form-embed>
*custom_value - The values are always validated, so if the Online form question expects a value formatted as an email, it will throw an error in the online form if the value isn't formatted correctly.
Pre-filling and working with values after Form initialization
Pipeliner Online Form SDK, includes 'setInputData' function to update values in the online form after the online form has been initialised. This function can also modify data that aren't visible on the form (for example the question is set as Invisible in Online form Editor)
Function setInputData:
setInputData(pre_fill_parameter_field_name, new_value)
pre_fill_parameter_field_name - This represents field name, take a look at section What are Pre-fill parameters and how to use them?
new_value - The custom value. New value is always validated, so if the question expects a value formatted as an email, it will throw an validation error in the online form on the form submit
For Dropdown, Radio Button, Multi-select checkbox, you must provide Field Option ID to do pre-fill correctly (see section What are Pre-fill parameters and how to use them)
Code example (pre-filling after form initialisation):
//Online Form SDK
<script src="https://static-webapps.pipelinersales.com/online-form/staging/latest/online-form.js" defer></script>
//Online form was initialized on website with ID=bbe744baca1f36c9d55b
<ppl-online-form-embed id="bbe744baca1f36c9d55b" >
</ppl-online-form-embed>
//Function SetInput Data is Called on the initialized online form
<script>
document.addEventListener('DOMContentLoaded', (event) => {
document.getElementById('bbe744baca1f36c9d55').setInputData('cf_first_name', "John");
});
</script>
Use Case: Record identification via Record ID
To ensure that the online form is always linked to the correct record when submitted, embedded form can be initialized with data-record-id attribute.
Pipeliner online forms have two ways to identify the record that submitted the form. Record ID is the primary method to identify the record, or secondary method by field matching, which can be configured in the online form editor.
The most common use case would be to send an email campaign with a record id in the link and initialise the embedded form with the record id parsed from the URL.
(In this example Account ID is sent in Email Campaign in URL parameter record_id)
Then, when someone clicks on the link in the email, they are redirected to the website and you can initialise the online form with parameter data-record-id
Code example (intialization with record id)
<ppl-online-form-embed id="bbe744baca1f36c9d55b"
data-record-id="record_id_value">
</ppl-online-form-embed>
*record_id_value is ID of record retrieved from the URL opened in your browser
Use Case: Populating data in Embedded Online form from URL parameters
The standard embedded form use case is to render an embedded form and automatically pre-populate data from the URL.
For this use case to be successful, a valid URL must be provided. As a developer, you have two options for populating data into the online form. Either on form initialisation or after form initialisation using the setInputData function.
Example of URL where the embedded form should be rendered:
https://example.com/view-form?
cf_first_name=John&
cf_last_name=Doe&
cf_tshirt_size_contact_id=01889b11-cc4e-fff1-5bad-4d3d31937c93
Populate data on form initialization
//Online Form SDK
<script src="https://static-webapps.pipelinersales.com/online-form/staging/latest/online-form.js" defer></script>
//Dropdown, Radio Button, Multi-select checkbox requires Pre-fill Option ID for population
<ppl-online-form-embed id="bbe744baca1f36c9d55b"
data-cf_first_name="query_parameter_value_first_name"
data-cf_last_name="query_parameter_value_last_name"
data-dropdown="01889b11-cc4e-fff1-5bad-4d3d31937c93"
data-contact.2853409f-dc70-002c-e9ba-c91f4649cb7b="query_parameter_value"
data-record-id="query_parameter_value">
</ppl-online-form-embed>
*query_parameter_value are values retrieved from the URL opened in your browser
Populate data after form initialization
//Online Form SDK
<script src="https://static-webapps.pipelinersales.com/online-form/staging/latest/online-form.js" defer></script>
//Online form was added into the HTML, with ID=bbe744baca1f36c9d55b
<ppl-online-form-embed id="bbe744baca1f36c9d55b" >
</ppl-online-form-embed>
<script>
document.addEventListener('DOMContentLoaded', (event) => {
const params = new URLSearchParams(window.location.search);
document.getElementById('bbe744baca1f36c9d55b').setInputData('cf_first_name', params.get('cf_first_name'));
document.getElementById('bbe744baca1f36c9d55b').setInputData('cf_last_namee', params.get('cf_first_name'));
document.getElementById('bbe744baca1f36c9d55b').setInputData('01889b11-cc4e-fff1-5bad-4d3d31937c93', params.get('cf_tshirt_size_contact_id'));
});
</script>