Over the years I have worked with many different API programs, especially in the automotive field. Edmunds, eLead, DataOne, Fuel – you name it. Since not all of them feature great documentation, I figured I would put together some of the things I’ve picked up over the years. In this case, we’re exploring how to convert data submitted via a basic online form to 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.

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. Please note that my sample form doesn’t have any data validation or error checking, however these are all things you should have in your form.

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