- Why businesses should integrate a contact form with a CRM
- How much does website form integration with CRM cost?
- Step 1. Settings in your Zadarma account
- Step 2. PHP script
- Step 3. HTML form
- Step 4. Additional settings
- Step 5. What happens after the form is submitted
- Conclusion
- FAQs
A customer's journey to making a purchase or contacting a company most often begins with a simple form on a website. However, to quickly turn a request into a successful deal, simply collecting contact details is not enough — it's important to understand where that data goes and how it is processed next.
The foundation of effective client management is a CRM system. It helps structure your contact database, automate tasks, and ensure that no inquiry goes unattended. You can read about the operational tasks a CRM can help you solve in the article 5 reasons why your business should use a CRM system.
But a CRM alone is not enough. It needs to interact with the other tools and communication channels your business uses. Direct integration of a website form with a CRM via API has long become the standard for modern companies. This approach speeds up request processing, preserves the full context of each inquiry, and frees employees from the routine of manual data entry.
In this article, we will walk through the integration process step by step. You will learn how to automatically transfer data from a website form to a CRM and what additional information can help your sales and support teams work more efficiently.
Why businesses should integrate a contact form with a CRM
Before moving on to the code, let's look at the task from a business perspective. What does this integration actually give you?
- Instant data transfer. A request is sent to the CRM the moment the user clicks “Submit”. Your team receives a notification and can start working before the client has even closed the page.
- Fewer errors. Manual data entry inevitably leads to mistakes. A mistyped email or a missing digit in a phone number can cost you a client. The API transfers data to the CRM automatically, without loss or distortion.
- Preserved context of the inquiry. A standard email contains only the information the user typed in. API integration allows you to include additional parameters and hidden data that help you better understand the client's needs.
- Automatic lead segmentation. The script can assign tags depending on which page the form was submitted from. For example, requests from the “Payment error” page are automatically routed to technical support, while requests from the “Pricing” page go to the sales team.
Now that the benefits are clear, let's move on to the practical implementation.
How much does website form integration with CRM cost?
Teamsale CRM works alongside the Zadarma cloud PBX, and both services are provided free of charge. To keep your account active, you need to top up your balance at least once every three months. Funds can be used for any services: outgoing calls, virtual numbers, or additional PBX features.
If needed, you can connect a price plan that includes minutes for outgoing calls, virtual numbers, AI speech analytics, an increased number of CRM users, and other features. You can choose the right plan depending on your company size, communication volume, and the features you need.
Step 1. Settings in your Zadarma account
In the “Settings → Integrations and API” section, make sure that the Teamsale CRM integration is activated. Then open the “Keys and API” section and obtain your access keys — key and secret. These will be needed to authorize API requests.
Step 2. PHP script
Create a handler, for example, at https://my.site.com/zcrm_leads that will receive the form data and send it to the CRM via the API. In the UserKey and Secret fields, enter the credentials obtained in the previous step.
<?php
$postData = $_POST;
if ($postData) {
if (isset($postData['phones'], $postData['phones'][0], $postData['phones'][0]['phone'])) {
$postData['phones'][0]['type'] = 'work';
}
if (isset($postData['contacts'], $postData['contacts'][0], $postData['contacts'][0]['value'])) {
$postData['contacts'][0]['type'] = 'email_work';
}
$params = ['lead' => $postData];
$params['lead']['lead_source'] = 'form';
$leadData = makePostRequest('/v1/zcrm/leads', $params);
if (
isset($leadData['status'], $leadData['data'], $leadData['data']['id'])
&& $leadData['status'] === 'success'
&& isset($postData['comment'])
&& !empty($postData['comment'])
) {
// If the client was created, you can add a text note to their card.
$addFeedMethod = sprintf('/v1/zcrm/customers/%s/feed', $leadData['data']['id']);
$messageData = ['content' => $postData['comment']];
makePostRequest($addFeedMethod, $messageData);
}
var_dump($leadData);
}
exit();
function makePostRequest($method, $params)
{
// Replace userKey and secret with your credentials from your Zadarma account.
$userKey = '';
$secret = '';
$apiUrl = 'https://api.zadarma.com';
ksort($params);
$paramsStr = makeParamsStr($params);
$sign = makeSign($paramsStr, $method, $secret);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $apiUrl . $method);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, $paramsStr);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: ' . $userKey . ':' . $sign
]);
$response = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);
if ($error) {
return null;
}
return json_decode($response, true);
}
/**
* @param array $params
* @return string
*/
function makeParamsStr($params)
{
return http_build_query($params, null, '&', PHP_QUERY_RFC1738);
}
/**
* @param string $paramsStr
* @param string $method
* @param string $secret
*
* @return string
*/
function makeSign($paramsStr, $method, $secret)
{
return base64_encode(
hash_hmac(
'sha1',
$method . $paramsStr . md5($paramsStr),
$secret
)
);
}
?>
Step 3. HTML form
Add an HTML form to your website to submit data to the CRM. The hidden fields are required for correct data transfer.
<form method="POST" action="/zcrm_leads">
<label for="name">Name:</label>
<br>
<input type="text" id="name" name="name" value="">
<br>
<label for="comment">Comment:</label>
<br>
<input type="text" id="comment" name="comment" value="">
<br>
<label for="phone">Phone:</label>
<br>
<input type="text" id="phone" name="phones[0][phone]" value="">
<br>
<label for="email">Email:</label>
<br>
<input type="text" id="email" name="contacts[0][value]" value="">
<br>
<br>
<input type="submit" value="Submit">
</form>
This example is written in plain HTML without any third-party libraries. You can adapt the form's appearance to match your website's design and add additional fields as needed.
The full list of integration methods is available in the CRM API section.
Step 4. Additional settings
The basic form transfers a name, phone number, email, and comment. However, the CRM API allows you to send significantly more data.
Marketing parameters
If your website uses UTM tags, they can be automatically sent to the CRM via hidden form fields. This allows you to accurately track which advertising channel a lead came from.
Tags
Tags help automatically categorize leads. They can be assigned either in the HTML form or directly in the PHP script.
Additional properties
If your form includes specific fields, such as a preferred call time or selected service, these can be passed via the custom_properties parameter.
Step 5. What happens after the form is submitted
In its current state, the form is fully functional. However, before launching in a live environment, it is recommended to complete a few additional steps.
- Spam protection. It is recommended to add verification via the free Google reCAPTCHA.
- Validating data on the server. Verify that the email, phone number, and required fields are correct before sending the data to the CRM.
- Error handling. Instead of displaying var_dump($leadData), it is better to redirect the user to a thank-you page or an error page.
Conclusion
A contact form is the simplest way to pass data into a CRM. However, the same approach can be used for online stores, chatbots, landing pages, and any other channels through which you receive requests.
The open Zadarma CRM API doesn’t limit the number or type of integrations. You can automate virtually any business process and connect your own solutions without using third-party services.
If you want to expand your integration capabilities, the full list of API methods is available in the “Resources → API Documentation” section on the Zadarma website.
FAQs
How do I automatically add leads from a website form to a CRM?
The most reliable method is integration via API. The form data is sent to a server script, for example in PHP, which generates a signed request and sends it to the CRM. The lead is created automatically as soon as the form is submitted.
Can I connect a website form to a CRM without plugins?
Yes. All you need is a server script in PHP, Python, or Node.js and access to the CRM API. No additional platforms or website builders are required.
How do I store API keys securely?
API keys should only be used on the server side. Store them in your server script or in environment variables. Never include your key and secret in JavaScript code that is accessible to users.
Do I need to pay for CRM to use the API?
No. Teamsale CRM provides API access free of charge. All you need is an active account with a positive balance.