Announcement

Collapse
No announcement yet.

Lead Capture: Web to Lead How To?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lead Capture: Web to Lead How To?

    Hi everyone,

    I am trying to make the Lead Capture work without success... following the info on this page but it's not working.



    Everything seems to be correctly setup but no lead are being sent to EspoCRM.

    Anyone with or had the same problem?

    Thanks,

    Nuno

  • #2
    Hi nunos,

    Please send the logs of your EspoCRM instance. They may contain more detailed information. Also, please specify which method (script) you use to send leads.​

    Comment


    • #3
      This is how it worked for me:

      Create the entry point -> /#Admin/leadCapture
      With the payload fields that are to be used for transfer.

      Then I created 2 files in the /public/contact folder.

      index.php
      PHP Code:
      <html lang="de">
      <
      head>
        <
      meta charset="UTF-8">
        <
      meta http-equiv="X-UA-Compatible" content="IE=edge">
        <
      meta name="viewport" content="width=device-width, initial-scale=1.0">
        <
      title>Titel</title>
        <!-- 
      CSS only -->
      <
      link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
      </
      head>
      <
      body>
       
      <
      main>
        <
      div class="container py-6">
        <
      center>Mit einem gekennzeichnet sind Pflichtfelder !</center>
         <
      form method="post" action="./send.php">
              <
      div class="p-5 mb-4 bg-light rounded-3">
                  <
      div class="mb-3">
                      <
      label for="emailAddress" class="form-label">E-Mail-Adresse*</label>
                      <
      input type="email" class="form-control" id="emailAddress" name="emailAddress" placeholder="name@beispiel.de">
                  </
      div>
                  <
      div class="mb-3">
                      <
      label for="firstName" class="form-label">Vorname*</label>
                      <
      input type="text" class="form-control" id="firstName" name="firstName" placeholder="Vorname">
                  </
      div>
                  <
      div class="mb-3">
                      <
      label for="lastName" class="form-label">Nachname*</label>
                      <
      input type="text" class="form-control" id="lastName" name="lastName" placeholder="Nachname">
                  </
      div>
                  <
      div class="mb-3">
                      <
      input type="hidden" class="form-control" id="assignedUserId" name="assignedUserId" value="6435bd1d21915631b">
                  </
      div>
                  <
      button type="submit" class="button btn-primary"Teilnehmen</button>
              </
      div>
          </
      form>
      </
      div>
      </
      main>
       
      </
      body>
      <!-- 
      JavaScript Bundle with Popper -->
      <
      script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>
      </
      html>​ 

      and send.php
      PHP Code:
      <?php
          
      if(empty($_POST['emailAddress']) || empty($_POST['firstName']) || empty($_POST['lastName'])) {
              echo 
      "Sie m&uuml;ssen alle erforderlichen Parameter angeben.";
        echo 
      "<br>";
        echo 
      "<br>";
        echo 
      "<button onclick='history.back()'>Zur&uuml;ck</button>";
              die;
          }
        
          
      $params = array(
              
      'emailAddress'      => $_POST['emailAddress'],
              
      'firstName'         => $_POST['firstName'],
              
      'lastName'          => $_POST['lastName'],
              
      'assignedUserId'    => $_POST['assignedUserId']
        
          );
          
      $curl curl_init();
          
      curl_setopt_array($curl, array(
            
      CURLOPT_URL           => "https://PATH-TO-CRM/api/v1/LeadCapture/CaptureID",
            
      CURLOPT_RETURNTRANSFER  => true,
            
      CURLOPT_ENCODING        => "",
            
      CURLOPT_MAXREDIRS     => 10,
            
      CURLOPT_TIMEOUT         => 30,
            
      CURLOPT_HTTP_VERSION      => CURL_HTTP_VERSION_1_1,
            
      CURLOPT_CUSTOMREQUEST   => "POST",
            
      CURLOPT_POSTFIELDS    => json_encode($params),
            
      CURLOPT_HTTPHEADER    => array(
              
      "Cache-Control: no-cache",
              
      "Content-Type: application/json"
            
      ),
          ));
       
          
      $response curl_exec($curl);
          
      $err    curl_error($curl);
       
          
      curl_close($curl);
          echo 
      "<center>Wir haben Ihre Anmeldung bekommen.<br><br>Bitte best&auml;tigen Sie dies in der E-Mail, die bei Ihnen gleich eingeht!</center>";  
      ?>

      IMPORTANT!
      The URL of the entry point must be specified for CURLOPT_URL.
      And the payload fields must be formatted slightly differently.
      You can see this under $params
      So do not copy 1:1 from the entry point.​

      Maybe this will help you a little​

      Comment


      • #4
        Hi ChrisSka83, thanks for the code, it seems to be ok but i think there is something missing or wrong on my side...

        I insert the URL provided on the Administration / Lead Capture in the CURLOPT_URL line but after checking my installation directory i can't find any api/v1/LeadCapture/... directory

        EspoCRM version 8.1

        *** Ok, it's working! there was a field marked as required on the Leads field list that was causing the problem. I have checked the logs and corrected the problem

        From another post on the forum it seems that the problem is there since version 7.2
        Last edited by nunos; 06-17-2024, 09:58 PM.

        Comment


        • ChrisSka83
          ChrisSka83 commented
          Editing a comment
          The /api/v1 folder is located in the public folder.

          Have you tested whether it works?
      Working...
      X