• Resolved deano34

    (@deano34)


    Hi,

    I am seeking some more clarity on answer given to a couple of past questions about creating multiple Popups but having them rotate automatically. In past two requests the responses have been to use:
    https://docs.wppopupmaker.com/article/313-how-can-i-ab-test-or-randomly-display-popups

    This is fine for me and I have loaded the script into site and it “works” but not how I want it to and I think it is my basic lack of understanding what the script is doing and how I need to setup the Popups in Popup Maker and get the customization of the variables correct within the script. This is what I have done and what happens…..

    1. I have two popups and can see their Popup IDs (7560 and 7542) within the plugin.
    When inputting into the script is the following correct:
    var popups = [7560, 7542], // Comma separated popup IDs.
    ie. Do I leave the brackets as above ?
    2. The next variable is:
    cookie_name = ‘pum-split-test’, // Cookie name for the test only.
    What am I required to do with this variable, is it suffice to leave as is ?
    3. cookie_time = ‘1 month’, // Cookie timer.
    This is ok.

    After loading the script what is the behaviour I should expect when refreshing the page ? and after selecting Close on the popup ?
    What do I need to do with the PopUps themselves within Popup Maker by way of configuration for triggers and targets ?

    Any help appreciated.

    Peter

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Maria Togonon

    (@mariatogonon)

    Hello @deano34 – thanks for writing in and apologies for the delay.

    We will need to forward your concern to our lead developer and we will let you know as soon as we get a piece of new information.

    We appreciate your patience. Thank you!

    Plugin Author Daniel Iser

    (@danieliser)

    @deano34 – So that script is meant to allow split testing, in that scenario one you see Popup A, you would never be allowed to see Popup B as it would skew the test. So once any popup is opened in the above script the others won’t be. It is not a cycling popup script.

    It could be modified by removing the checks for cookies and such and then it would randomly show a different popup each time. You would need to avoid all cookies in that case.

    
    
    (function ($, document) {
    
        // Customize these variables.
        // ----------------------------------
        var popups = [163, 165], // Comma separated popup IDs
            // ------------------------------
            // End Customizations.
            chosen_popup = false; // Empty placeholder.
    
        function random_popup() {
            return popups[Math.floor(Math.random() * popups.length)];
        }
    
        function get_chosen_popup() {
            if ( ! chosen_popup ) {
                chosen_popup = random_popup();
            }
            
            return chosen_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 above skips the A/B selection and just picks a random popup from the list each time the page is loaded.

    Otherwise yes, leave the [] brackets, they denote a comma list inside.

    Hope that helps. If your issue is resolved please take a moment to rate and review the plugin or support.

    If you still need help please message us directly at https://wppopupmaker.com/support/.

    Thanks, great.

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