Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

How to: Add a Lead Opt-in Web Form

Adrian Singer, 10-28-2009
A lead opt-in web form is a short form, asking the user to provide name, emailaddress, phone and/or other optional fields, for the purpose of signing up for a program, or receiving more information about your offering.



Unlike other shopping carts, the SPI cart doesn't limit you to a single form style or any specific fields.

You can create whatever html form you like, using any design and combination of fields (text, radio button, checkboxes, textareas) as needed.

The only requirement is to have at least the emailaddress field, whenever saving a new lead to the database.

Step 1 - Design your opt-in form

Use your favorite HTML editor to design your lead opt-in form.

For simplicity, use 'name' as the fieldname for the user's name (or 'first_name' + 'last_name'), use 'emailaddress' as the fieldname for the user's email address and use 'phone' as the fieldname for the user's phone number.

Here's a typical lead opt-in form with the basic name,emailaddress,phone fields as well as a few additional custom ones:


<form action="#" method="post">
<
p>First Name: <input type="text" name="first_name" /></p>
<
p>Last Name: <input type="text" name="last_name" /></p>
<
p>Best Email: <input type="text" name="email" /></p>
<
p>Best Phone Number: <input type="text" name="phone" /></p>
<
p>Have you traded individual stocks?
Yes <input name="traded_indi_stock" type="radio" value="Yes" /> No <input name="traded_indi_stock" type="radio" value="No" />
</
p>
<
p>Have you traded options
Yes
<input name="traded_option" type="radio" value="Yes" /> No <input name="traded_option" type="radio" value="No" />
</
p>
<
input type="submit" name="submit" value="Submit" />
</
form>

Step 2 - Add custom fields to Leads table

Since we're using a few custom fields in this example (traded_indi_stock, traded_option), we need to add those fields to the 'leads' table.

Connect to your SPI database using PHPMyAdmin, locate the leads table and add the two new fields. You only have to do this once every time you're adding a new custom field to a table.



Make sure you're adding the custom fields to the 'leads' table and pay close attention to the fieldnames. The fieldnames you choose are going to have to match the fieldnames you pass to the do_addlead() function.

Step 3 - Save the lead to the database

Now that we have the custom leads in the 'leads' table, saving the lead to the database is the easy part.

The code below renders the opt-in form, saves the lead to the database and redirects the user to a thankyou.html page.


<?php
// Include SPICart shopping cart API
require_once("spicart.php");

// If this is a lead submit
if (!empty($_POST['email']))
{
// Save lead to the database
$input = array();
$input['first_name'] = $_POST['first_name'];
$input['last_name'] = $_POST['last_name'];
$input['emailaddress'] = $_POST['emailaddres'];
$input['phone'] = $_POST['phone'];
$input['traded_indi_stock'] = $_POST['traded_indi_stock'];
$input['traded_option'] = $_POST['traded_option'];
do_addlead($input, &$output, &$result_str);
Header("Location: thankyou.html");
die;
}
?>
<form action="#" method="post">
<p>First Name: <input type="text" name="first_name" /></p>
<p>Last Name: <input type="text" name="last_name" /></p>
<p>Best Email: <input type="text" name="emailaddress" /></p>
<p>Best Phone Number: <input type="text" name="phone" /></p>
<p>Have you traded individual stocks?
Yes <input name="traded_indi_stock" type="radio" value="Yes" /> No <input name="traded_indi_stock" type="radio" value="No" />
</p>
<p>Have you traded options
Yes <input name="traded_option" type="radio" value="Yes" /> No <input name="traded_option" type="radio" value="No" />
</p>
<input type="submit" name="submit" value="Submit" />
</form>
<?php
// Track visit to this page
track();
?>

Note about Affiliate Tracking

Often times, affiliates will be sending their traffic to your lead opt-in forms. You're going to want to know which affiliate generated which leads.

Luckily the system takes care of this automatically.

One of the fields in the 'leads' table is aff_id. This is the ID of the referring affiliate and serves as the glue, associating leads with the affiliates who referred them.

When a user clicks on an affiliate link to visit the opt-in form on your website, they typically follow a link that looks like this:

www.YourDomain.com/?aff_id=1234

Where 1234 is the affiliate ID.

As soon as the user lands on the lead opt-in form, the spicart.php include at the top of your file, identifies the aff_id url-parameter and saves it in a cookie on the end-user's machine.

Later when you call do_addlead(), this method picks up the aff_id from the end-user's cookie and passes it along, so that when the lead is added, the referring aff_id is saved as well.
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions