> For the complete documentation index, see [llms.txt](https://docs.exoclick.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.exoclick.com/advertisers/ja/kyanpn/iframe-events.md).

# iframeイベント

広告主は、広告内のイベントをトラッキングできます。これらのイベントは、JavaScriptの助けを借りてクライアントのブラウザ内で直接プログラム的に管理されます。

## イベント

### creativeDisplayed

{% hint style="info" %}
これは次の場合にのみ利用できます **デスクトップ フルページ インタースティシャル** と **モバイル フルページ インタースティシャル** (*DFPI/MFPI*）広告フォーマットのキャンペーンで **iframeのURL** バリエーション。
{% endhint %}

広告がユーザーに表示されると、という名前の iframe にメッセージが送信されます `creativeDisplayed`.

以下のスクリプトを使用して、このイベントを iframe 内でトラッキングできます。これにより、広告がユーザーに表示された際に送信されたメッセージを捕捉するイベントリスナーが追加されます。

```html
<script>
        function readMessage(event) {
            console.log("readMessage イベント");
            console.log("オリジン: " + event.origin);
            console.log("データ: " + event.data);
        }

        if (window.addEventListener) {
            // 標準準拠のウェブブラウザ向け
            window.addEventListener("message", readMessage, false);
        } else {
            window.attachEvent("onmessage", readMessage);
        }
</script>
```

## 例 - フルページ インタースティシャル

```html
<!DOCTYPE html>
<html>
<head>
    <!-- イベント部分 -->
    <script>
        function readMessage(event) {
            console.log("readMessage イベント");
            console.log("オリジン: " + event.origin);
            console.log("データ: " + event.data);
            var message = "メッセージを受信しました: '" + event.data + "' から '" + event.origin + "' （現在、広告主の iframe 内です）";
            console.log(message);
            document.getElementById("received-message").innerHTML = message;
            // IE では、広告主が何らかの要素を更新したい場合
        }
        if (window.addEventListener) {
            // 標準準拠のウェブブラウザ向け
            window.addEventListener("message", readMessage, false);
        } else {
            window.attachEvent("onmessage", readMessage);
        }
    </script>
    <!-- イベント部分の終了 -->
</head>
<body>
    <h1>テスト用 iframe の見出し</h1>
    <p>テスト用 iframe の段落</p>
    <p id="received-message">メッセージを待機中</p>
</body>
</html>
```

<figure><img src="/files/38dc99d3faf07959ac657f1e3b416537f47c61b1" alt=""><figcaption></figcaption></figure>


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.exoclick.com/advertisers/ja/kyanpn/iframe-events.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
