Integration of 1C-Bitrix with predictive analytics services

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

Integration of 1C-Bitrix with Predictive Analytics Services

External predictive analytics services — RetailRocket, Mindbox, Exponea, Segmentify — provide ready-made ML models for recommendations, churn prediction, personalization. Unlike own PHP/SQL implementation, they are pre-trained on millions of transaction data. Task of integration — organize two-way data exchange: from Bitrix to service and back.

Choosing a service

Service Specialization Features
RetailRocket Recommendations, trigger campaigns Russian-language, Bitrix support
Mindbox CDP + campaigns + analytics Wide functionality, higher price
Segmentify Content personalization Focus on real-time
Exponea (Bloomreach) CDP + ML European vendor, GDPR
Retail Rocket Ready module for Bitrix

Data transmission: events from browser

Most services use JavaScript SDK for behavioral event collection. SDK installed in <head> of site template. Standard event set:

Product view — in catalog.element template:

// Example for RetailRocket-like service
analytics.push(['trackProductView', {
    id: <?= (int)$arResult['ID'] ?>,
    groupId: <?= (int)$arResult['IBLOCK_SECTION_ID'] ?>,
    price: <?= (float)($arResult['CATALOG_PRICE_1']['PRICE'] ?? 0) ?>,
    isAvailable: <?= $arResult['CATALOG_QUANTITY'] > 0 ? 'true' : 'false' ?>
}]);

Cart addition — in "Buy" button handler or via OnSaleBasketItemAddBefore event.

Purchase — on successful order page via $arResult['ORDER_ID'] of sale.order.ajax component.

Transmitting product catalog

Service must know current catalog to show recommendations. Transmission — via feed (YML, CSV or custom format) or via API. Bitrix agent generates feed and publishes by URL:

function generateAnalyticsFeed(): void
{
    $elements = \CIBlockElement::GetList(
        ['SORT' => 'ASC'],
        ['IBLOCK_ID' => CATALOG_IBLOCK_ID, 'ACTIVE' => 'Y'],
        false, false,
        ['ID', 'NAME', 'IBLOCK_SECTION_ID', 'DETAIL_PAGE_URL', 'PREVIEW_PICTURE', 'CATALOG_PRICE_1', 'CATALOG_QUANTITY']
    );

    $rows = [];
    while ($el = $elements->GetNext()) {
        $rows[] = [
            'id'          => $el['ID'],
            'name'        => $el['NAME'],
            'categoryId'  => $el['IBLOCK_SECTION_ID'],
            'url'         => 'https://' . SITE_SERVER_NAME . $el['DETAIL_PAGE_URL'],
            'imageUrl'    => 'https://' . SITE_SERVER_NAME . \CFile::GetPath($el['PREVIEW_PICTURE']),
            'price'       => $el['CATALOG_PRICE_1'],
            'inStock'     => $el['CATALOG_QUANTITY'] > 0,
        ];
    }

    file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/upload/analytics_feed.json', json_encode($rows));
}

Feed updates via agent hourly. URL registered in analytics service cabinet.

Transmitting user data

On user registration and profile update — send data to service via API. Event handlers OnAfterUserRegister and OnAfterUserUpdate:

AddEventHandler('main', 'OnAfterUserRegister', function($fields) {
    if ($fields['EMAIL']) {
        AnalyticsService::identifyUser([
            'email'     => $fields['EMAIL'],
            'userId'    => $fields['USER_ID'],
            'firstName' => $fields['NAME'],
            'phone'     => $fields['PERSONAL_PHONE'],
        ]);
    }
});

AnalyticsService::identifyUser() makes POST request to service API with user identification.

Getting recommendations back to Bitrix

Recommendations obtained two ways:

Client widget — service provides JavaScript widget, inserted in needed page place and renders recommendations independently. Simplest approach, but weak control over appearance.

Server-side API — in catalog.element template or personal account component request recommendations via service API and render ourselves:

$recommendations = AnalyticsService::getRecommendations([
    'type'      => 'similar',
    'productId' => $arResult['ID'],
    'userId'    => $USER->GetID(),
    'limit'     => 8,
]);
// Pass to template for rendering via standard Bitrix means
$arResult['ANALYTICS_RECOMMENDATIONS'] = $recommendations;

Implementation timeline

Stage Timeline
SDK installation and basic events (view/cart/purchase) 2–3 days
Catalog feed with update agent 1–2 days
User identification and profile transmission 1–2 days
Server recommendations on catalog pages 2–3 days
Trigger campaigns via service 3–5 days

What we configure

  • Service JavaScript SDK in site template with view, cart and purchase events
  • Catalog feed generator in format required by service, with update agent
  • Event handlers for user registration/update for identification
  • Server-side API client for requesting recommendations and embedding in templates
  • Order data transmission via API or webhook on successful payment