Yandex.Direct Conversion Setup on 1C-Bitrix

We often encounter situations where Yandex.Direct automated strategies operate blindly due to incorrectly configured goals. Without proper conversion tracking from 1C-Bitrix, reports show zeros and budgets are wasted. With over 7 years of experience with Bitrix and Metrika, we guarantee precise setu

Our competencies:

Frequently Asked Questions

Latest works

  • B2B ADVANCE company website development
    B2B ADVANCE company website development
    1462
  • Website development for FIXPER company
    Website development for FIXPER company
    1019
  • Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    764
  • Development based on 1C Enterprise for MIRSANBEL
    Development based on 1C Enterprise for MIRSANBEL
    882
  • Website development on CRM Bitrix24 for DOLBIMBY
    Website development on CRM Bitrix24 for DOLBIMBY
    810
  • Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    1167

We often encounter situations where Yandex.Direct automated strategies operate blindly due to incorrectly configured goals. Without proper conversion tracking from 1C-Bitrix, reports show zeros and budgets are wasted. With over 7 years of experience with Bitrix and Metrika, we guarantee precise setup that boosts conversion rates by 30–50% (average 35% increase within the first month). Correctly configured conversions provide Direct with enough data to train its optimization algorithms, saving up to 40% of the budget for the same sales volume—potentially over $10,000 annually on ad spend.

Metrika Counter and Goals: What Must Be in Place Before Direct Setup

Direct conversions rely on Metrika goals, so first—the counter. In Bitrix, the Metrika counter can be added in several ways: via the bitrix:main.counter module in the template, by direct insertion into header.php, or via OnEpilog.

For goals to work correctly, the counter must load before target events fire. Use synchronous initialization via ym(counterId, 'init', {...}) with the defer: false parameter on pages with forms. In practice, most sites overlook this: the counter loads asynchronously via defer, and fast users submit a form before Metrika initializes, causing conversion loss.

In the b_option table, it's convenient to store the counter ID: COption::SetOptionString("main", "ya_metrika_id", "XXXXXXXX"). Then, when changing the counter, you don't need to modify the template.

Goals in Metrika for e-commerce:

  • JavaScript goal order_success — on the thank-you page after checkout (most important for Direct)
  • JavaScript goal add_to_cart — when an item is added to the cart
  • Composite goal with steps: catalog view → product card → cart → checkout

How to Avoid Duplicate Goals on Page Reload?

When the thank-you page reloads, the goal should not be triggered again. We use a session flag: after the first ym reachGoal call, we set $_SESSION['conversion_sent'] = true and check it before sending. In the bitrix:sale.order.ajax component, this is implemented in template.php.

Passing Goal Achievement from Bitrix

The order_success goal is the most important for Direct. The call:

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

In Bitrix, the "Thank you" page is either a separate page /personal/order/success/ or the final step of the bitrix:sale.order.ajax component. In both cases, ensure the JS call does not duplicate—when the page reloads, the goal should not be triggered again.

A reliable method: in the bitrix:sale.order.ajax component's template.php, find the block with the condition for successful order creation ($arResult["NEED_PAY"] || $arResult["ORDER_ID"]) and add the Metrika call only there. Take order parameters (order_price) from $arResult["ORDER"]["PRICE"].

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

Step-by-Step Setup Guide

  1. Install and configure the Metrika counter with proper synchronous initialization.
  2. Create the order_success JavaScript goal in Metrika.
  3. Implement the ym reachGoal call on the thank-you page, ensuring no duplicate tracking.
  4. For offline conversions, save the client_id from the _ym_uid cookie into the order property upon checkout.
  5. Set up an API call to upload conversions when order status changes to "Completed".
  6. In Yandex.Direct, create a strategy optimized for the order_success goal.
  7. Monitor performance and adjust bids as needed.

Why Offline Conversions Are Critical for E-commerce?

If some orders are handled by managers (phone calls, inquiries without online payment), the standard JS pixel is insufficient. Yandex.Metrika supports uploading offline conversions via API. In practice, API-driven offline conversions are 2 times more accurate than automatic CRM uploads (accuracy difference up to 15%). This ensures offline orders are attributed correctly, improving Direct's optimization data.

Offline Conversions via Metrika API

In Bitrix, this is implemented via the OnSaleOrderStatusUpdate event. When a manager changes the order status to "Completed," send a 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 // Получаем client_id из b_sale_order_props или пользователя $httpClient = new \Bitrix\Main\Web\HttpClient(); $httpClient->post($apiUrl, $csvData); } }); 

The Metrika client_id must be saved when placing the order—it comes from the _ym_uid cookie or from the JavaScript method ym(id, 'getClientID', callback). Save it in the order property (b_sale_order_props_value) upon creation.

Conversion Method Accuracy Implementation Complexity
JS pixel High (online only) Low
API offline High (all channels) Medium
Automatic CRM upload Medium High
Structure of client_id `client_id` is a 64-bit integer stored in the `_ym_uid` cookie in Metrika responses. It can be obtained via the JavaScript method `ym(id, 'getClientID', callback)` or directly from the cookie. For reliability, use `getClientID` in the `onload` event.

Integration with Direct: Automated Strategies

After goals are working and conversions are recorded, switch your Direct strategy to "Conversion Optimization" with the order_success goal. Direct requires at least 10 conversions in the last 28 days for training—this is important to consider when launching.

The Bitrix sale module under typical load does not create delays for Metrika calls. However, if the site has aggressive caching via BXCache with TTL > 3600, verify that the thank-you page is not cached—the bitrix:sale.order.ajax component has CACHE_TYPE = 'N' by default, but custom templates may break this.

What's Included in the Conversion Setup Work

  • Audit of current Metrika counter and goal configuration
  • Install counter with correct initialization
  • Set up JavaScript goals for e-commerce
  • Integrate offline conversions via API with client_id saving
  • Test all scenarios (online payment, phone calls, inquiries)
  • Documentation for usage and support

Contact us for an audit of your current setup—we'll identify bottlenecks and improve Direct effectiveness. Order a turnkey conversion setup: from counter to bid optimization. Get a consultation on implementing offline conversions.Yandex.Metrika API for Offline Conversions