> For the complete documentation index, see [llms.txt](https://wiki.playgama.com/playgama/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.playgama.com/playgama/playgama-ad/fallback-solution.md).

# Fallback Solution

The ad backfill mechanism helps maximize revenue by filling unsold impressions. Whenever an ad request through the platform ad SDK fails, you can display ads using **Playgama Ad**.

Supported Platforms:

* <img src="/files/gNXTaRBS5xk6tYhticVK" alt="" data-size="line"> [MSN](https://msn.com/en-us/play)

#### <mark style="background-color:purple;">Access</mark>

**Playgama Ad** is currently available in **open beta**, please contact us using the Contact Us form at [**https://playgama.com/adv**](https://playgama.com/adv).

### If you are using [Playgama Bridge](/playgama/bridge-sdk/getting-started.md)

The backfill mechanism is already built in. Use the [config editor](https://playgama.github.io/bridge-config-editor/) to add your IDs to `playgama-bridge-config.json`, and everything will run automatically.

* **gameId** is the identifier of your game on the third-party platform (for example, on MSN)
* **backfillId** is you personal partner identifier (playgama\_clid)

```
{
    "platforms": {
        ...,
        "msn": {
            "gameId": "<YOUR_GAME_ID>"
        }
    },
    "advertisement": {
        ...,
        "backfillId": "msn-bridge"
    }
}
```

### If you're not using Playgama Bridge

You will need to implement this logic yourself. To see an example of how it works, you can check the Playgama Bridge [source code](https://github.com/Playgama/bridge/blob/main/src/platform-bridges/MsnPlatformBridge.js).

#### Installation

For correct data attribution, you need to pass several IDs:

* **\<your-clid>** means you personal partner identifier (playgama\_clid);
* **\<game-identifier>** means the identifier of your game on the third-party platform (for example, on MSN).

```javascript
<script src="https://playgama.com/ads/msn.v0.1.js"></script>

// Initialize the SDK
await window.pgAds.init('<your-clid>');
window.pgAds.updateTargeting({ gameId: '<game-identifier>' });
```

#### **Show Interstitial**

```javascript
window.$msstart.loadAdsAsync(false)
    .then((msnAd) => window.$msstart.showAdsAsync(msnAd.instanceId))
    .catch(() => {
        const banner = await window.pgAds.requestOutOfPageAd('interstitial');
        
        if (banner.state === 'ready') {
            banner.show();
        } else if (banner.state === 'empty') {
             // No ad available
        } else {
            banner.addEventListener('ready', () => {
                banner.show();
            });
            banner.addEventListener('empty', () => {
                // No ad available
            });
        }
    });
```

#### **Show Rewarded**

```javascript
window.$msstart.loadAdsAsync(true)
    .then((msnAd) => window.$msstart.showAdsAsync(msnAd.instanceId))
    .catch(() => {
        const banner = await window.pgAds.requestOutOfPageAd('rewarded');

        if (banner.state === 'ready') {
            banner.show();
        } else if (banner.state === 'empty') {
             // No ad available
        } else {
            banner.addEventListener('ready', () => {
                banner.show();
            });
            banner.addEventListener('empty', () => {
                // No ad available
            });
        }
        
        banner.addEventListener('rewarded', () => {
            console.log('Grant reward to user');
        });
    });
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.playgama.com/playgama/playgama-ad/fallback-solution.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
