> For the complete documentation index, see [llms.txt](https://docs.exads.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.exads.com/publishers/sites-and-zones/fpi-popunder-capping-option.md).

# Manage Capping for Popunders and Fullpage Interstitials

As a Publisher, when you create or edit a Popunder, Desktop Fullpage Interstitial, or Mobile Fullpage Interstitial zone, you can enable or disable **capping** for your ad zone. With this option, you can manage capping (display frequency) on your own side.

**Supported Ad Formats:** Popunder, Mobile Popunder, Desktop Fullpage Interstitial, Mobile Fullpage Interstitial.

## Setting Up <a href="#setting-up" id="setting-up"></a>

### Step 1: Enable/Disable Capping Through the Snippet <a href="#step-1-enabledisable-capping-through-the-snippet" id="step-1-enabledisable-capping-through-the-snippet"></a>

Disable the capping on the Popunder snippet. Only the `adConfig` block is shown below — copy the full tag from your zone's tag page in the Admin Panel and set **capping\_enabled** or **ad\_capping\_enabled** to `false`.

{% code overflow="wrap" expandable="true" %}

```html
<script type="application/javascript">
(function() {
    //version 12.0.0

    var adConfig = {
    "ads_host": "a.examplesite.com",
    "syndication_host": "syndication.examplesite.com",
    "idzone": XXX, // Replace XXX with zone id
    "popup_fallback": false,
    "popup_force": false,
    "chrome_enabled": true,
    "new_tab": false,
    "frequency_period": 720,
    "frequency_count": 1,
    "trigger_method": 3,
    "trigger_class": "",
    "trigger_delay": 0,
    "capping_enabled": false, // set this to false
    "tcf_enabled": false,
    "agego_cross_site_enabled": true,
    "only_inline": false
};
    // Ad script runtime from the generated tag goes here, unchanged
})();
</script>
```

{% endcode %}

{% code overflow="wrap" expandable="true" %}

```html
<script type="application/javascript">
    var ad_idzone = "XXX", // Replace XXX with zone id
    ad_popup_fallback = false,
    ad_popup_force = false,
    ad_chrome_enabled = true,
    ad_new_tab = false,
    ad_frequency_period = 720,
    ad_frequency_count = 1,
    ad_trigger_method = 3,
    ad_trigger_delay = 0,
    ad_capping_enabled = false; // set this to false
</script>
<script type="application/javascript" src="https://a.examplesite.com/popunder1000.js"></script>
```

{% endcode %}

{% hint style="info" %}
**Note**: Complete Step 2 and Step 3 to ensure the ad is not triggered on every click.
{% endhint %}

### Step 2: Setting Up Event Listener <a href="#step-2-setting-up-event-listener" id="step-2-setting-up-event-listener"></a>

Set up the event listener for the `creativeDisplayed` event so that you can store and increment the capping counter on your own side.

{% hint style="info" %}
For Popunder zones you can use the `on_redirect` callback instead of this event listener. See [using the should\_fire callback](#using-the-should_fire-callback) below.
{% endhint %}

{% code overflow="wrap" expandable="true" %}

```html
<script type="application/javascript">
        document.addEventListener(
            'creativeDisplayed-XXX', // Replace XXX with zone id
            function(e) {
 //Code to increment the display counter goes here. Below is just an example
                 const name = 'popunder-capping';
                 let match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
                 let counter = match ? parseInt(match[2], 10) : 0;
                 ++counter;
                 document.cookie = name + "=" + counter + "; path=/";
            }
        );
    </script>
```

{% endcode %}

### Step 3: Managing the Page DOM <a href="#step-3-managing-the-page-dom" id="step-3-managing-the-page-dom"></a>

Based on the value of the counter, which you can store in any way, exclude the snippet from the page DOM. You can do this on the front end or the back end; both examples follow.

**FE Example:**

{% code expandable="true" %}

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Example page</title>
</head>
<body>
<script type="application/javascript">
    let name = 'popunder-capping';
    let match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
    let counter = match ? parseInt(match[2], 10) : 0;
    let maxCount = 5;
    if (counter < maxCount) {
        // Paste the full Inline + Remote Script snippet for your zone here,
        // taken from the zone's tag page in the Admin Panel,
        // with "capping_enabled" set to false.
    }
</script>
<a href="https://www.example.com">Visit example.com!</a>
<script type="application/javascript">
    document.addEventListener('creativeDisplayed-XXX', function(e) { // Replace XXX with zone id
        ++counter;
        document.cookie = name + "=" + counter + "; path=/";
    });
</script>
</body>
</html>
```

{% endcode %}

**BE Example:**

{% code expandable="true" %}

```php
<?php
$counter = $_COOKIE['popunder-capping'] ?? 0;
?>
<html>
<head><title>Example page</title></head>
<body>
<?php
if ($counter < 5) :
?>
    <script type="application/javascript">
        // Paste the full Inline + Remote Script snippet for your zone here,
        // taken from the zone's tag page in the Admin Panel,
        // with "capping_enabled" set to false.

        document.addEventListener(
            'creativeDisplayed-XXX', // Replace XXX with zone id
            function(e) {
                const name = 'popunder-capping';
                let match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
                let counter = match ? parseInt(match[2], 10) : 0;
                ++counter;
                document.cookie = "popunder-capping=" + counter + "; path=/";
            }
        );
    </script>
<?php
endif;
?>
<a href="https://www.example.com">Visit example.com!</a>
</body>
</html>
```

{% endcode %}

## Using the should\_fire callback

Instead of keeping the snippet out of the page DOM, you can leave the tag in place and decide on each click whether the ad should be served. When capping is disabled, the ad is only served if your callback returns true.

{% hint style="info" %}
The callback can only suppress the ad, not allow extra displays: with capping disabled the ad is still served at most once per page load. `on_redirect` is available on Popunder only; Fullpage Interstitial zones use the `creativeDisplayed` listener from Step 2 to count displays.
{% endhint %}

### Popunder

**Inline + Remote Script**

{% code expandable="true" %}

```html
<script type="application/javascript">
(function() {
    //version 12.0.0

    function myCappingCheck() {
        let name = 'popunder-capping';
        let match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
        let counter = match ? parseInt(match[2], 10) : 0;
        return counter < 5;
    }

    var adConfig = {
    "ads_host": "a.examplesite.com",
    "syndication_host": "syndication.examplesite.com",
    "idzone": XXX, // Replace XXX with zone id
    "popup_fallback": false,
    "popup_force": false,
    "chrome_enabled": true,
    "new_tab": false,
    "frequency_period": 720,
    "frequency_count": 1,
    "trigger_method": 3,
    "trigger_class": "",
    "trigger_delay": 0,
    "capping_enabled": false,
    "tcf_enabled": false,
    "agego_cross_site_enabled": true,
    "only_inline": false,
    "should_fire": myCappingCheck,
    "on_redirect": function () {
        let name = 'popunder-capping';
        let match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
        let counter = match ? parseInt(match[2], 10) : 0;
        document.cookie = name + "=" + (++counter) + "; path=/";
    }
};
    // Ad script runtime from the generated tag goes here, unchanged
})();
</script>
```

{% endcode %}

**Remote Script Only**

{% code expandable="true" %}

```html
<script type="application/javascript">
    var ad_idzone = "XXX", // Replace XXX with zone id
    ad_popup_fallback = false,
    ad_popup_force = false,
    ad_chrome_enabled = true,
    ad_new_tab = false,
    ad_frequency_period = 720,
    ad_frequency_count = 1,
    ad_trigger_method = 3,
    ad_trigger_delay = 0,
    ad_capping_enabled = false;

    var ad_should_fire = function () {
        let name = 'popunder-capping';
        let match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
        let counter = match ? parseInt(match[2], 10) : 0;
        return counter < 5;
    };

    var ad_on_redirect = function () {
        let name = 'popunder-capping';
        let match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
        let counter = match ? parseInt(match[2], 10) : 0;
        document.cookie = name + "=" + (++counter) + "; path=/";
    };
</script>
<script type="application/javascript" src="https://a.examplesite.com/popunder1000.js"></script>
```

{% endcode %}

### Desktop and Mobile Fullpage Interstitial

On the asynchronous tag, pass the name of your function in the data-should-fire attribute rather than the function itself. The function must be defined on the page before the tag runs.

{% code expandable="true" %}

```html
<script type="application/javascript">
    function myCappingCheck() {
        let name = 'popunder-capping';
        let match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
        let counter = match ? parseInt(match[2], 10) : 0;
        return counter < 5;
    }
</script>

<script async type="application/javascript" src="https://a.examplesite.com/ad-provider.js"></script>
<ins class="adsbynetwork" data-zoneid="XXX" data-should-fire="myCappingCheck"></ins>
<script>(AdProvider = window.AdProvider || []).push({"serve": {}});</script>
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.exads.com/publishers/sites-and-zones/fpi-popunder-capping-option.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
