> 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/tutorials/it/tutorial/tutorial-per-editori/esempi-di-reindirizzamento-popunder.md).

# Esempi di reindirizzamento Popunder

La seguente pagina elenca una serie di casi d'uso in cui puoi usare il **URL Redirect Popunder** formato del popunder per attivare l'annuncio in determinate condizioni.

## Servire i popunder sotto Adblock

Assumendo che tu non voglia usare il **Inline + Remote Script** versione del popunder, puoi seguire questi passaggi:

{% stepper %}
{% step %}
Crea un `.js` file chiamato `ads.js` contenente il seguente codice:

```js
isAdblockActive = false;
```

{% endstep %}

{% step %}
Crea un altro file chiamato `domains.js` contenente il seguente codice:

```js
let storedDomain = null;
fetch("https://ads.exoclick.com/adblock-domains.php")
  .then(r => {
    if (!r.ok) {
      throw new Error("La risposta di rete non era valida (" + r.status + ")");
    }
    return r.json();
  })
  .then(data => {
    if (data.success && data.domain) {
      storedDomain = data.domain;
    } else {
      logError("L'API ha restituito un errore: " + (data.message || "Errore sconosciuto"));
    }
  })
  .catch(err => {
    logError("La fetch è fallita: " + err.message);
  });
```

{% endstep %}

{% step %}
Inserisci entrambi i file sul server del tuo sito web. Poi, nell'HTML del tuo sito, aggiungi quanto segue:

```html
<script type="text/javascript">var isAdBlockActive=true;</script>
<script type="text/javascript" src="domains.js"></script>
<script type="text/javascript" src="ads.js" ></script>
<a id="rd" href="#" target="_blank">Redirect Domain</a>
<script>
var link = document.getElementById('rd');
link.addEventListener("click", function (){
	if (isAdBlockActive) {
	window.location.replace("https://" + storedDomain + "/v1/link.php?cat=&idzone=XXXXX&type=8&block=1");
      } else {
    window.location.replace("https://s.pemsrv.com/v1/link.php?cat=&idzone=XXXXX&type=8");
      }
});
</script>
```

Il Redirect Popunder si attiverà quando l'utente farà clic sul link con id `rd`. Poi, se Adblock è abilitato nel browser, `isAdBlockActive` verrà impostato su true perché `ads.js` verrà bloccato, consentendo al popunder di redirect di usare il dominio Adblock dinamico recuperato da `domains.js`. Il `&block=1` parametro consente al popunder di registrare il traffico come Adblock.
{% endstep %}
{% endstepper %}

## Servire annunci SFW

Il `ex_av` e `block_ad_types` I parametri possono essere aggiunti al Redirect Domain Popunder per registrare l'utente come qualcuno che ha o non ha superato la verifica dell'età e per bloccare gli annunci NSFW.

Il seguente codice si basa su [**Come servire annunci SFW con ExoClick**](/tutorials/it/tutorial/tutorial-per-editori/serve-sfw-ads.md) e carica il Redirect Domain Popunder a seconda che l'utente abbia il `userVerified` cookie, impostato una volta che l'utente ha superato la verifica dell'età.

```html
<a id="rd" href="#" target="_blank">Redirect Domain</a>
<script>
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
const link = document.getElementById('rd');
const verifiedUser = getCookie("verified_user");
link.addEventListener("click", function (){
  if (verifiedUser === "yes") {
    window.location.replace("https://s.pemsrv.com/v1/link.php?cat=&idzone=XXXXX&type=8&ex_av=1");
    }
  altrimenti {
    window.location.replace("https://s.pemsrv.com/v1/link.php?cat=&idzone=XXXXX&type=8&ex_av=2&blocked_ad_types=101");)
  }
});
</script>
```

## Blocca le campagne con etichette specifiche quando il sito web ha un parametro specifico nel suo URL

Il seguente codice si basa su [**Come bloccare dinamicamente i tipi di annunci usando data-block-ad-types**](/tutorials/it/tutorial/tutorial-per-editori/dynamically-block-ads-using-data-block-ad-types.md) e legge il valore da un parametro specifico dell'URL in cui verrà caricato il popunder. Questo può essere utile per i publisher che identificano le proprie fonti di traffico usando un parametro specifico.

In questo esempio, stiamo cercando un parametro chiamato `utm_source` e l'etichetta che andremo a bloccare è **Falsi positivi verificati**:

```html
<a id="rd" href="#" target="_blank">Redirect Domain</a>
<script>
const link = document.getElementById('rd');
const pb = new URLSearchParams(window.location.search).get("utm_source");
link.addEventListener("click", function (){
  if (pb === YYYYYYYYYYY) { // YYYYY corrisponde a qualunque valore il publisher usi per identificare la fonte di traffico in cui vogliamo applicare questo blocco
    window.location.replace("https://s.pemsrv.com/v1/link.php?cat=&idzone=XXXXX&type=8&blocked_ad_types=98");
    }
  altrimenti {
    window.location.replace("https://s.pemsrv.com/v1/link.php?cat=&idzone=XXXXX&type=8");)
  }
});
</script>
```


---

# 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/tutorials/it/tutorial/tutorial-per-editori/esempi-di-reindirizzamento-popunder.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.
