Setting up Yandex.Direct conversions on 1C-Bitrix

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
    1189
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    813
  • 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
    657
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Yandex Direct Conversion Setup on 1C-Bitrix

Sending conversions to Yandex Direct is linking two tools: Yandex.Metrica (which registers goals) and Direct itself (which uses goals to optimize bids). Without correctly configured goals, Direct's automatic strategies work blind, and conversion reports show zeros.

Metrica Counter and Goals: What Should Be Ready Before Direct Setup

Direct conversions rely on Metrica goals, so first comes the counter. In Bitrix, Metrica counter is added several ways: via bitrix:main.counter component in template, direct insertion in header.php, or via OnEpilog.

For proper goal operation, critical: counter must load before goal events fire. Use synchronous initialization via ym(counterId, 'init', {...}) with defer: false for pages with forms.

In b_option table it's convenient to store counter ID: COption::SetOptionString("main", "ya_metrika_id", "XXXXXXXX"). Then switching counter doesn't need template edits.

Goals in Metrica for e-commerce:

  • JavaScript goal order_success — on thank you page after order
  • JavaScript goal add_to_cart — when adding product to cart
  • Composite goal with steps: catalog view → product card → cart → checkout

Sending Goal Achievement from Bitrix

The order_success goal is most important for Direct. Call:

ym(COUNTER_ID, 'reachGoal', 'order_success', {
    order_price: 4900,
    currency: 'RUB'
});

In Bitrix the "Thank You" page is either separate page /personal/order/success/ or final step of bitrix:sale.order.ajax component. In both cases ensure JS call doesn't duplicate — on page reload goal shouldn't register again.

Reliable method: in bitrix:sale.order.ajax component in template.php find block with successful order creation condition ($arResult["NEED_PAY"] || $arResult["ORDER_ID"]) and add Metrica call only there. Get order params (order_price) from $arResult["ORDER"]["PRICE"].

For /personal/order/success/ page — bitrix:sale.order.detail component gives access to order details via $arResult. Order ID from URL parameter + CSaleOrder::GetByID($orderId).

Offline Conversions via Metrica API

If some orders are processed by managers (calls, applications without online payment), standard JS pixel isn't enough. Yandex.Metrica supports offline conversion upload via API.

In Bitrix implement via OnSaleOrderStatusUpdate event handler. When manager moves order to "Completed" status, send POST request to https://api-metrika.yandex.net/management/v1/counter/{counterId}/uploads/client_id:

AddEventHandler("sale", "OnSaleOrderStatusUpdate", function($id, $arFields) {
    if ($arFields["STATUS_ID"] === "F") { // Finished
        // Get client_id from b_sale_order_props or user
        $httpClient = new \Bitrix\Main\Web\HttpClient();
        $httpClient->post($apiUrl, $csvData);
    }
});

Metrica client_id must be saved on order creation — this value comes from cookie _ym_uid or JS method ym(id, 'getClientID', callback). Save to order property (b_sale_order_props_value) on creation.

Direct Connection: Automatic Strategies

After goals work and conversions register, in Direct switch strategy to "Conversion Optimization" with order_success goal. Direct needs minimum 10 conversions per 28 days to learn — important to account for on launch.

sale module under typical load doesn't create delays for Metrica calls, but if site has aggressive BXCache caching with TTL > 3600, check that thank you page doesn't cache — bitrix:sale.order.ajax component has CACHE_TYPE = 'N' by default, but custom templates can break this.