In today’s digital world, integrating your website’s contact forms with your CRM is essential for efficient lead management and streamlined communication. If you’re using Contact Form 7 on your WordPress site and want to send form submissions to Insightly CRM, this guide is for you. We’ll walk you through the process, ensuring a seamless integration that enhances your workflow.
Why Integrate Contact Form 7 with Insightly CRM?
Contact Form 7 is a popular WordPress plugin that allows you to create and manage multiple contact forms with ease. However, manually transferring form submissions to your CRM can be time-consuming and error-prone. By integrating Contact Form 7 with Insightly CRM, you can automate this process, ensuring that all form data is accurately captured and stored in your CRM for future reference.
- Step 1: Install and Activate Contact Form 7
If you haven’t already, install and activate the Contact Form 7 plugin on your WordPress site. You can find it in the WordPress plugin repository or by searching for it in your WordPress dashboard.
- Step 2: Retrieve the Form Data After Submission
We’ll use the wpcf7_mail_sent hook to capture the form data after the email is sent. This hook allows us to execute our custom function once the form submission is complete.
Add the following code to your theme’s functions.php file or create a custom plugin:
// Hook into the Contact Form 7 mail sent action
add_action('wpcf7_mail_sent', 'submit_to_insightly', 10, 1);
function submit_to_insightly($contact_form) {
// Get the submission instance
$submission = WPCF7_Submission::get_instance();
if ($submission) {
// Get the form data
$data = $submission->get_posted_data();
// Map your form fields to Insightly fields
$first_name = isset($data['your-first-name']) ? $data['your-first-name'] : '';
$last_name = isset($data['your-last-name']) ? $data['your-last-name'] : '';
$email = isset($data['your-email']) ? $data['your-email'] : '';
$message = isset($data['your-message']) ? $data['your-message'] : '';
// Prepare the data to be sent to Insightly
$insightly_data = array(
'FIRST_NAME' => $first_name,
'LAST_NAME' => $last_name,
'EMAIL_ADDRESS' => $email,
'ADDRESS_MAIL_STREET' => $message,
);
// Submit the data to Insightly
send_to_insightly($insightly_data);
}
}
function send_to_insightly($data) {
$api_url = 'https://api.insightly.com/v3.1/Contacts'; // Insightly API endpoint
$api_key = 'your_insightly_api_key'; // Replace with your Insightly API key
// Set up the request
$args = array(
'body' => json_encode($data),
'headers' => array(
'Content-Type' => 'application/json',
'Authorization' => 'Basic ' . base64_encode($api_key . ':')
),
'method' => 'POST'
);
// Send the request to Insightly
$response = wp_remote_post($api_url, $args);
// Handle the response
if (is_wp_error($response)) {
error_log('Insightly API request failed: ' . $response->get_error_message());
} else {
error_log('Insightly API request succeeded: ' . wp_remote_retrieve_body($response));
}
}
- Step 3: Configure Your Form Fields
Ensure your Contact Form 7 fields match the ones you are mapping in the code. For instance, if your form fields are named your-first-name, your-last-name, your-email, and your-message, they should be referenced correctly in the code.
- Step 4: Replace the API Key
In the send_to_insightly function, replace 'your_insightly_api_key' with your actual Insightly API key. This key is essential for authenticating your requests to the Insightly API.
- Step 5: Test the Integration
Submit a test form on your website to ensure the data is correctly sent to Insightly CRM. Check your Insightly account to verify that the contact information has been added or updated as expected.
Benefits of Automating Contact Form Submissions to CRM
- Time-Saving: Automates the manual process of transferring data, allowing your team to focus on more critical tasks.
- Accuracy: Reduces the risk of errors associated with manual data entry.
- Efficiency: Streamlines your workflow by ensuring all lead information is stored in a single, accessible location.