Requirement
One of the our customer has their website built in WordPress and they are using WP form to capture the Lead/Contact-us requests.
WP form is good but not very friendly in syncing with CRM which is running in Salesforce.
We tried several options below that may give you idea if you are trying the same. Each approach has their own kind of pros and cons.
Since customer wanted to have an advance customization option and prevent duplicate Leads, we opted the 2nd approach.
Approaches
1️⃣ Using Salesforce Web-to-Lead Forms
Salesforce offers to generate HTML code that can be embedded directly in website – submitting the form will automatically creates Lead in the Salesforce. Here the steps to implement it: https://help.salesforce.com/s/articleView?id=sales.setting_up_web-to-lead.htm&type=5
NOTES
🔹 Built-in Salesforce feature to collect leads from WordPress forms.
🔹 Simply generate a Web-to-Lead form in Salesforce and embed it into your WordPress site.
🔹 Limitations: Basic functionality, no deep customization, and no bidirectional sync.
2️⃣ Using API Integration (Custom Development)
Develop webhook in Salesforce using Apex Rest. This is very powerful way customize and control the integration behaviour.
📌 QUICK STEPS
🔹 Develop Webhook in Salesforce by developing an Apex class. A sample is given below:
@RestResource(urlMapping='/LeadManagement/*')
global class LeadManagemet {
@HttpPost
global static String doPost(){
RestRequest req = RestContext.request;
RestResponse res = Restcontext.response;
String newRequest = req.requestBody.toString();
System.debug(newRequest+'____________');
Map params = req.params;
Map headers = req.headers;
Lead l = new Lead();
l.LastName = rawInput.data.Name != null?rawInput.data.Name:rawInput.data.Email;
l.LeadSource = 'Website';
l.phone = rawInput.data.Phone;
l.Company = String.isNotBlank(rawInput.data.Company);
try{
if(l.Email != null || l.Phone != null) insert l;
else createLog(rawInput, 'A junk Lead');
}catch(Exception e){
String body = e.getMessage()+'\r\n\r\n';
body += newRequest;
createLog(rawInput, body);
}
return l.Id;
}
public static void createLog(LeadWrappper rawInput, String logDescription){
}
}
🔹 Add this Apex Class in a Public site: https://help.salesforce.com/s/articleView?id=sf.os_grant_apex_class_access_to_a_community_profile.htm&language=en_US&type=5
🔹 Place this Webhook URL when Form is submitted. Webhook URL should be for given sample code: https://companydomain.my.site.com/<siteprefix>/services/apexrest/whatsappInboundMessageHandler
🔹 Best for: Businesses needing complex workflows or a two-way sync.
🔹 Powerful Customization: Gives more control to manage duplicate, create logs, notify stakeholders or create any other custom object records.
🔹 Limitations: Basic functionality, no deep customization, no bidirectional sync and need developer support.
3️⃣ Using Zapier (No-Code Automation)
🔹 Connect WordPress with Salesforce using Zapier without any development.
🔹 Example: When someone submits a WordPress form, Zapier automatically creates a Lead in Salesforce.
🔹 Limitations: Some advanced features require paid plans and less control over debugging, failed use cases and advance custmization
Need Help? We are here for you!
Don’t let valuable leads slip through the cracks! Whether you need simple lead capture, WooCommerce order sync, or custom API integration, we’ve got you covered.
Let’s optimize your workflow and supercharge your sales! 💡 Contact us today for a free consultation and take your business to the next level.