Hatchbuck has an API, which can be used for more advanced integrations, like AJAX posts or retrieving information about a contact before updating it. The main problem with this is the cookie required for webpage tracking is not generated since the contact is never directed to our application. 


Luckily, there is a solution that can meet you halfway. By using a script to perform an HTTP POST to our form submission script, you will lose the flexibility to retrieve information about a contact and act accordingly since it's a unidirectional communication, but you will still be able to send the captured data to another application, store it in an internal database, and the tracking cookie will be generated as with a normal form submission.


This example uses PHP/cURL, but the logic is similar for other languages and frameworks. 


1) Create a form within Hatchbuck. 

You will also want to make any configuration changes you desire, like setting a thank you page, adding actions, and handling duplicate submissions.


2) Put the form on your page. 

Make sure if you code the form yourself from scratch, you include the hidden fields (like simple_spc, enable303Redirect, formID, etc.) and the pre-filled values**. Also take note of the original input names, as these will be required when you perform the POST to Hatchbuck.


** With one exception: set "enable303Redirect" to a value of 0. See below.



3) Write your script.

This is the part you have to handle on your own. The first thing you need to do is capture the POSTed data in variables, then push that data into another application, insert it into a local database, or manipulate it in whatever way you'd like. 




4) Push the data to Hatchbuck with cURL.

You want to make sure you push the data into Hatchbuck last. This is because you're giving up control of the browser at this point. This will redirect the browser to app.hatchbuck.com, and the contact will eventually end up on the thank you page as specified in Hatchbuck. Be sure to set the hash keys as the input names you saw on the original Hatchbuck form, as well as including those hidden fields. If you do not include some of the hidden field values, your POST may be rejected. 




At this point, the script is simply pushing the same values from the original form submission to Hatchbuck exactly like a "regular" form submission. Anything after this point in the code will not work, so make sure you put this section at the bottom of your script.

So here is a complete working example that will accept a form submission, push the data into a local database, and then send the POST to Hatchbuck.

INDEX.HTML 
<html>

<form accept-charset="utf-8" action="submit.php" id="form_62232815910" method="post" name="form_62232815910">
    <input name="formID" type="hidden" value="62232815910">
    <input name="enableServerValidation" type="hidden" value="1">
    <input name="enable303Redirect" type="hidden" value="0"> 
    <br />
    <label>First Name</label> 
    <input name="q1_firstName1" type="text"> 
    <br />
    <label>Last Name</label> 
    <input name="q3_lastName3" type="text"> 
    <br />
    <label>E-mail<span>*</span></label> 
    <input name="q4_email" type="email">
    <br />
    <button type="submit">Submit</button>

    <input name="website" type="hidden" value="">
    <input name="simple_spc" type="hidden" value="62232815910-62232815910">
</form>

</html>

 

SUBMIT.PHP

<?php

# PULLING VALUES FROM FORM SUBMISSION
$formid = $_POST["formID"];
$server_validation = $_POST["enableServerValidation"];
$enable_303 = $_POST["enable303Redirect"];
$firstname = $_POST["q1_firstName1"];
$lastname = $_POST["q3_lastName3"];
$email = $_POST["q4_email"];
$antispam = $_POST["website"];
$simple_spc = $_POST["simple_spc"];

# POSTING DATA TO INTERNAL DATABASE VIA PDO 
#################################################
# CONNECTING TO DB
$db = new PDO('sqlite:db/contacts.db') or die("fail to connect db");

# WRITING AND PREPPING QUERY
$insert_contacts_sql = 'INSERT INTO contacts (FirstName, LastName, Email) VALUES (:firstname, :lastname, :email)';
$insert_contacts = $db->prepare($insert_contacts_sql);

# EXECUTING QUERY
$insert_contacts->execute(array(':firstname' => $firstname, ':lastname' => $lastname, ':email' => $email)) or die(print_r($db->errorInfo(), true));

# NOW POSTING FIELDS TO HATCHBUCK
$hb_submit_url = "https://app.hatchbuck.com/onlineForm/submit.php";
$fields = array(
    "formID" => urlencode($formid),
    "enableServerValidation" => urlencode($server_validation),
    "enable303Redirect" => urlencode($enable_303),
    "q1_firstName1" => urlencode($firstname),
    "q3_lastName3" => urlencode($lastname),
    "q4_email" => urlencode($email),
    "website" => urlencode($antispam),
    "simple_spc" => urlencode($simple_spc)
);

# FORMATTING QUERY STRINGS IN URL FOR POST
foreach ($fields as $key=>$value) {
    $fields_string .= $key.'='.$value.'&';
}
rtrim($fields_string, '&');

# INITIALIZE CONNECTION
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $hb_submit_url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

# CAPTURING ERRORS AND DROPPING CONNECTION
$result = curl_exec($ch);
curl_close($ch);

?>

 



Note: Support cannot assist with implementing or troubleshooting this. All code examples may need to be modified to work within an individual website, and they are intended for advanced users only.