---
title: "Randomly Rotate Popups on a Page - EngageBox"
description: "Show just one popup from a group at random—ideal for testing variations or keeping your page clean without overwhelming visitors."
url: "https://www.tassos.gr/docs/engagebox/functionality/random-rotate-popups"
date: "2026-04-21T07:55:14+00:00"
language: "en-GB"
---

[ Home ](https://www.tassos.gr/index.php?option=com_content&view=category&layout=blog&id=24&Itemid=1088) / [ EngageBox ](https://www.tassos.gr/index.php?option=com_content&view=category&id=35) / [ Functionality ](https://www.tassos.gr/index.php?option=com_content&view=category&id=52)

#  Randomly Rotate Popups on a Page

##  Show just one popup from a group at random—ideal for testing variations or keeping your page clean without overwhelming visitors.

Want to display only one of several popups on a page, selected at random? Whether you’re experimenting with different content or simply trying to avoid showing multiple popups at once, there’s a simple way to control this behavior. While EngageBox doesn’t offer built-in A/B testing, you can replicate this logic using a short script.

## [Steps](#steps)

First, publish all the popups you want to include in the rotation. Ensure they’re **assigned to the same page** so they’re all loaded and available for selection.

Next, add the following JavaScript to your site:

 ```
EngageBox.onReady(() => {
    // Array of popup IDs we want to manage
    const popups = [3, 4, 5];

    // Randomly select one popup ID from the array
    const randomId = popups[Math.floor(Math.random() * popups.length)];

    // Iterate through all popup IDs
    popups.forEach(popupId => {

        // Skip the randomly selected popup ID
        // This popup will be allowed to display normally
        if (popupId === randomId) {
            return;
        }

        // Get the EngageBox instance for the current popup ID
        const popup = EngageBox.getInstance(popupId);

        // If the popup instance doesn't exist, skip to the next one
        if (popup === undefined) {
            return;
        }

        // Add an event listener for the 'beforeOpen' event
        // and prevent the popup from opening
        popup.on('beforeOpen', () => {
            return false;
        });
    });
});

```

## [Notes](#notes)

- **All popups must be published on the same page** for this method to work. If a popup is not loaded on the page, it won’t be available for EngageBox to control.
- **You can use any of the supported trigger points**—On Page Load, Exit Intent, Scroll, Click, etc. It does not matter. The script will still prevent non-selected popups from opening.
- **There is no limit to the number of popups** you can include in the random rotation. Simply add all the popup IDs to the popupIds array.
- This approach does not offer built-in tracking or conversion statistics but provides a simple way to rotate content without showing everything at once.

 Last updated on May 15th 2025 09:05

## Schema

```json
{
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "itemListElement": [
        {
            "@type": "ListItem",
            "position": 1,
            "name": "Home",
            "item": "https://www.tassos.gr"
        },
        {
            "@type": "ListItem",
            "position": 2,
            "name": "Home",
            "item": "https://www.tassos.gr/docs"
        },
        {
            "@type": "ListItem",
            "position": 3,
            "name": "EngageBox",
            "item": "https://www.tassos.gr/docs/engagebox"
        },
        {
            "@type": "ListItem",
            "position": 4,
            "name": "Functionality",
            "item": "https://www.tassos.gr/docs/engagebox/functionality"
        },
        {
            "@type": "ListItem",
            "position": 5,
            "name": "Randomly Rotate Popups on a Page",
            "item": "https://www.tassos.gr/docs/engagebox/functionality/random-rotate-popups"
        }
    ]
}
```

```json
{
    "@context": "https://schema.org",
    "@type": "Article",
    "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "https://www.tassos.gr/docs/engagebox/functionality/random-rotate-popups"
    },
    "headline": "Randomly Rotate Popups on a Page",
    "description": "Show just one popup from a group at random—ideal for testing variations or keeping your page clean without overwhelming visitors.",
    "image": {
        "@type": "ImageObject",
        "url": "https://www.tassos.gr/"
    },
    "publisher": {
        "@type": "Organization",
        "name": "Tassos",
        "logo": {
            "@type": "ImageObject",
            "url": "https://www.tassos.gr/https://www.tassos.gr/media/brand/logo-text.png"
        }
    },
    "author": {
        "@type": "Person",
        "name": "Tassos Marinos",
        "url": "https://www.tassos.gr/docs/engagebox/functionality/random-rotate-popups"
    },
    "datePublished": "2025-05-15T09:32:19+03:00",
    "dateCreated": "2025-05-15T09:32:19+03:00",
    "dateModified": "2025-05-15T09:51:22+03:00"
}
```
