Integration of the landing page with KeyCRM: PHP script that generates orders
The client sells products through a landing page and previously received applications via email/spreadsheets.
Task: To ensure that each application from the form on the website automatically creates a deal in KeyCRM with a complete set of data:
- contact (name, email, phone);
- product(s) and amount;
- payment and its status;
- UTM tags from advertising;
- additional fields for business logic.
Solution
On the website side, a PHP form handler was added, which collects all data from $_POST and forms a structured array data according to the KeyCRM API format:
Main details of the deal:
- title — name of the application;
- source_id — lead source;
- manager_comment — comment from the form;
- manager_id and pipeline_id — responsible manager and pipeline.
Contact:
- the contact block with full_name, email, phone creates/updates the customer card linked to the deal.
Marketing data:
- utm_source, utm_medium, utm_campaign, utm_term, utm_content — all UTM from the link are automatically sent to the CRM so that marketing can see which campaign/ad the lead came from.
Products:
- the products array with fields name, sku, quantity, price, picture allows to immediately record what exactly the client is buying, in what quantity and at what price.
Payments:
- the payments array with payment_method_id, amount, payment_date, status (“paid”, “not_paid”, “canceled”, “refund”) allows linking the fact/status of payment to the deal.
Custom fields:
- the custom_fields block with uuid and value fills in business-specific fields (for example, lead type, source of inquiry, internal tags).
- After forming the $data array, it is sent to KeyCRM via an HTTP request to their API endpoint for creating deals/orders (described as “server-side integration of the form with CRM”).
What the client received
- Automatic deals: each form submission on the website creates a complete card in KeyCRM without manual entry.
- Transparent analytics: marketing sees UTM tags for each deal and can calculate conversions by campaigns.
- Accurate sales accounting: the card immediately contains products, amount, and payment status — convenient for finance and repeat sales.
- Readiness for scaling: when expanding the website/advertising, there is no need to change the process in the sales department — everything is already centralized in the CRM.
Task: To ensure that each application from the form on the website automatically creates a deal in KeyCRM with a complete set of data:
- contact (name, email, phone);
- product(s) and amount;
- payment and its status;
- UTM tags from advertising;
- additional fields for business logic.
Solution
On the website side, a PHP form handler was added, which collects all data from $_POST and forms a structured array data according to the KeyCRM API format:
Main details of the deal:
- title — name of the application;
- source_id — lead source;
- manager_comment — comment from the form;
- manager_id and pipeline_id — responsible manager and pipeline.
Contact:
- the contact block with full_name, email, phone creates/updates the customer card linked to the deal.
Marketing data:
- utm_source, utm_medium, utm_campaign, utm_term, utm_content — all UTM from the link are automatically sent to the CRM so that marketing can see which campaign/ad the lead came from.
Products:
- the products array with fields name, sku, quantity, price, picture allows to immediately record what exactly the client is buying, in what quantity and at what price.
Payments:
- the payments array with payment_method_id, amount, payment_date, status (“paid”, “not_paid”, “canceled”, “refund”) allows linking the fact/status of payment to the deal.
Custom fields:
- the custom_fields block with uuid and value fills in business-specific fields (for example, lead type, source of inquiry, internal tags).
- After forming the $data array, it is sent to KeyCRM via an HTTP request to their API endpoint for creating deals/orders (described as “server-side integration of the form with CRM”).
What the client received
- Automatic deals: each form submission on the website creates a complete card in KeyCRM without manual entry.
- Transparent analytics: marketing sees UTM tags for each deal and can calculate conversions by campaigns.
- Accurate sales accounting: the card immediately contains products, amount, and payment status — convenient for finance and repeat sales.
- Readiness for scaling: when expanding the website/advertising, there is no need to change the process in the sales department — everything is already centralized in the CRM.