Home > Tutorials > PHP Tutorials > Auto Generation of New Prospects in eLEAD CRM via ADF XML Emails

Auto Generation of New Prospects in eLEAD CRM via ADF XML Emails

Earlier in the week I had to do a rather niche task with a local leasing company I work with. They have switched over to eLEAD CRM and as such wanted to convert all of their online lease quote request forms to submit to their new eLEAD CRM. This way requests from existing customers will automatically be assigned and recorded to their customer account; and new quote requests will automatically generate new prospects within the CRM system. Having done several of these implementations in the past I figured I would outline what it takes to take this on yourself.

For starters let’s define what ADF XML is. ADF stands forĀ Auto Data Format which is the standard data delivery format for the automotive industry. Using ADF XML leads and customer details can easily be imported/exported across a wide array of platforms and dealerships. You can read the v1.0 of the ADF XML specifications here.

Now that we got the pleasantries out of the way – let’s start doing some coding. We’ll need a form first which will collect the information from our customer. For the purposes of this tutorial I’ll use the following simple form, however any pre-existing form you have will work just fine.

<form action="submitLead.php" method="POST" >
  First Name: <input type="text" name="fname"><br />
  Last Name: <input type="text" name="lname"><br />
  Phone: <input type="text" name="phone"><br />
  Email: <input type="text" name="email"><br />
  Desired Make: <input type="text" name="make"><br />
  Desired Model: <input type="text" name="model"><br />
  Comments: <input type="text" name="comments"><br />
  <input type="submit">
</form>

Now let’s head over to our submission script, in this case I have it in a separate file called submitLead.php. I won’t go into detail here on the basics of sending out an email with PHP as I have described that in a separate tutorial here – alas the basis of this entire process is based on sending out an email via PHP so if you feel you need a refresher head back to that tutorial. Otherwise let’s collect our form variables and start building our ADF XML email.

In addition to gathering the usual POST information from our form we’re also going to need to create a few additional variables for our request id number, the eLEAD email address assigned to us, and the date of the request. For this tutorial I simply generated a number for each lead lead using mt_rand.

<?php
// Start ADFXML Email Options
    $fname = $_POST['fname'];
    $lname = $_POST['lname'];
    $adfphone = $_POST['phone'];
    $adfemail = $_POST['email'];
    $commentsbox = $_POST['comments'];
    $currentdate = date();
    $adfmake = $_POST['make'];
    $adfmodel = $_POST['model'];
$eleadtrackemail = "[email protected]";
$six_digit_random_number = mt_rand(100000, 999999);
$adfsubject = "Lease Quote Request:".$adfmake." ".$adfmodel."";

Now that we have all the variables we will need setup, let’s build the body of our email. The part that will actually be made up of ADF XML. All of the ADF XML emails you will be building will all always start off with the following lines:

<?xml version="1.0" encoding="UTF-8"?>
<?ADF VERSION="1.0"?>

Following that you will always need to specify a unique lead ID and a source for the lead. In my example I am listing my source as Lease Request Page.

$adfxml = '<?xml version="1.0" encoding="UTF-8"?>
  <?ADF VERSION="1.0"?>
    <adf>
      <prospect>
<id sequence="1" source="Lease Request Page">'.$six_digit_random_number.'</id>
        <requestdate>'.$currentdate.'</requestdate>
        <vehicle interest="lease" status="new">
          <make>'.$adfmake.'</make>
          <model>'.$adfmodel.'</model>
        </vehicle>
        <customer>
          <contact>
          <name part="first" type="individual">'.$fname.'</name>
          <name part="last" type="individual">'.$lname.'</name>
          <email>'.$adfemail.'</email>
          <phone type="home">'.$adfphone.'</phone>
        </contact>
        <comments>'.$commentsbox.'</comments>
      </customer>
      <vendor>
<vendorname>My Awesome Dealership</vendorname>
      </vendor>
    </prospect>
</adf>';
$sendelead = mail($eleadtrackemail, $adfsubject, $adfxml);

Now take note that this is a very basic implementation and ADF XML offers alot more elements and has the ability to transmit additional information such as vehicle VIN numbers, odometer readings, and much more. A full write-up of of all the different elements is available here. At the end you’re submit script will resemble the following:

<?php
    $fname = $_POST['fname'];
    $lname = $_POST['lname'];
    $adfphone = $_POST['phone'];
    $adfemail = $_POST['email'];
    $commentsbox = $_POST['comments'];
    $currentdate = date();
    $adfmake = $_POST['make'];
    $adfmodel = $_POST['model'];
    $eleadtrackemail = "[email protected]";
    $six_digit_random_number = mt_rand(100000, 999999);
    $adfsubject = "Lease Quote Request:".$adfmake." ".$adfmodel."";

$adfxml = '<?xml version="1.0" encoding="UTF-8"?>
  <?ADF VERSION="1.0"?>
    <adf>
      <prospect>
<id sequence="1" source="Lease Request Page">'.$six_digit_random_number.'</id>
        <requestdate>'.$currentdate.'</requestdate>
        <vehicle interest="lease" status="new">
          <make>'.$adfmake.'</make>
          <model>'.$adfmodel.'</model>
        </vehicle>
        <customer>
          <contact>
          <name part="first" type="individual">'.$fname.'</name>
          <name part="last" type="individual">'.$lname.'</name>
          <email>'.$adfemail.'</email>
          <phone type="home">'.$adfphone.'</phone>
        </contact>
        <comments>'.$commentsbox.'</comments>
      </customer>
      <vendor>
<vendorname>My Awesome Dealership</vendorname>
      </vendor>
    </prospect>
</adf>';
$sendelead = mail($eleadtrackemail, $adfsubject, $adfxml);

Now once you’re form submission has processed simply head on over and login to eLEAD CRM and you’ll see your new lease request within your mail inbox with a new prospect automatically assigned to the request.

elead crm

About Michael Boguslavskiy

Michael Boguslavskiy is a full-stack developer & online presence consultant based out of New York City. He's been offering freelance marketing & development services for over a decade. He currently manages Rapid Purple - and online webmaster resources center; and Media Explode - a full service marketing agency.

Check Also

5 Must Have WordPress Optimization Plugins For A Fast Loading Website

Having a fast loading website is essential these days. First off, users are impatient. If ...

Like every other website, this site uses cookies to analyze our traffic. Cookies may also be utilized by our advertisers and partners. By using this website you agree to the use of said cookies. More Information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings, continuing to navigate past this message, or you click "Accept" below then you are consenting to the use of cookies on the Rapid Purple website.

Close