// Do not act until the document is loaded.
window.addEventListener('load', (evt) => {
// Get the leadid parameter from the URL.
let urlParams = new URLSearchParams(window.local.search);
if (urlParams.has('leadid')) {
// Create object with field values - this should match the data accessor in the mapping.
let formData = { leadid: urlParams.get('leadid') };
// Send the form data via S4S Cloud, using the formId that matches the mapping.
S4SCloud.forms.send('lead_identifier', formData)
.then((data) => {
// Successful response. S4S Cloud will apply the visitor id automatically.
// Show a success message, or do something else.
})
.catch((error) => {
// Failed :-(
// Perhaps surface an error?
});
}
} |