Integration of 1C-Bitrix with Carrot Quest

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

1C-Bitrix Integration with Carrot Quest

Carrot Quest is a platform that combines live chat, email marketing, pop-ups, and user behavior analytics in a single tool. Unlike simple chat widgets, user identification is critical here: every event (product view, add to cart, order placement) is tied to a profile. Without that linkage, Carrot Quest becomes just an expensive live chat.

Installing the Tracking Code

The Carrot Quest code is inserted into the site template before </body>:

// In the Bitrix template
(function(){ /* ... standard Carrot Quest snippet ... */ })();
carrotquest.connect('YOUR_API_KEY');

Identifying Users from Bitrix

The key operation is carrotquest.identify(). Without it, all events are anonymous and do not accumulate in a profile.

<?php if ($USER->IsAuthorized()):
    $userId    = $USER->GetID();
    $userEmail = $USER->GetEmail();
    $userName  = $USER->GetFullName();
    // Hash for server-side verification in Carrot Quest
    $hash = hash_hmac('sha256', $userId, 'YOUR_SECRET_KEY');
?>
<script>
carrotquest.identify({
    '$user_id':    <?= json_encode($userId) ?>,
    '$email':      <?= json_encode($userEmail) ?>,
    '$name':       <?= json_encode($userName) ?>,
    '$phone':      <?= json_encode(getUserPhone($userId)) ?>,
    'orders_count': <?= getUserOrdersCount($userId) ?>,
    'total_spent':  <?= getUserTotalSpent($userId) ?>,
}, <?= json_encode($hash) ?>);
</script>
<?php endif; ?>

The hash parameter is an HMAC-SHA256 of the user_id with the secret key. This verifies the authenticity of the data on the Carrot Quest side and prevents ID spoofing.

Sending Events from the Bitrix Catalog

Carrot Quest delivers the most analytical value when it receives events from across the entire funnel. Events are sent via carrotquest.track():

Product page view (in the catalog.element template):

carrotquest.track('Product Viewed', {
    product_id:   <?= $arResult['ID'] ?>,
    product_name: <?= json_encode($arResult['NAME']) ?>,
    price:        <?= $arResult['CATALOG_PRICE_1'] ?? 0 ?>,
    category:     <?= json_encode($sectionName) ?>,
});

Add to cart (button handler):

// After a successful AJAX add-to-cart
carrotquest.track('Product Added to Cart', {
    product_id:   productId,
    product_name: productName,
    price:        price,
    quantity:     quantity,
});

Order placed (in the sale.order.ajax template, event after order creation):

carrotquest.track('Order Placed', {
    order_id:    <?= $orderId ?>,
    total_price: <?= $orderTotal ?>,
    items_count: <?= $itemsCount ?>,
    payment_method: <?= json_encode($paymentMethod) ?>,
});

User Segmentation via Attributes

After carrotquest.identify(), user attributes can be updated on every visit — this allows building segments in Carrot Quest for triggered messages:

// Update on every login
carrotquest.identify({
    'last_visit':       new Date().toISOString(),
    'cart_value':       <?= $basketTotal ?>,
    'cart_items_count': <?= $basketCount ?>,
    'loyalty_level':    <?= json_encode($loyaltyLevel) ?>,
});

Integration via Carrot Quest PHP API

In addition to JS tracking, Carrot Quest has a REST API for server-side use. This is needed when an event occurs outside the browser — for example, an order status change:

// On order status change — notify Carrot Quest
\Bitrix\Main\EventManager::getInstance()->addEventHandler(
    'sale', 'OnSaleStatusOrder',
    function (\Bitrix\Main\Event $event) {
        $order      = $event->getParameter('ENTITY');
        $userId     = $order->getUserId();
        $userEmail  = getUserEmail($userId);
        $statusId   = $order->getField('STATUS_ID');

        $payload = [
            'id'         => $userEmail,
            'id_type'    => 1, // 1 = email
            'event'      => 'Order Status Changed',
            'params'     => [
                'order_id'   => $order->getId(),
                'new_status' => $statusId,
            ],
        ];

        $ch = curl_init('https://api.carrotquest.io/v1/users/events');
        curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Token YOUR_API_KEY', 'Content-Type: application/json']);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_exec($ch);
        curl_close($ch);
    }
);

Automated Messages Based on Events

Once tracking is configured, triggered sequences are built in the Carrot Quest interface:

  • User viewed product X → did not add to cart within 30 minutes → chat message "Need help choosing?"
  • Order created → status "Delivered" → 7 days later email "Leave a review"
  • User has not visited in 60 days → email with a discount

All of this is configured in the Carrot Quest interface without code — provided that events arrive correctly.

Debugging Tracking

Use the browser console: when configured correctly, carrotquest.track() and carrotquest.identify() print confirmation to the console in development mode. In the Carrot Quest admin panel, Analytics → Events shows incoming events in real time.

Scope of work: code installation and user identification — 1 day. Tracking all funnel events — 2–3 days. Server-side API for order status changes — another 1 day. Setting up triggered sequences — 1–2 days after initial data accumulates.