This demonstrates how to use S4S Cloud to identify a website visitor against an existing Lead. In this example we send out an email to Leads that already exist in Salesforce, but are not yet identified as S4S Cloud visitors.
The individual link may be something like:
https://example.com/clickthrough?leadid=00Q5g000007FikMAAS
If you don’t want to expose the Lead Id, use a custom external Id or some other unique field.
This example uses a Lead, but it could be any other standard or custom object. See Custom Identification Object for more details.
Create Mapping
Create an S4S Cloud Mapping in Salesforce.
Set the Form Identifier to
formId:<custom_id_here>
.Set the Salesforce Object to Lead.
Check the Update Only box.
Set the Identification Lookup to Lead.
Create a single field mapping.
Set Salesforce field to Lead ID.
Set Form field field to use the Data accessor
leadid
.Set Inbound Mapping to Identity key.
This mapping will identify a visitor any time it finds an existing Lead matched by the passed leadid value. It will never create a Lead.
Client JavaScript
Add script to the website to take the value from the URL parameter and submit it via S4S Cloud.
// 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? }); } }