Support » Plugin: Popup Maker - Popup for opt-ins, lead gen, & more » Randomly view doesn’t work

  • Resolved artursandmedia

    (@artursandmedia)


    Hi, I’m having trouble configuring random popups. I have the free version, what am I doing wrong?

    By Custom CSS & JS Plugin, i added such code to the page:

    jQuery(document).ready(function( $, document ){
    
        // Customize these variables.
        // ----------------------------------
        var popups = [3532, 3527], // Comma separated popup IDs.
            cookie_name = 'pum-split-test', // Cookie name for the test only.
            cookie_time = '1 second', // Cookie timer.
            // ------------------------------
            // End Customizations.
            chosen_popup = false; // Empty placeholder.
    
        function random_popup() {
            return popups[Math.floor(Math.random() * popups.length)];
        }
    
        function get_chosen_popup() {
            var popup,
                cookie;
    
            if ($.pm_cookie === undefined) {
                return 0;
            }
    
            cookie = parseInt($.pm_cookie(cookie_name)) || false;
    
            // If the cookie contains a value use it.
            if (cookie > 0 && popups.indexOf(cookie) !== -1) {
                popup = cookie;
            } else if (!cookie) {
                popup = random_popup();
                $.pm_cookie(cookie_name, popup, cookie_time, '/');
            }
    
            return popup;
        }
    		
        // Prevent non chosen popups from opening.
        $(document).on('pumBeforeOpen', '.pum', function () {
            var $this = $(this),
                ID = $this.popmake('getSettings').id;
    
            if (!chosen_popup) {
                chosen_popup = get_chosen_popup();
            }
    
            if (popups.indexOf(ID) >= 0 && ID !== chosen_popup) {
                $this.addClass('preventOpen');
            } else {
                $this.removeClass('preventOpen');
            }
        });
    
    (jQuery, document));
    });

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.