Complete Guide to Integrating Forminator with SendSquared
This guide provides a comprehensive approach to integrating WordPress Forminator with SendSquared's Lead With Contact API. This integration allows you to automatically create contacts and leads in your SendSquared CRM when visitors submit forms on your website.
Table of Contents
- Overview
- Prerequisites
- Implementation Checklist
- Gathering Required Information
- Implementation Steps
- Code Explanation
- Understanding Forminator Data Structure
- Understanding the Lead With Contact API
- Customizing the Lead Data
- Troubleshooting
- Support Resources
Overview
The Forminator-SendSquared integration allows you to:
- Automatically create contacts in SendSquared from form submissions
- Generate leads in SendSquared's CRM system
- Track customer interest and follow up with potential clients
- Streamline the lead capturing process from your WordPress website
Prerequisites
Before implementing this integration, ensure you have:
- WordPress with Forminator plugin installed and activated
- Admin access to both WordPress and SendSquared
- Basic knowledge of PHP or access to a developer
- Access to edit your theme's
functions.php
file or ability to create a custom plugin
Implementation Checklist
Copy this checklist to your task management system to track your progress:
- Forminator: Identify your form ID
- Forminator: Identify your field IDs/names
- Forminator: Test your form submission
- SendSquared: Obtain your API key
- SendSquared: Determine the lead type ID to use
- SendSquared: Determine the lead status ID to use
- SendSquared: Identify the user ID for lead assignment
- SendSquared: Determine the source ID (if applicable)
- Test the integration after implementation
Gathering Required Information
Before implementing this integration, you'll need to gather information from both Forminator and SendSquared:
From Forminator:
-
Form ID: Each Forminator form has a unique ID:
- Go to Forminator > Forms in your WordPress admin
- Look for the ID column to find your form ID
-
Field Names/IDs: Forminator uses a specific naming convention for fields:
- Go to Forminator > Forms in your WordPress admin
- Edit your form
- Click on a field and note the field type and its position number
- The field name will be in the format:
{field-type}-{position}
(e.g.,email-1
,name-1
,phone-1
) - For name fields, the first and last name are accessed as properties (e.g.,
name-1['first-name']
andname-1['last-name']
) - Note down the names for these fields:
- Email field
- Name field (which contains first and last name)
- Phone field
- Interest field (likely a select or radio field)
- Message/notes field (likely a textarea field)
From SendSquared:
- API Key: Go to Settings > API Keys in your SendSquared admin panel to obtain your API key
- Lead Type ID: Navigate to Settings > Lead Types and note the ID of the appropriate lead type
- Lead Status ID: Go to Settings > Lead Statuses and identify the status ID you want to use for new leads
- User ID: This is the ID of the agent who will be assigned these leads. You can find user IDs in the Users section
- Source ID: If you track lead sources in SendSquared, obtain the appropriate source ID from Settings > Sources
All of these IDs are required for the integration to work properly. If you're unsure about any of these values, contact SendSquared support for assistance in locating them in your account.
Implementation Steps
- Copy the code snippet below
- Paste it into your theme's
functions.php
file or in a custom plugin - Update the form ID (
$form_id != 123
) with your actual Forminator form ID - Update all the field names in the code with your actual Forminator field names:
email-1
for the email fieldname-1
for the name field (which contains 'first-name' and 'last-name')phone-1
for the phone fieldselect-1
for the interest field (could be select, radio, etc.)textarea-1
for the message field
- Update the SendSquared specific IDs that you gathered earlier:
lead_type_id
lead_status_id
user_id
source_id
- Replace
your-api-key-here
with your actual SendSquared API key - Test your form submission to ensure leads are being created in SendSquared
Code Explanation
The following code integrates Forminator with SendSquared's Lead With Contact API. When a form is submitted, it collects form data, constructs the necessary contact and lead information, and sends it to SendSquared.
<?php
add_action('forminator_form_after_save_entry', 'send_forminator_data_to_sendsquared', 10, 2);
function send_forminator_data_to_sendsquared($entry_id, $form_id)
{
// Only run this for a specific form ID - update with your form ID
if ($form_id != 123) {
return;
}
// Get the entry data
$entry = Forminator_API::get_entry($entry_id);
$entry_meta = $entry->meta_data;
// Get submitted field values - update these field names with your actual Forminator field names
$email = isset($entry_meta['email-1']) ? $entry_meta['email-1']['value'] : '';
$first_name = isset($entry_meta['name-1']['first-name']) ? $entry_meta['name-1']['first-name'] : '';
$last_name = isset($entry_meta['name-1']['last-name']) ? $entry_meta['name-1']['last-name'] : '';
$phone = isset($entry_meta['phone-1']) ? $entry_meta['phone-1']['value'] : ''; // must be in E.164 format
$interest_in = isset($entry_meta['select-1']) ? $entry_meta['select-1']['value'] : '';
$other_items = isset($entry_meta['textarea-1']) ? $entry_meta['textarea-1']['value'] : '';
// This constructs the subject line using the interest field
$subject = 'Interested in ' . $interest_in;
$now = new DateTime();
$formatted_now = $now->format(DateTime::ATOM);
// Contact data structure
$contactData = array(
'email' => $email,
'first_name' => $first_name,
'last_name' => $last_name,
'mobile_phone' => $phone, // must be in E.164 format (+1XXXXXXXXXX)
);
// Lead data structure
$leadData = array(
// Update these IDs with your actual SendSquared IDs
'lead_type_id' => 116, // Update with your lead type ID
'lead_status_id' => 504, // Update with your lead status ID
'subject' => $subject,
'interest_start_at' => $formatted_now,
'interest_end_at' => $formatted_now,
'quantity_1' => 1, // Number of adults - customize as needed
'quantity_2' => 0, // Number of children - customize as needed
'notes' => array($other_items),
'user_id' => 1446, // Update with your agent user ID
'source_id' => 0, // Update with your source ID if needed
);
// Prepare request data
$requestData = json_encode(array(
'contact' => $contactData,
'lead' => $leadData,
));
// Send data to the SendSquared API
$response = wp_remote_post('https://api.sendsquared.com/v1/leads/lead-with-contact', array(
'method' => 'POST',
'headers' => array(
'Content-Type' => 'application/json',
// Update with your actual API key
'x-api-key' => 'your-api-key-here',
),
'body' => $requestData,
));
// Error handling
if (is_wp_error($response) || wp_remote_retrieve_response_code($response) != 200) {
$response_code = wp_remote_retrieve_response_code($response);
$response_body = wp_remote_retrieve_body($response);
error_log("Error submitting lead to SendSquared (Code: {$response_code}): " . $response_body);
}
}
Understanding Forminator Data Structure
The integration uses the forminator_form_after_save_entry
hook which is triggered after a form entry is saved. This hook provides two parameters:
$entry_id
- The ID of the newly created entry$form_id
- The ID of the form that was submitted
To access the submitted data, we use Forminator_API::get_entry($entry_id)
which returns the entry object. The entry's meta data contains all the form field values in an associative array where the keys are the field names.
The structure of the meta data depends on the field type:
- Simple fields (text, email, phone):
$entry_meta['field-name']['value']
- Name fields:
$entry_meta['name-field']['first-name']
and$entry_meta['name-field']['last-name']
- Address fields:
$entry_meta['address-field']['street_address']
,$entry_meta['address-field']['city']
, etc. - Checkbox fields:
$entry_meta['checkbox-field']['value']
(returns an array)
Understanding the Lead With Contact API
The SendSquared Lead With Contact API creates both a contact record and a lead record in a single API call, linking them together automatically. This is useful when:
- You want to capture new leads from your website
- You need to track interest in specific properties or services
- You want to automate the lead capture process
Customizing the Lead Data
You can customize various aspects of the lead data to fit your specific needs:
// Example of additional lead customization
$leadData = array(
'lead_type_id' => 116,
'lead_status_id' => 504,
'subject' => $subject,
'interest_start_at' => $formatted_now,
'interest_end_at' => $formatted_now,
'quantity_1' => isset($entry_meta['number-1']) ? intval($entry_meta['number-1']['value']) : 1, // Adults field
'quantity_2' => isset($entry_meta['number-2']) ? intval($entry_meta['number-2']['value']) : 0, // Children field
'notes' => array(
"Interest: " . $interest_in,
"Budget: " . (isset($entry_meta['text-1']) ? $entry_meta['text-1']['value'] : ''), // Budget field
"Additional notes: " . $other_items
),
'user_id' => 1446, // The agent who will handle this lead
'source_id' => 123, // Your website source ID
);
Troubleshooting
If your integration isn't working properly, check these common issues:
- Field Name Mismatch: Verify that your Forminator form ID and field names/IDs match exactly what you've specified in the code
- API Credentials: Confirm that your SendSquared API key is correct
- Error Logs: Check your WordPress error logs for any API errors
- Response Codes: Pay attention to response codes from the SendSquared API:
- 422 Error: This means validation failed. The response body will contain details about what is missing or incorrect in your request. Check field formats (especially the phone number which must be in E.164 format) and required fields.
- Network Issues: Ensure that WordPress can make outgoing HTTP requests (some hosting providers block these)
- API Accessibility: Verify that the SendSquared API endpoint is accessible from your server
To debug Forminator submissions, you can add this code temporarily to see the structure of your form entries:
add_action('forminator_form_after_save_entry', 'debug_forminator_submission', 10, 2);
function debug_forminator_submission($entry_id, $form_id) {
$entry = Forminator_API::get_entry($entry_id);
error_log('Forminator Submission - Entry ID: ' . $entry_id);
error_log('Forminator Submission - Form ID: ' . $form_id);
error_log('Forminator Submission - Entry Data: ' . print_r($entry, true));
}
Support Resources
For additional support, contact SendSquared support at:
- Email: support@sendsquared.com
- Phone: +1.855.340.7363
For Forminator support, refer to their documentation at: