Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
// 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?
      });
  }
}
Info

The identification could come from somewhere else, for example a website with login authentication may have existing data stored about the user.