> 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/es/campanas/iframe-events.md).

# Eventos de iframe

Los anunciantes pueden rastrear eventos en sus anuncios. Estos eventos se gestionan programáticamente directamente en el navegador del cliente con la ayuda de JavaScript.

## Eventos

### creativeDisplayed

{% hint style="info" %}
Esto solo está disponible para **Interstitial de página completa para escritorio** y **Interstitial de página completa para móvil** (*DFPI/MFPI*) campañas de formato de anuncio con **URL del iframe** variación.
{% endhint %}

Cuando el anuncio se muestra al usuario, se envía un mensaje al iframe llamado `creativeDisplayed`.

Puedes rastrear este evento dentro de tu iframe usando el siguiente script, que agrega un detector de eventos para capturar el mensaje enviado una vez que el anuncio se muestra al usuario.

```html
<script>
        function readMessage(event) {
            console.log("evento readMessage");
            console.log("origen: " + event.origin);
            console.log("datos: " + event.data);
        }

        if (window.addEventListener) {
            // Para navegadores web compatibles con los estándares
            window.addEventListener("message", readMessage, false);
        } else {
            window.attachEvent("onmessage", readMessage);
        }
</script>
```

## Ejemplo - Interstitial de página completa

```html
<!DOCTYPE html>
<html>
<head>
    <!-- PARTE DEL EVENTO -->
    <script>
        function readMessage(event) {
            console.log("evento readMessage");
            console.log("origen: " + event.origin);
            console.log("datos: " + event.data);
            var message = "Recibimos el mensaje: '" + event.data + "' de '" + event.origin + "' (ahora estamos en el iframe del anunciante)";
            console.log(message);
            document.getElementById("received-message").innerHTML = message;
            // el anunciante de ie quiere actualizar algún elemento
        }
        if (window.addEventListener) {
            // Para navegadores web compatibles con los estándares
            window.addEventListener("message", readMessage, false);
        } else {
            window.attachEvent("onmessage", readMessage);
        }
    </script>
    <!-- FIN DE LA PARTE DEL EVENTO -->
</head>
<body>
    <h1>Mi encabezado de prueba del iframe</h1>
    <p>Mi párrafo de prueba del iframe</p>
    <p id="received-message">Esperando el mensaje</p>
</body>
</html>
```

<figure><img src="/files/7a4023025dc2ac4477efbb07cf03a9492542e959" 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/es/campanas/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.
