This demonstrates how to use Send2CRM 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 Send2CRM 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 a Send2CRM 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 Send2CRM.
// 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 Send2CRM, using the formId that matches the mapping. send2crm.forms.send('lead_identifier', formData) .then((data) => { // Successful response. Send2CRM will apply the visitor id automatically. // Show a success message, or do something else. }) .catch((error) => { // Failed :-( // Perhaps surface an error? }); } }
The identification could come from somewhere else, for example a website with login authentication may have existing data stored about the user.