# Ad Slot Complete Event

Source: https://docs.ezoic.com/docs/ezoicadsadvanced/slot-complete-event/


The `ezSlotComplete` event lets your site respond when Ezoic has finished an ad slot's current loading lifecycle.

This is useful when your layout needs to react after Ezoic has either filled a placement or stopped trying to fill it. For example, you may want to hide a surrounding wrapper when a placement is not filled.

## Listening for the event

Add a listener to `document`:

```javascript
document.addEventListener("ezSlotComplete", function (event) {
    if (event.detail.placeholderId !== 123) {
        return;
    }

    var wrapper = document.getElementById("ad-wrapper-123");

    if (event.detail.filled) {
        // Placeholder 123 was filled.
        if (wrapper) {
            wrapper.style.display = "";
        }
    } else {
        // Placeholder 123 did not fill.
        if (wrapper) {
            wrapper.style.display = "none";
        }
    }
});
```

## When the event fires

`ezSlotComplete` fires after Ezoic has finished processing a slot for the current load or refresh lifecycle.

- If `event.detail.filled` is `true`, Ezoic filled the slot.
- If `event.detail.filled` is `false`, Ezoic has stopped trying to fill that slot for the current lifecycle. In this case, it is safe to hide your own surrounding layout for that slot.

The event does not fire while Ezoic is still retrying the slot.


Hide your own wrapper or surrounding layout, not the Ezoic placeholder element itself. The placeholder element should remain available for future Ezoic calls, refreshes, or dynamic content behavior.


## Example: hide an unfilled slot wrapper

Use a publisher-owned wrapper around the Ezoic placeholder:

```html
<div id="ad-wrapper-123">
    <div id="ezoic-pub-ad-placeholder-123"></div>
</div>
```

Then hide the wrapper if Ezoic finishes the slot without a fill:

```javascript
document.addEventListener("ezSlotComplete", function (event) {
    if (event.detail.placeholderId !== 123) {
        return;
    }

    var wrapper = document.getElementById("ad-wrapper-123");

    if (!wrapper) {
        return;
    }

    if (event.detail.filled) {
        wrapper.style.display = "";
    } else {
        wrapper.style.display = "none";
    }
});
```

If you call `ezstandalone.showAds()` or refresh the same placeholder again later, make sure your wrapper is visible before the next ad request. The `filled: true` branch above restores the wrapper for that case.

## Event details

The event is a browser `CustomEvent`. The payload is available on `event.detail`.

| Field | Type | Description |
|---|---|---|
| `placeholderId` | number | The Ezoic placeholder ID associated with the slot. |
| `filled` | boolean | `true` when Ezoic filled the slot; `false` when Ezoic stopped trying to fill it for the current lifecycle. |
| `reason` | string | `"filled"` or `"no_fill"`. |
| `slotId` | string | The rendered ad slot element ID, when available. |
| `adUnitPath` | string | The Google Ad Manager ad unit path, when available. |
| `positionType` | number | The Ezoic position type for the slot. |
| `isAnchor` | boolean | Whether the slot is an Ezoic anchor slot. |

## Anchor ads

Some anchor ads are owned and managed by Google. Ezoic does not send `ezSlotComplete` for those Google-owned anchors, because publisher code should not hide or remove layout that Google manages.

Ezoic-owned slots, including Ezoic-owned anchors, can emit `ezSlotComplete` when their current lifecycle finishes.

