Setting up an abandoned viewing email notification 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

Setting up email notification for abandoned product view in 1C-Bitrix

An abandoned view trigger captures the fact — user viewed product but did nothing. Email notification turns this fact into marketing action: an email arrives in 30–60 minutes with the viewed product card, price and "View again" button. Implementation is built on top of the abandoned view trigger from b_catalog_viewed_product and Bitrix's standard mail engine.

Mail event type

In Bitrix emails are sent via the mail events system. You need to create an event type in "Settings → Mail → Mail event types":

  • Symbolic code: CATALOG_ABANDONED_VIEW
  • Event fields: PRODUCT_ID, PRODUCT_NAME, PRODUCT_URL, PRODUCT_PRICE, PRODUCT_IMAGE, USER_NAME, USER_EMAIL

Email template is created in "Settings → Mail → Mail event templates" and linked to the event type for the needed site.

Email template

Template is written as HTML with Bitrix macros. Product data is passed via event field array:

Subject: #PRODUCT_NAME# — you viewed this product
Body:
<p>Hello, #USER_NAME#!</p>
<p>You recently viewed the product:</p>
<p><img src="#PRODUCT_IMAGE#" width="200"/></p>
<p><strong>#PRODUCT_NAME#</strong></p>
<p>Price: #PRODUCT_PRICE# rubles</p>
<a href="#PRODUCT_URL#">View product</a>

Product image (PRODUCT_IMAGE) — absolute URL. In the agent you need to get the path from CFile::GetPath($previewPictureId) and add site domain.

Sending logic in agent

Agent polls b_catalog_viewed_product, finds entries in the "30 to 90 minutes ago" window that don't have corresponding order or addition to cart, and sends email:

$email = \Bitrix\Main\UserTable::getById($userId)
    ->fetchObject()
    ?->getEmail();

if ($email) {
    \Bitrix\Main\Mail\Event::send([
        'EVENT_NAME' => 'CATALOG_ABANDONED_VIEW',
        'LID'        => SITE_ID,
        'C_FIELDS'   => [
            'USER_EMAIL'    => $email,
            'USER_NAME'     => $userName,
            'PRODUCT_ID'    => $productId,
            'PRODUCT_NAME'  => $productName,
            'PRODUCT_URL'   => $productUrl,
            'PRODUCT_PRICE' => $price,
            'PRODUCT_IMAGE' => $imageUrl,
        ],
    ]);
}

Deduplication and frequency limits

Without control a user can receive multiple emails per day if they viewed different products. Restrictions:

  • No more than one abandoned view email per 24 hours per user
  • Don't send if abandoned cart email (CATALOG_ABANDONED_CART) was already sent in this period
  • Exclude users who unsubscribed from marketing mailings (field UF_MAILING_SUBSCRIBE in b_uts_user or check via b_subscribe_user_group)

Deduplication table bl_abandoned_view_sent: fields (user_id, sent_date) with unique index. Before sending — INSERT OR IGNORE, if record exists — skip.

What we configure

  • Mail event type CATALOG_ABANDONED_VIEW and HTML email template
  • Agent with logic for selecting from b_catalog_viewed_product and checking cart/orders
  • Deduplication table with limit of one email per 24 hours per user
  • Check subscription status before sending
  • Building absolute URLs for product images for correct display in email