Setting up Advertising Block Rotation on 1C-Bitrix
Rotation is showing different banners in one position in sequence or by weights. In Bitrix, rotation is implemented in advertising module through contract and banner group mechanism. Without this module, rotation can be done in JavaScript or through custom PHP code.
Rotation through advertising module
Architecture: Contract (ad campaign) → Banner (specific ad) → Place (position on site). Show place is created with type (TEXT, HTML, BANNER) and tied to specific site zone.
Module tables:
-
b_adv_banner— banners with content, dates, show weights -
b_adv_contract— contracts (campaigns) with attached banners -
b_adv_type— show places -
b_adv_stat_day— daily statistics of banner shows and clicks
Component in template:
$APPLICATION->IncludeComponent('bitrix:advertising.banner', '.default', [
'TYPE' => 'main_slider', // symbolic code of show place
'SHOW_COUNT' => 1, // how many banners at once
'CACHE_TYPE' => 'N', // rotation + cache incompatible
]);
Cache for rotating blocks must be disabled (CACHE_TYPE = N) — otherwise all users see the same cached banner.
Weight-based rotation: mechanics
In b_adv_banner field WEIGHT determines probability of banner show. Banner with WEIGHT = 60 will show in about 60% of cases with two banners having total weight 100.
Module selects banner based on weighted random selection with each request. This creates database load on high traffic: each show is SELECT + INSERT in b_adv_stat_day. For high-load sites, show statistics better aggregated through queue or disabled if not needed.
Rotation without advertising module
If advertising module unavailable (old edition) or its capabilities sufficient, implement rotation through infoblock + JavaScript.
PHP side returns all active banners for position in JSON. JavaScript on client selects random (or next in queue) and displays:
class BannerRotator {
constructor(banners) {
this.banners = banners;
this.current = Math.floor(Math.random() * banners.length);
}
getNext() {
const banner = this.banners[this.current];
this.current = (this.current + 1) % this.banners.length;
return banner;
}
}
const rotator = new BannerRotator(window.bannerData['main_slider']);
// Show first banner, change every 5 seconds
setInterval(() => displayBanner(rotator.getNext()), 5000);
Banner data is output to JS variable through PHP in template. PHP component cache works this way — data is cached, rotation done on client.
A/B testing of banners
advertising module supports A/B testing by splitting traffic across contracts. Practically: create two banners in one group with 50/50 weights, view click statistics in /bitrix/admin/adv_stat.php after 7-14 days, keep winner.
For serious A/B testing with segmentation by devices, traffic sources and regions, built-in functionality not enough — need integration with Google Optimize or Optimizely. But for basic comparison of two banners, module is sufficient.
Show banners to specific audience
Contracts in advertising module can be set to show specific user groups (authorized/unauthorized), at specific times, under certain conditions. These settings stored in b_adv_banner in CONDITIONS field as serialized array.
For regional rotation — combine with regional determination from $_SESSION['USER_REGION'] and filter banners by region property before passing to rotator.







