lukeyouell/craft-salesforceleads

此包已弃用且不再维护。未建议替代包。

从表单提交中生成 Salesforce 领先。

1.2.1 2018-12-06 16:33 UTC

This package is not auto-updated.

Last update: 2019-11-16 17:15:05 UTC


README

icon

Craft CMS 3.x 的 Salesforce 领先插件

从表单提交中生成 Salesforce 领先。

要求

此插件需要 Craft CMS 3.0.0 或更高版本。

安装

要安装插件,请按照以下说明操作。

  1. 打开您的终端并转到您的 Craft 项目

     cd /path/to/project
    
  2. 然后告诉 Composer 加载插件

     composer require lukeyouell/craft-salesforceleads
    
  3. 在控制面板中,转到设置→插件,然后点击 Salesforce 领先的“安装”按钮。

用法

您的表单模板可以看起来像这样

<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 }}">

  <label>Name</label>
  <input type="text" name="name">

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

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

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

</form>

Salesforce 参数

以下 Salesforce 参数可用 但必须包含哈希值 以防止篡改。

名称 必需 默认值
oid 设置/配置中设置的值
retURL 当前站点基本网址
lead_source
Campaign_ID

上述字段名是 区分大小写的

提交后重定向

如果您有一个 redirect 隐藏输入,用户将在成功提交后重定向到它。同样,这必须是一个哈希值。

如果您 没有 redirect 隐藏输入,则插件将返回 JSON。

Honeypot Captcha

要配置 Honeypot Captcha,请转到设置→Salesforce 领先,并选择 honeypot 字段应具有的参数名称。

然后编辑您的表单模板,添加 honeypot 字段

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

您可以使用 CSS 隐藏字段

.hidden {
  display: none;
}

电子邮件验证

如果您已安装 Email Validator 插件,则可以验证用于提交 Salesforce 领先的电子邮件地址。

要配置 Email Validator,请转到设置→Salesforce 领先,选择您的电子邮件字段应具有的参数名称,并切换您希望执行的验证过程。

Ajax 提交

如果您愿意,可以可选地通过 Ajax 发送联系表单提交。只需向您的网站发送带有所有常规数据的 POST 请求即可

$('#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.');
      }
    }
  });
});

处理响应

我们正在使用 HTTP POST 请求向 Salesforce 提交,因此我们没有收到任何有意义的反馈。请求只有在请求本身有问题时才会出错。

成功

{
   "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"
   }
}

不成功

{
   "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 领英路线图

一些要完成的事项,以及潜在功能的想法