# プレイアブル広告のベストプラクティス

> Unity Ads User Acquisition を使用したプレイアブルクリエイティブの推奨ベストプラクティスを確認します。

プレイアブルアセットを設定する際は、以下について考慮してください。

### mraid.open##mraid

ユーザーがクリックするとリダイレクトされるようにするには、ゲームのアプリストアページの URL 文字列を指定して `mraid.open` メソッドを使用します。

```plaintext
case "Android":mraid.open("https://play.google.com/store/apps/details?id=yourgame"); break;

case "iOS":mraid.open("https://itunes.apple.com/us/yourgame?mt=8");
```

### ブートストラップ##bootstrap

プレイアブル広告の初期化方法を示す以下の例について考えてみましょう。

```cs
// Wait for the SDK to become ready: 
function Start() {
    if (mraid.getState()==='loading') {
        // If the SDK is still loading, add a listener for the 'ready' event:
        mraid.addEventListener('ready', onSdkReady);
        // Otherwise, if the SDK is ready, execute your function:
    } else {
        onSdkReady(); 
    }
}

// Implement a function that shows the ad when it first renders:
function onSdkReady() {
    // The viewableChange event fires if the ad container's viewability status changes.
    // Add a listener for the viewabilityChange event, to handle pausing and resuming:
    mraid.addEventListener('viewableChange',viewableChangeHandler);
	// The isViewable method returns whether the ad container is viewable on the screen.
    if (mraid.isViewable()) {
        // If the ad container is visible, play the ad:
        showMyAd(); 
    }
}

// Implement a function for executing the ad:
function showMyAd() {
    // Insert code for showing your playable ad.
}

// Implement a function that handles pausing and resuming the ad based on visibility:
function viewableChangeHandler(viewable) {
    if(viewable) {
        // If the ad is viewable, show the ad:
        showMyAd(); 
    } else {
        // If not, pause the ad.
    }
}
```

> **Note:**
>
> * Unity Ads SDK は広告のスキップ機能をコントロールします。
> * アプリストアへの自動リダイレクトは使用しないでください。広告では、自動的に、またはユーザーの最初のタッチによってアプリストアが開かない場合があります。
> * 開始、ビュー、クリックのアトリビューションはサーバー側で行われます。
