Setting up QR codes for 1C-Bitrix marketing campaigns

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
    1212
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    815
  • 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
    565
  • 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
    980

Marketing Campaign QR Codes Setup in 1C-Bitrix

Marketing QR codes are not just a link in a square. Marketing QR solves a specific task: connect offline touchpoint (packaging, leaflet, banner, display) with online action (apply coupon, join loyalty program, participate in giveaway). Key difference from product QR — analytics: who, when, where scanned.

Architecture of Marketing QR

Marketing QR doesn't point directly to campaign page but to intermediate redirector with analytics. Scheme:

QR → https://shop.com/promo/qr/?c=SUMMER25&src=package_tea → (tracking) → /catalog/sale/

Parameters:

  • c — campaign code (tied to coupon or scenario)
  • src — placement source (packaging, leaflet, banner)
  • mid — material-specific ID (leaflet batch number)

This approach provides analytics without changing final page URL.

Storing Marketing QR in Bitrix

For managing marketing QR, create separate infoblock or table via ORM:

class MarketingQrTable extends \Bitrix\Main\ORM\Data\DataManager {
    public static function getTableName(): string {
        return 'custom_marketing_qr';
    }

    public static function getMap(): array {
        return [
            new Fields\IntegerField('ID', ['primary' => true, 'autocomplete' => true]),
            new Fields\StringField('CODE'),          // Unique QR code
            new Fields\StringField('NAME'),          // Campaign name
            new Fields\StringField('TARGET_URL'),    // Where to redirect
            new Fields\StringField('SOURCE'),        // Source type
            new Fields\DatetimeField('ACTIVE_FROM'),
            new Fields\DatetimeField('ACTIVE_TO'),
            new Fields\IntegerField('SCAN_COUNT'),   // Scan counter
            new Fields\BooleanField('IS_ACTIVE'),
        ];
    }
}

Redirector with Tracking

Controller processes QR transition:

class QrRedirectController extends \Bitrix\Main\Engine\Controller {

    public function trackAction(string $code, string $src = '', string $mid = ''): \Bitrix\Main\Engine\Response\Redirect {
        $qr = MarketingQrTable::getList([
            'filter' => ['=CODE' => $code, '=IS_ACTIVE' => true],
            'limit' => 1,
        ])->fetch();

        if (!$qr) {
            return new \Bitrix\Main\Engine\Response\Redirect('/404/');
        }

        // Check activity period
        $now = new \Bitrix\Main\Type\DateTime();
        if ($qr['ACTIVE_FROM'] && $qr['ACTIVE_FROM'] > $now) {
            return new \Bitrix\Main\Engine\Response\Redirect('/promo/soon/');
        }
        if ($qr['ACTIVE_TO'] && $qr['ACTIVE_TO'] < $now) {
            return new \Bitrix\Main\Engine\Response\Redirect('/promo/expired/');
        }

        // Log scan
        QrScanLogTable::add([
            'QR_ID' => $qr['ID'],
            'SOURCE' => $src,
            'MATERIAL_ID' => $mid,
            'IP' => $_SERVER['REMOTE_ADDR'],
            'USER_AGENT' => $_SERVER['HTTP_USER_AGENT'],
            'SCANNED_AT' => $now,
            'USER_ID' => $GLOBALS['USER']->GetID() ?: null,
        ]);

        // Increment counter
        MarketingQrTable::update($qr['ID'], [
            'SCAN_COUNT' => $qr['SCAN_COUNT'] + 1,
        ]);

        // Apply coupon if exists
        if (!empty($qr['COUPON_CODE'])) {
            \Bitrix\Main\Application::getInstance()->getSession()->set('QR_COUPON', $qr['COUPON_CODE']);
        }

        return new \Bitrix\Main\Engine\Response\Redirect($qr['TARGET_URL']);
    }
}

Integration with Bitrix Coupons

Powerful scenario: user scans QR from packaging → enters store → coupon applies automatically. Coupon is pre-created in Bitrix "Marketing" module (sale.discount):

// Apply coupon from session when opening cart
AddEventHandler('sale', 'OnSaleBasketBeforeSaved', function(&$params) {
    $session = \Bitrix\Main\Application::getInstance()->getSession();
    $qrCoupon = $session->get('QR_COUPON');

    if ($qrCoupon) {
        \CSaleDiscount::ApplyCoupon($qrCoupon);
        $session->remove('QR_COUPON');
    }
});

Batch QR Generation for Print

For offline materials, generate QR package:

function generateQrBatch(string $campaignCode, string $source, int $count): string {
    $zipPath = '/tmp/qr-' . $campaignCode . '.zip';
    $zip = new ZipArchive();
    $zip->open($zipPath, ZipArchive::CREATE);

    for ($i = 1; $i <= $count; $i++) {
        $mid = str_pad($i, 5, '0', STR_PAD_LEFT);
        $url = 'https://' . SITE_SERVER_NAME . '/promo/qr/?c=' . $campaignCode . '&src=' . $source . '&mid=' . $mid;

        $result = \Endroid\QrCode\Builder\Builder::create()
            ->data($url)
            ->size(600)
            ->build();

        $zip->addFromString('qr-' . $mid . '.png', $result->getString());
    }

    $zip->close();
    return $zipPath;
}

Analytics in Admin

Reports from scan logs:

  • Scans by source (which medium works best)
  • Conversion from scan to purchase
  • Time of day and weekday activity
  • Geo-distribution (by IP)

Data output in custom report in admin or exported to Google Data Studio.

Execution Timeline

Scope Timeline
Redirector + tracking + basic generation 1–2 days
Coupon integration + session logic +1 day
Batch generation + analytics +1–2 days

Marketing QR without tracking is money wasted. With tracking — manageable tool with measurable ROI.