Skip to content
Generate Salesforce leads from form submissions.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Salesforce Leads plugin for Craft CMS 3.x

Generate Salesforce leads from form submissions.


This plugin requires Craft CMS 3.0.0 or later.


To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
  2. Then tell Composer to load the plugin:

     composer require lukeyouell/craft-salesforceleads
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Salesforce Leads.


Your form template can look something like this:

<form action="" method="post">

  {{ csrfInput() }}
  <input type="hidden" name="action" value="salesforce-leads/post">
  <input type="hidden" name="redirect" value="{{ 'contact/thanks'|hash }}">
  <input type="hidden" name="lead_source" value="{{ 'Web'|hash }}">
  <input type="hidden" name="Campaign_ID" value="{{ 'FA4316257629E'|hash }}">

  <input type="text" name="name">

  <label>Email Address</label>
  <input type="email" name="email">

  <textarea name="message"></textarea>

  <input type="submit" value="Submit">


Salesforce Parameters

The following Salesforce parameters are available but must contain hashed values to prevent tampering.

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.

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.

If you don't have a redirect hidden input, the plugin will respond with json.

Honeypot Captcha

To configure the Honeypot Captcha, go to Settings → Salesforce Leads and choose a param name that your honeypot field should have.

Then edit your form template(s), adding the honeypot field:

<input class="hidden" type="text" name="secretHoneypotParamName">

You can hide the field with CSS:

.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.

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.

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:

$('#myForm').submit(function(ev) {
  // Prevent the form from actually submitting

  // Send it to the server
    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.


   "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=\">\n</head>\n<script>if (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect(''); }  else if (window.location.replace){ window.location.replace('');} else {;window.location.href ='';} </script></html>\n",
   "payload": {
      "Campaign_ID": "FA4316257629E",
      "name": "Joe Bloggs",
      "email": "",
      "message": "Ut felis ipsum, pulvinar id elit in, tempor sagittis lacus. In lectus quam, consequat eu nibh vel, maximus lobortis sapien.",
      "oid": "936A151D88D8C",
      "retURL": "",
      "lead_source": "Web"


   "success": false,
   "reason": "Error message will be shown here",
   "payload": {
      "Campaign_ID": "FA4316257629E",
      "name": "Joe Bloggs",
      "email": "",
      "message": "Ut felis ipsum, pulvinar id elit in, tempor sagittis lacus. In lectus quam, consequat eu nibh vel, maximus lobortis sapien.",
      "oid": "936A151D88D8C",
      "retURL": "",
      "lead_source": "Web"

Salesforce Leads Roadmap

Some things to do, and ideas for potential features:

You can’t perform that action at this time.