jQuery(document).ready(function($) { // Konfiguracja Twojego testu A/B
const popups = [1726, 1722], // Twoje ID popupów
cookieName = 'pum-ab-test-1726-1722', // Unikalna nazwa ciasteczka
cookieTime = '1 month'; // Czas pamiętania wyboru let chosenPopup = false; function randomPopup() {
return popups[Math.floor(Math.random() * popups.length)];
} function getChosenPopup() {
let popup;
let cookie; if ($.pm_cookie === undefined) {
return 0;
} cookie = parseInt($.pm_cookie(cookieName)) || false; if (cookie > 0 && popups.indexOf(cookie) !== -1) {
popup = cookie;
} else if (!cookie) {
popup = randomPopup();
$.pm_cookie(cookieName, popup, cookieTime, '/');
} return popup;
} $(document).on('pumInit', '.pum', function() {
const $this = $(this);
const popupId = $this.popmake('getSettings').id; if (!chosenPopup) {
chosenPopup = getChosenPopup();
} // Jeśli to popup z testu, ale nie ten wylosowany - zablokuj go
if (popups.indexOf(popupId) >= 0 && popupId !== chosenPopup) {
$this.addClass('preventOpen');
} else {
$this.removeClass('preventOpen');
}
}); });