Setting up abandoned cart retargeting in 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
    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

Abandoned Cart Retargeting Setup for 1C-Bitrix

Abandoned cart retargeting means showing ads for a specific product to a user who added it to their cart but did not complete the purchase. In Yandex.Direct — via Yandex Audiences or Goals; in Google Ads — via Audience Manager. On a Bitrix site, events and identifiers must be correctly passed to the advertising systems.

Client-Side Events for Ad Pixels

Yandex.Metrica ecommerce — the foundation for retargeting in Yandex.Direct:

// When adding to cart
BX.addCustomEvent('onBasketItemAdded', function(data) {
    window.dataLayer = window.dataLayer || [];
    dataLayer.push({
        'ecommerce': {
            'currencyCode': 'RUB',
            'add': {
                'products': [{
                    'id':       String(data.productId),
                    'name':     data.productName,
                    'price':    data.price,
                    'quantity': data.quantity,
                    'category': data.sectionName,
                }]
            }
        }
    });
    // For Metrica
    ym(METRIKA_ID, 'reachGoal', 'add_to_cart', {
        product_id: data.productId,
        price:      data.price,
    });
});

Facebook Pixel / Meta Pixel (for international traffic):

BX.addCustomEvent('onBasketItemAdded', function(data) {
    fbq('track', 'AddToCart', {
        content_ids:  [String(data.productId)],
        content_type: 'product',
        value:        data.price * data.quantity,
        currency:     'RUB',
    });
});

Google Ads Remarketing Tag:

BX.addCustomEvent('onBasketItemAdded', function(data) {
    gtag('event', 'add_to_cart', {
        items: [{
            id:       String(data.productId),
            google_business_vertical: 'retail',
        }],
    });
});

Retrieving Bitrix Data for Events

In the catalog.element component template, product data is available via $arResult. Pass it to JS variables in result_modifier.php or in template.php:

// In result_modifier.php of the catalog.element component
global $APPLICATION;
$APPLICATION->AddHeadScript('');

// Or directly in template.php
$productData = [
    'id'          => $arResult['ID'],
    'name'        => $arResult['NAME'],
    'price'       => $arResult['CATALOG_PRICE_1'] ?? 0,
    'category'    => $arResult['SECTION']['NAME'] ?? '',
    'sku'         => $arResult['PROPERTIES']['ARTICLE']['VALUE'] ?? '',
];
<!-- In template.php -->
<script>
window.currentProduct = <?= json_encode($productData, JSON_UNESCAPED_UNICODE) ?>;
</script>

Then use window.currentProduct in the "Add to Cart" button JavaScript for the events.

Dynamic Retargeting: Product Feed

To show the exact product that is in the cart (rather than simply remarketing to all visitors), advertising systems require a product feed.

Yandex.Business / Direct — feed in YML format:

// /local/api/yml-feed.php
require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';
\Bitrix\Main\Loader::includeModule('iblock');
\Bitrix\Main\Loader::includeModule('catalog');

header('Content-Type: application/xml; charset=utf-8');
$date = date('Y-m-d H:i');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<yml_catalog date=\"{$date}\">\n<shop>\n";
echo "<name>Store Name</name>\n";
echo "<company>Company LLC</company>\n";
echo "<url>" . SITE_SERVER_NAME . "</url>\n";
echo "<currencies><currency id=\"RUR\" rate=\"1\"/></currencies>\n";
echo "<offers>\n";

$res = \CIBlockElement::GetList(
    ['SORT' => 'ASC'],
    ['IBLOCK_ID' => CATALOG_IBLOCK_ID, 'ACTIVE' => 'Y'],
    false,
    ['nPageSize' => 5000],
    ['ID', 'NAME', 'DETAIL_PAGE_URL', 'PREVIEW_PICTURE', 'CATALOG_PRICE_1']
);

while ($el = $res->GetNextElement()) {
    $f    = $el->GetFields();
    $p    = $el->GetProperties(['ARTICLE', 'BRAND']);
    $img  = $f['PREVIEW_PICTURE'] ? \CFile::GetPath($f['PREVIEW_PICTURE']) : '';
    $url  = SITE_SERVER_NAME . $f['DETAIL_PAGE_URL'];
    $price = $f['CATALOG_PRICE_1'] ?? 0;
    if (!$price) continue;

    echo "<offer id=\"{$f['ID']}\" available=\"true\">\n";
    echo "  <url>" . htmlspecialchars($url) . "</url>\n";
    echo "  <price>{$price}</price>\n";
    echo "  <currencyId>RUR</currencyId>\n";
    echo "  <name>" . htmlspecialchars($f['NAME']) . "</name>\n";
    if ($img) echo "  <picture>" . htmlspecialchars(SITE_SERVER_NAME . $img) . "</picture>\n";
    echo "</offer>\n";
}

echo "</offers>\n</shop>\n</yml_catalog>";

Cache the feed — do not generate it on every request. Cache for 4–8 hours using CPHPCache or an agent that saves the file.

Google Merchant Center — feed in Google Product format:

The structure is similar, but the format is a Google Spreadsheet CSV or XML with the Google namespace. Key fields: id, title, description, link, image_link, price, availability, google_product_category.

Audience Segmentation in Yandex.Metrica

Create segments in Metrica for retargeting:

  • "Added to cart, did not purchase" — reached the add_to_cart goal, did not reach order_complete in the last 30 days
  • "Browsed category X" — visited URLs matching /catalog/electronics/, did not purchase

These segments are exported to Yandex Audiences and used in Direct for impression targeting.

Setting Up Campaigns in Yandex.Direct

In Direct, select the "Dynamic Ads" or "Smart Banners" campaign type. Connect the YML feed, configure the audience as the "added to cart" segment. The bid for this audience is typically 1.5–2x higher than for cold traffic — the user is already familiar with the product.

Timelines: pixel and event setup — 1 day. YML feed development — 1–2 days. Audience and campaign setup in advertising systems — 1–2 days.