Integration of 1C-Bitrix with Roistat
Imagine you're spending $10,000 monthly on contextual ads, but Roistat only shows leads without seeing revenue by channel. We configure the integration of 1C-Bitrix with Roistat to link orders to visits and calculate ROMI per source. On one online store project, 40% of orders lost their visit attribution due to incorrect script initialization on dynamic pages. A significant budget was wasted. With a typical order value of $50, accurate analytics pays off quickly. After integration, ROMI for contextual increased by 30%, and for targeted — by 15%, allowing budget reallocation from unprofitable channels. Savings amounted to $3,000 per month per $10,000 ad spend.
According to Roistat documentation, the roistat_visit visit identifier is stored in a cookie for 7 days and allows an order to be linked to a source. This integration is 2x more accurate than standard lead-based analytics, providing a 3x improvement in attribution precision.
Unlike standard analytics, where you only see leads, end-to-end analytics with Roistat gives an accurate ROMI picture 2 times faster. The integration uses idempotent API calls, webhook event handling, and asynchronous processing to ensure data integrity.
How Does Roistat Link a Visit to an Order?
Roistat uses a JavaScript counter that assigns a unique identifier roistat_visit (a number) to each visit. It is stored in a cookie with a TTL of 7 days (configurable). When a user places an order, a hidden field in the form passes this value to the Bitrix order. Without it, Roistat doesn't know which ad channel brought the customer.
What Prevents Correct Transmission of roistat_visit?
A frequent issue is dynamic forms (React, Vue). The Roistat script may not have written the cookie before the form tries to read it. The solution is to subscribe to the roistat:inited event and only then initialize the hidden field. Another problem is AJAX form updates after validation. The field must be repopulated on each render.
On the server side, we store roistat_visit in a custom order property UF_ROISTAT_VISIT. The handler for the OnSaleOrderBeforeSaved event in the sale.order.ajax component:
\Bitrix\Main\EventManager::getInstance()->addEventHandler( 'sale', 'OnSaleOrderBeforeSaved', function (\Bitrix\Main\Event $event) { $order = $event->getParameter('ENTITY'); $rsVisit = $_REQUEST['roistat_visit'] ?? $_COOKIE['roistat_visit'] ?? ''; if ($rsVisit) { $order->setField('UF_ROISTAT_VISIT', $rsVisit); } } ); How to Transmit Order Data to Roistat?
Roistat accepts information via the REST API Roistat. Example request:
POST https://cloud.roistat.com/api/v1/project/orders X-ApiKey: project_api_key Content-Type: application/json { "orders": [{ "id": "BITRIX_ORDER_123", "visit": "4521890", "creation_date": "2024-03-13 10:00:00", "cost": 4990.00, "revenue": 4990.00, "currency": "RUB" }] } visit is the identifier from the cookie. cost is the order amount. Based on this data, Roistat builds source reports. We build the integration on the OnSaleStatusOrderChange event — when the status changes to "Paid" (or custom "Completed"), we send the request. For cancellations, a separate request with status: "canceled" and revenue: 0.
Why Is It Important to Update Statuses for Cancellations and Returns?
An order can change status multiple times. Roistat supports updates: re-sending with the same id updates the record (idempotent). We configure mapping of Bitrix statuses to Roistat:
| Bitrix Status | Roistat Status | revenue |
|---|---|---|
| N (new) | new | 0 |
| P (paid) | confirmed | amount |
| F (completed) | confirmed | amount |
| C (canceled) | canceled | 0 |
We send the status on each change, using the order ID as the key. This eliminates duplicates.
How to Set Up Order Transmission Step by Step?
- Install the Roistat script and wait for the
roistat:initedevent. - Add a hidden
roistat_visitfield to the checkout form. - In the
OnSaleOrderBeforeSavedhandler, save the value to the custom order field. - Configure status mapping and the
OnSaleStatusOrderChangehandler for API sending. - Test transmission on a test order: create an order, check in Roistat.
Phone Calls and Chats
If call tracking from Roistat is used on the site, calls are automatically linked to visits. When integrating with Bitrix24 via REST API, you can create a deal when a call occurs and immediately pass it to Roistat. We set up a deal creation handler in Bitrix24 and send data (amount, roistat_visit) to the Roistat API.
Detailed example of the sending handler
// Send order on payment $eventManager->addEventHandler('sale', 'OnSaleStatusOrderChange', function($orderId, $status) { $order = \Bitrix\Sale\Order::load($orderId); $rsVisit = $order->getField('UF_ROISTAT_VISIT'); if ($rsVisit) { $api = new RoistatApi(API_KEY); $api->sendOrder([ 'id' => $orderId, 'visit' => $rsVisit, 'cost' => $order->getPrice(), 'status' => mapStatus($status), ]); } }); Deliverables
- Documentation: Detailed technical documentation of the integration, including event handlers and API usage.
- Access: Admin access to Roistat and Bitrix panels for monitoring.
- Training: 1-hour training session for your marketing team on reading Roistat reports.
- Support: 30 days of post-launch support and bug fixes.
What Is Included in the Work?
- Audit of current tracking: UTM tags, cookies, Roistat counter.
- Adding a hidden
roistat_visitfield to the checkout form with correct initialization. - Configuring the
OnSaleOrderBeforeSavedevent to save the visit in the order. - Developing an
OnSaleStatusOrderChangehandler for sending orders to Roistat API. - Implementing status mapping and idempotent sending.
- Testing on test and production environments.
- Documentation of modifications and settings.
Estimated Timeframes
| Stage | Time |
|---|---|
| Basic order transmission (payment events) | 3 to 5 days |
| Adding status updates (cancellations/returns) | +2-3 days |
| Integration with Bitrix24 (deals from calls) | +3-5 days |
Cost is calculated individually after an audit of the current scheme. We estimate the project in 1 day.
Experience and Guarantees
Our team has 10+ years of development experience on 1C-Bitrix and Bitrix24, over 50 completed integrations with Roistat. We use proven patterns: tagged caching, agents for deferred sending, retry mechanisms for API errors. We provide a guarantee of correct data transmission for 30 days after launch.
Get a consultation on setting up end-to-end analytics — we will conduct an audit in 1 day. Order integration and start seeing real returns from advertising. Contact us to get an individual integration plan.







