 , (*1)
, (*1)
Salesforce Leads plugin for Craft CMS 3.x
Generate Salesforce leads from form submissions., (*2)
Requirements
This plugin requires Craft CMS 3.0.0 or later., (*3)
Installation
To install the plugin, follow these instructions., (*4)
- 
Open your terminal and go to your Craft project:, (*5) cd /path/to/project 
- 
Then tell Composer to load the plugin:, (*6) composer require lukeyouell/craft-salesforceleads 
- 
In the Control Panel, go to Settings → Plugins and click the “Install” button for Salesforce Leads., (*7) 
Usage
Your form template can look something like this:, (*8)
Salesforce Parameters
The following Salesforce parameters are available but must contain hashed values to prevent tampering., (*9)
| Name | Required | Default Value | 
| oid | No | Value set in settings/config | 
| retURL | No | Current site base url | 
| lead_source | No | Null | 
| Campaign_ID | No | Null | 
The above field names are case-sensitive., (*10)
Redirecting After Submit
If you have a redirect hidden input, the user will be redirected to it upon successful submission. Again, this must be a hashed value., (*11)
If you don't have a redirect hidden input, the plugin will respond with json., (*12)
Honeypot Captcha
To configure the Honeypot Captcha, go to Settings → Salesforce Leads and choose a param name that your honeypot field should have., (*13)
Then edit your form template(s), adding the honeypot field:, (*14)
<input class="hidden" type="text" name="secretHoneypotParamName">
You can hide the field with CSS:, (*15)
.hidden {
  display: none;
}
Email Validation
If you have the Email Validator plugin installed you can validate the email addresses being used to submit Salesforce leads., (*16)
To configure the Email Validator, go to Settings → Salesforce Leads, choose a param name that your email field should have and toggle the validation processes you wish to enforce., (*17)
Ajax Submissions
You can optionally post contact form submissions over Ajax if you’d like. Just send a POST request to your site with all of the same data that would normally be sent:, (*18)
$('#myForm').submit(function(ev) {
  // Prevent the form from actually submitting
  ev.preventDefault();
  // Send it to the server
  $.post({
    url: '/',
    dataType: 'json',
    data: $(this).serialize(),
    success: function(response) {
      if (response.success) {
        alert('Successful submission.');
      } else {
        alert('An error occurred. Please try again.');
      }
    }
  });
});
Handling Responses
We are posting to Salesforce using a HTTP POST request, so we don't receive any meaningful feedback. The request will only error if there is a problem with the request itself., (*19)
Successful
{
   "success": true,
   "statusCode": 200,
   "reason": "OK",
   "body": "\r\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n<html>\n<head>\n<meta HTTP-EQUIV=\"PRAGMA\" CONTENT=\"NO-CACHE\">\n<meta http-equiv=\"Refresh\" content=\"0; URL=https://www.yoursite.com/\">\n</head>\n<script>if (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('https://www.yoursite.com/'); }  else if (window.location.replace){ window.location.replace('https://www.yoursite.com/');} else {;window.location.href ='https://www.yoursite.com/';} </script></html>\n",
   "payload": {
      "Campaign_ID": "FA4316257629E",
      "name": "Joe Bloggs",
      "email": "joe.bloggs@email.com",
      "message": "Ut felis ipsum, pulvinar id elit in, tempor sagittis lacus. In lectus quam, consequat eu nibh vel, maximus lobortis sapien.",
      "oid": "936A151D88D8C",
      "retURL": "https://www.yoursite.com",
      "lead_source": "Web"
   }
}
Unsuccessfull
{
   "success": false,
   "reason": "Error message will be shown here",
   "payload": {
      "Campaign_ID": "FA4316257629E",
      "name": "Joe Bloggs",
      "email": "joe.bloggs@email.com",
      "message": "Ut felis ipsum, pulvinar id elit in, tempor sagittis lacus. In lectus quam, consequat eu nibh vel, maximus lobortis sapien.",
      "oid": "936A151D88D8C",
      "retURL": "https://www.yoursite.com",
      "lead_source": "Web"
   }
}
Salesforce Leads Roadmap
Some things to do, and ideas for potential features:, (*20)