# 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:&#x20;

* <img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2FAyXsmbtkfDO8XRh2zBF4%2FimagesMSN.jpeg?alt=media&#x26;token=883b926a-9720-4fd0-99ff-1505fd7d73bc" 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](https://wiki.playgama.com/playgama/sdk/getting-started)

The backfill mechanism is already built in. All you need to do is provide your IDs in the `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');
        });
    });
```
