Integrating 1C-Bitrix with Unisender

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

1C-Bitrix Integration with UniSender

UniSender is one of the leading email marketing platforms with a straightforward REST API. It suits mid-sized businesses: affordable pricing, solid deliverability to major mail services (Mail.ru, Yandex.Mail).

UniSender API

All methods are available at https://api.unisender.com/ru/api/{method}?format=json&api_key={KEY}. Authentication uses an API key passed as a query parameter or request header. The key is created in the UniSender account settings.

Contact Synchronisation

class UniSenderClient {
    private string $apiKey;
    private string $baseUrl = 'https://api.unisender.com/ru/api/';

    public function __construct() {
        $this->apiKey = COption::GetOptionString('site', 'unisender_api_key');
    }

    public function importContacts(array $contacts, int $listId): array {
        // Batch import of up to 500 contacts per call
        $fieldNames  = ['email', 'email_list_ids', 'Name', 'Phone'];
        $fieldValues = [];

        foreach ($contacts as $c) {
            $fieldValues[] = [
                $c['email'],
                (string)$listId,
                $c['name'] ?? '',
                $c['phone'] ?? '',
            ];
        }

        $http = new \Bitrix\Main\Web\HttpClient();
        return json_decode($http->post($this->baseUrl . 'importContacts', [
            'api_key'      => $this->apiKey,
            'format'       => 'json',
            'field_names'  => $fieldNames,
            'data'         => $fieldValues,
            'overwrite_tags'    => 1,
            'overwrite_lists'   => 0,
        ]), true);
    }
}

importContacts is the primary method for bulk synchronisation. Each call handles up to 500 contacts. When exporting the full subscriber base, split it into batches.

Subscription Handler

AddEventHandler('subscribe', 'OnSubscribeSubscribe', function($id, $email, $fields) {
    $listId = COption::GetOptionString('site', 'unisender_list_id');
    $client = new UniSenderClient();
    $client->subscribe($email, $listId, [
        'Name'  => $fields['NAME'] ?? '',
        'Phone' => $fields['PERSONAL_PHONE'] ?? '',
    ]);
});

The subscribe method adds a single contact and sends them a confirmation email (double opt-in) if that setting is enabled in UniSender.

Retrieving Contact Status

Before creating a mailing it is useful to know the subscriber's current status — whether they are active or have unsubscribed:

public function getContactStatus(string $email): string {
    $http = new \Bitrix\Main\Web\HttpClient();
    $response = json_decode($http->get(
        $this->baseUrl . 'getContact?api_key=' . $this->apiKey
        . '&format=json&email=' . urlencode($email)
    ), true);
    return $response['result']['status'] ?? 'unknown';
    // 'active', 'unsubscribed', 'bounced', 'spam'
}

Used during order processing: if the buyer has unsubscribed, they are not added to new mailing lists.

Triggered Mailing After Order Placement

After an order is placed, a series of transactional emails is sent via UniSender Automation:

AddEventHandler('sale', 'OnSaleOrderSaved', function($order) {
    if (!$order->isNew()) return;
    $email = getOrderEmail($order);

    // Send transactional email via UniSender
    $client = new UniSenderClient();
    $client->sendEmail([
        'to'         => [['email' => $email, 'name' => getOrderName($order)]],
        'subject'    => 'Order #' . $order->getId() . ' confirmed',
        'body'       => renderOrderEmailTemplate($order),
        'list_id'    => UNISENDER_TRANSACT_LIST_ID,
        'sender_name'  => 'Store',
        'sender_email' => '[email protected]',
    ]);
});

Deliverability Analytics

UniSender provides statistics via getCampaignStatus and getCampaignCommonStats. Data is retrieved for each mailing and logged into a custom 1C-Bitrix info block for trend monitoring:

  • Open rate, CTR, bounces, unsubscribes.
  • If bounce rate exceeds 5%, the campaign is automatically paused and the marketing team is notified.
Task Effort
API client + subscription handlers 3–5 h
Bulk subscriber base export 3–4 h
Transactional emails on events 4–6 h
Analytics collection in 1C-Bitrix 3–4 h