Questo riferimento utilizza la notazione TypeScript per descrivere i tipi. La tabella seguente fornisce una breve spiegazione con esempi.
Digita l'espressione | |
---|---|
string |
Il tipo di stringa primitiva. |
string[] |
Un tipo di array in cui i valori possono essere solo stringhe. |
number | string |
Un tipo unione, in cui il valore può essere un numero o una stringa. |
Array<number | string> |
Un tipo di array in cui i valori sono di tipo complesso (unione). |
[number, string] |
Un tipo di tupla, in cui il valore è un array di due elementi che deve contenere un numero e una stringa in questo ordine. |
Slot |
Un tipo di oggetto, il cui valore è un'istanza di googletag.Slot . |
() => void |
Un tipo di funzione senza argomenti definiti e senza valore restituito. |
Per scoprire di più sui tipi e sulle espressioni di tipo supportati, consulta il Manuale di TypeScript .
Annotare i tipi
Un due punti dopo una variabile, un nome parametro, un nome proprietà o la firma di una funzione indica un'annotazione del tipo. Le annotazioni di tipo descrivono i tipi che l'elemento a sinistra del due punti può accettare o restituire. La tabella seguente mostra esempi di annotazioni di tipo che potresti trovare in questo riferimento.
Annotazione del tipo | |
---|---|
param: string |
Indica che param accetta o restituisce un valore di stringa. Questa sintassi viene utilizzata per variabili, parametri, proprietà e tipi di restituzione.
|
param?: number | string |
Indica che param è facoltativo, ma accetta un numero o una stringa
se specificato. Questa sintassi viene utilizzata per i parametri e le proprietà.
|
...params: Array<() => void> |
Indica che params è un
parametro rest
che accetta funzioni. I parametri REST accettano un numero illimitato di valori del
tipo specificato.
|
googletag
Spazi dei nomi | |
---|---|
config | Interfaccia di configurazione principale per le impostazioni a livello di pagina. |
enums | Questo è lo spazio dei nomi utilizzato da GPT per i tipi di enum. |
events | Questo è lo spazio dei nomi utilizzato da GPT per gli eventi. |
secure | Questo è lo spazio dei nomi utilizzato da GPT per gestire gli indicatori sicuri. |
Interfacce | |
---|---|
Command | L'array di comandi accetta una sequenza di funzioni e le richiama in ordine. |
Companion | Servizio Annunci companion. |
Privacy | Oggetto di configurazione per le impostazioni della privacy. |
Pub | Servizio Annunci del publisher. |
Response | Un oggetto che rappresenta una singola risposta all'annuncio. |
Rewarded | Un oggetto che rappresenta il premio associato a un annuncio con premio. |
Safe | Oggetto di configurazione per i contenitori SafeFrame. |
Service | Classe di servizio di base che contiene metodi comuni a tutti i servizi. |
Size | Generatore di oggetti delle specifiche di mappatura delle dimensioni. |
Slot | Slot è un oggetto che rappresenta una singola area annuncio in una pagina. |
Alias del tipo | |
---|---|
General | Una configurazione delle dimensioni valida per uno spazio, che può essere una o più dimensioni. |
Multi | Un elenco di singole dimensioni valide. |
Named | Dimensioni con nome che uno slot può avere. |
Single | Una singola dimensione valida per uno spazio. |
Single | Array di due numeri che rappresentano [larghezza, altezza]. |
Size | Una mappatura delle dimensioni dell'area visibile alle dimensioni degli annunci. |
Size | Un elenco di mappature delle dimensioni. |
Variabili | |
---|---|
api | Indica che l'API GPT è caricata e pronta per essere chiamata. |
cmd | Riferimento alla coda di comandi globale per l'esecuzione asincrona delle chiamate relative a GPT. |
pubads | Flag che indica che PubAdsService è attivato, caricato e completamente operativo. |
secure | Riferimento all'array dei fornitori di indicatori sicuri. |
Funzioni | |
---|---|
companion | Restituisce un riferimento a CompanionAdsService. |
define | Consente di creare un'area annuncio fuori pagina con il percorso dell'unità pubblicitaria specificato. |
define | Consente di creare un'area annuncio con un determinato percorso e dimensioni dell'unità pubblicitaria e di associarla all'ID di un elemento div nella pagina che conterrà l'annuncio. |
destroy | Distrugge gli slot specificati, rimuovendo tutti gli oggetti e i riferimenti correlati da GPT. |
disable | Disattiva la Google Publisher Console. |
display | Indica ai servizi dello slot di eseguire il rendering dello slot. |
enable | Attiva tutti i servizi GPT che sono stati definiti per le aree annuncio nella pagina. |
get | Restituisce la versione corrente di GPT. |
open | Viene aperta la Google Publisher Console. |
pubads | Restituisce un riferimento a PubAdsService. |
set | Imposta il titolo per tutti gli iframe dei contenitori degli annunci creati da PubAdsService, da questo momento in poi. |
set | Imposta le opzioni di configurazione generali per la pagina. |
size | Crea un nuovo SizeMappingBuilder. |
Alias del tipo
GeneralSize
GeneralSize: SingleSize | MultiSize
MultiSize
MultiSize: SingleSize[]
NamedSize
NamedSize: "fluid" | ["fluid"]
- fluid: il contenitore dell'annuncio occupa il 100% della larghezza del div principale e poi ridimensiona la sua altezza in base ai contenuti della creatività. In modo simile al comportamento degli elementi di blocco standard in una pagina. Utilizzato per gli annunci nativi (vedi l'articolo correlato). Tieni presente che sia
fluid
che['fluid']
sono forme accettabili per dichiarare una dimensione dell'area come fluida.
SingleSize
SingleSize: SingleSizeArray | NamedSize
SingleSizeArray
SingleSizeArray: [number, number]
SizeMapping
SizeMapping: [SingleSizeArray, GeneralSize]
SizeMappingArray
SizeMappingArray: SizeMapping[]
Variabili
Const
apiReady
apiReady: boolean | undefined
undefined
finché l'API non sarà pronta.Tieni presente che il modo consigliato per gestire l'aggiornamento asincrono è utilizzare googletag.cmd per mettere in coda i callback per quando GPT è pronto. Questi callback non devono controllare googletag.apiReady perché è garantito che vengano eseguiti una volta configurata l'API.
Const
cmd
cmd: ((this: typeof globalThis) => void)[] | CommandArray
La variabile
googletag.cmd
viene inizializzata a un array JavaScript vuoto dalla sintassi del tag GPT nella pagina e cmd.push
è il metodo Array.push
standard che aggiunge un elemento alla fine dell'array. Quando il codice JavaScript di GPT viene caricato, esamina l'array ed esegue tutte le funzioni in ordine. Lo script sostituisce quindi cmd
con un oggetto CommandArray il cui metodo push è definito per eseguire l'argomento della funzione che gli viene passato. Questo meccanismo consente a GPT di ridurre la latenza percepita recuperando il codice JavaScript in modo asincrono, consentendo al browser di continuare a eseguire il rendering della pagina.- Esempio
JavaScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
JavaScript (precedente)
googletag.cmd.push(function () { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
TypeScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads()); });
Const
pubadsReady
pubadsReady: boolean | undefined
undefined
finché non viene chiamata enableServices e PubAdsService non viene caricato e inizializzato.secureSignalProviders
secureSignalProviders: SecureSignalProvider[] | SecureSignalProvidersArray | undefined
L'array di fornitori di indicatori sicuri accetta una sequenza di funzioni di generazione di indicatori e le invoca in ordine. È progettato per sostituire un array standard utilizzato per mettere in coda le funzioni di generazione di indicatori da richiamare una volta caricato il GPT.
- Esempio
JavaScript
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { return Promise.resolve("signal"); }, });
JavaScript (precedente)
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: function () { return Promise.resolve("signal"); }, });
TypeScript
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { return Promise.resolve("signal"); }, });
Funzioni
companionAds
companionAds(): CompanionAdsService
Resi | |
---|---|
CompanionAdsService | Il servizio Annunci companion. |
defineOutOfPageSlot
defineOutOfPageSlot(adUnitPath: string, div?: string | OutOfPageFormat): Slot | null
Per gli annunci fuori pagina personalizzati,
div
è l'ID dell'elemento div che conterrà l'annuncio. Per ulteriori dettagli, consulta l'articolo sulle creatività fuori pagina.Per gli annunci fuori pagina gestiti con GPT,
div
è un OutOfPageFormat supportato.- Esempio
JavaScript
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
JavaScript (precedente)
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
TypeScript
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
- Vedi anche
Parametri | |
---|---|
adUnitPath: string | Percorso dell'unità pubblicitaria completo con il codice di rete e il codice dell'unità pubblicitaria. |
| ID del div che conterrà questa unità pubblicitaria o OutOfPageFormat. |
Resi | |
---|---|
Slot | null | Lo slot appena creato o null se non è possibile crearne uno. |
defineSlot
defineSlot(adUnitPath: string, size: GeneralSize, div?: string): Slot | null
- Esempio
JavaScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
JavaScript (precedente)
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
- Vedi anche
Parametri | |
---|---|
adUnitPath: string | Percorso dell'unità pubblicitaria completo con il codice di rete e il codice dell'unità. |
size: GeneralSize | Larghezza e altezza dell'area aggiunta. Si tratta della dimensione utilizzata nella richiesta di annuncio se non viene fornita una mappatura delle dimensioni adattabili o se la dimensione dell'area visibile è inferiore alla dimensione più piccola indicata nella mappatura. |
| ID del div che conterrà questa unità pubblicitaria. |
Resi | |
---|---|
Slot | null | Lo slot appena creato o null se non è possibile crearne uno. |
destroySlots
destroySlots(slots?: Slot[]): boolean
L'attivazione di questa API in un'area annuncio cancella l'annuncio e rimuove l'oggetto area annuncio dallo stato interno gestito da GPT. La chiamata di altre funzioni all'oggetto slot comporterà un comportamento non definito. Tieni presente che il browser potrebbe comunque non liberare la memoria associata allo slot se un riferimento viene mantenuto dalla pagina del publisher. La chiamata a questa API rende disponibile per il riutilizzo il div associato a quella posizione.
In particolare, la distruzione di uno slot rimuove l'annuncio dalla visualizzazione di pagina a lungo termine di GPT, pertanto le richieste future non saranno influenzate da blocchi stradali o esclusioni della concorrenza che coinvolgono questo annuncio. Se non chiami questa funzione prima di rimuovere il div di uno slot dalla pagina, il comportamento sarà indefinito.
- Esempio
JavaScript
// The calls to construct an ad and display contents. const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
JavaScript (precedente)
// The calls to construct an ad and display contents. var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
TypeScript
// The calls to construct an ad and display contents. const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
Parametri | |
---|---|
| L'array di slot da distruggere. L'array è facoltativo; tutti gli slot verranno distrutti se non è specificato. |
Resi | |
---|---|
boolean | true se gli slot sono stati distrutti, false altrimenti. |
disablePublisherConsole
disablePublisherConsole(): void
- Vedi anche
display
display(divOrSlot: string | Element | Slot): void
Se viene utilizzata l'architettura di richiesta singola (SRA), tutte le aree annuncio non recuperate al momento della chiamata di questo metodo verranno recuperate contemporaneamente. Per impedire la visualizzazione di uno spazio annuncio, è necessario rimuovere l'intero div.
- Vedi anche
Parametri | |
---|---|
divOrSlot: string | Element | Slot | L'ID dell'elemento div contenente lo spazio pubblicitario o l'elemento div oppure l'oggetto spazio. Se viene fornito un elemento div, deve avere un attributo "id" che corrisponda all'ID passato a defineSlot. |
enableServices
enableServices(): void
getVersion
getVersion(): string
- Vedi anche
Resi | |
---|---|
string | La stringa della versione GPT attualmente in esecuzione. |
openConsole
openConsole(div?: string): void
- Esempio
JavaScript
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
JavaScript (precedente)
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
TypeScript
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
- Vedi anche
Parametri | |
---|---|
| Un ID div dell'area annuncio. Questo valore è facoltativo. Se specificato, la Publisher Console tenterà di aprirsi con i dettagli dell'area annuncio specificata in visualizzazione. |
pubads
pubads(): PubAdsService
Resi | |
---|---|
PubAdsService | Il servizio Annunci del publisher. |
setAdIframeTitle
setAdIframeTitle(title: string): void
- Esempio
JavaScript
googletag.setAdIframeTitle("title");
JavaScript (precedente)
googletag.setAdIframeTitle("title");
TypeScript
googletag.setAdIframeTitle("title");
Parametri | |
---|---|
title: string | Il nuovo titolo per tutti gli iframe del contenitore degli annunci. |
setConfig
setConfig(config: PageSettingsConfig): void
Parametri | |
---|---|
config: PageSettingsConfig |
sizeMapping
sizeMapping(): SizeMappingBuilder
Resi | |
---|---|
SizeMappingBuilder | Un nuovo generatore. |
googletag.CommandArray
Metodi | |
---|---|
push | Esegue la sequenza di funzioni specificate negli argomenti in ordine. |
Metodi
push
push(...f: ((this: typeof globalThis) => void)[]): number
- Esempio
JavaScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
JavaScript (precedente)
googletag.cmd.push(function () { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
TypeScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads()); });
Parametri | |
---|---|
| Una funzione JavaScript da eseguire. La compilazione di runtime sarà sempre globalThis . Valuta la possibilità di passare una funzione freccia per mantenere il valore this del contesto lessicale che la racchiude. |
Resi | |
---|---|
number | Il numero di comandi elaborati finora. Questo è compatibile con il valore restituito di Array.push (la lunghezza corrente dell'array). |
googletag.CompanionAdsService
Si estendeMetodi | |
---|---|
add | Registra un ascoltatore che ti consente di configurare e chiamare una funzione JavaScript quando si verifica un evento GPT specifico nella pagina. Ereditata da |
get | Visualizza l'elenco degli slot associati a questo servizio. Ereditata da |
remove | Rimuove un ascoltatore registrato in precedenza. Ereditata da |
set | Imposta se il backfill automatico verrà eseguito per gli slot companion che non sono stati compilati. |
- Vedi anche
Metodi
setRefreshUnfilledSlots
setRefreshUnfilledSlots(value: boolean): void
Questo metodo può essere chiamato più volte durante la vita utile della pagina per attivare e disattivare il backfill. Verrà eseguito il backfill solo per le aree registrate anche con PubAdsService. A causa delle limitazioni delle norme, questo metodo non è progettato per riempire gli slot companion vuoti quando viene pubblicato un video di Ad Exchange.
- Esempio
JavaScript
googletag.companionAds().setRefreshUnfilledSlots(true);
JavaScript (precedente)
googletag.companionAds().setRefreshUnfilledSlots(true);
TypeScript
googletag.companionAds().setRefreshUnfilledSlots(true);
Parametri | |
---|---|
value: boolean | true per eseguire automaticamente il backfill degli slot non completati, false per lasciarli invariati. |
googletag.PrivacySettingsConfig
Proprietà | |
---|---|
child | Indica se la pagina deve essere trattata come destinata ai minori. |
limited | Consente la pubblicazione in modalità di annunci con limitazioni per soddisfare le esigenze di conformità normativa dei publisher. |
non | Consente di pubblicare annunci in modalità non personalizzata per soddisfare le esigenze di conformità normativa dei publisher. |
restrict | Consente di pubblicare annunci in modalità di elaborazione limitata per soddisfare le esigenze di conformità normativa dei publisher. |
traffic | Indica se le richieste rappresentano traffico organico o acquistato. |
under | Indica se contrassegnare le richieste di annunci come provenienti da utenti di età inferiore a quella del consenso digitale. |
Proprietà
Optional
childDirectedTreatment
childDirectedTreatment?: null | boolean
null
per cancellare la configurazione.Optional
limitedAds
limitedAds?: boolean
Puoi chiedere a GPT di richiedere annunci con limitazioni in due modi:
- Automaticamente, utilizzando un indicatore di una piattaforma di gestione del consenso che utilizza la versione 2.0 del TCF di IAB.
- Manualmente, impostando il valore di questo campo su
true
.
Tieni presente che non è necessario attivare manualmente gli annunci con limitazioni quando è in uso una CMP.
- Esempio
JavaScript
// Manually enable limited ads serving. // GPT must be loaded from the limited ads URL to configure this setting. googletag.pubads().setPrivacySettings({ limitedAds: true, });
JavaScript (precedente)
// Manually enable limited ads serving. // GPT must be loaded from the limited ads URL to configure this setting. googletag.pubads().setPrivacySettings({ limitedAds: true, });
TypeScript
// Manually enable limited ads serving. // GPT must be loaded from the limited ads URL to configure this setting. googletag.pubads().setPrivacySettings({ limitedAds: true, });
- Vedi anche
Optional
nonPersonalizedAds
nonPersonalizedAds?: boolean
Optional
restrictDataProcessing
restrictDataProcessing?: boolean
Optional
trafficSource
trafficSource?: TrafficSource
undefined
nei report.- Esempio
JavaScript
// Indicate requests represent organic traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.ORGANIC, }); // Indicate requests represent purchased traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.PURCHASED, });
JavaScript (precedente)
// Indicate requests represent organic traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.ORGANIC, }); // Indicate requests represent purchased traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.PURCHASED, });
TypeScript
// Indicate requests represent organic traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.ORGANIC, }); // Indicate requests represent purchased traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.PURCHASED, });
Optional
underAgeOfConsent
underAgeOfConsent?: null | boolean
null
per cancellare la configurazione.googletag.PubAdsService
Si estendeMetodi | |
---|---|
add | Registra un ascoltatore che ti consente di configurare e chiamare una funzione JavaScript quando si verifica un evento GPT specifico nella pagina. Ereditata da |
clear | Rimuove gli annunci dagli slot specificati e li sostituisce con contenuti vuoti. |
clear | Cancella tutte le etichette di esclusione delle categorie di annunci a livello di pagina. |
clear | Cancella i parametri di targeting personalizzato per una chiave specifica o per tutte le chiavi. |
collapse | Consente di comprimere i div delle aree in modo che non occupino spazio sulla pagina quando non sono presenti contenuti dell'annuncio da visualizzare. |
disable | Disattiva le richieste di annunci al caricamento della pagina, ma consente di richiederli con una chiamata PubAdsService.refresh. |
display | Crea e mostra un'area annuncio con il percorso e le dimensioni dell'unità pubblicitaria specificati. |
enable | Attiva il caricamento lento in GPT come definito dall'oggetto config. |
enable | Attiva la modalità di richiesta singola per il recupero di più annunci contemporaneamente. |
enable | Indica a GPT che nella pagina saranno presenti annunci video. |
get | Restituisce il valore dell'attributo AdSense associato alla chiave specificata. |
get | Restituisce le chiavi degli attributi impostate su questo servizio. |
get | Visualizza l'elenco degli slot associati a questo servizio. Ereditata da |
get | Restituisce un parametro di targeting a livello di servizio personalizzato specifico che è stato impostato. |
get | Restituisce l'elenco di tutte le chiavi di targeting a livello di servizio personalizzate che sono state impostate. |
is | Restituisce se le richieste iniziali di annunci sono state disattivate correttamente da una chiamata PubAdsService.disableInitialLoad precedente. |
refresh | Recupera e mostra nuovi annunci per aree specifiche o per tutte le aree della pagina. |
remove | Rimuove un ascoltatore registrato in precedenza. Ereditata da |
set | Imposta i valori per gli attributi AdSense che si applicano a tutte le aree annuncio del servizio Annunci per i publisher. |
set | Imposta un'esclusione di categorie di annunci a livello di pagina per il nome dell'etichetta specificato. |
set | Attiva e disattiva il centro orizzontale degli annunci. |
set | Consente di configurare se tutti gli annunci nella pagina devono essere forzati a essere visualizzati utilizzando un contenitore SafeFrame. |
set | Trasmette i dati sulla posizione dai siti web per consentirti di scegliere come target geografico gli elementi pubblicitari in base a località specifiche. |
set | Consente la configurazione di tutte le impostazioni della privacy da una singola API utilizzando un oggetto di configurazione. |
set | Imposta il valore per l'ID fornito dal publisher. |
set | Imposta le preferenze a livello di pagina per la configurazione di SafeFrame. |
set | Imposta i parametri di targeting personalizzato per una determinata chiave che si applicano a tutti gli spazi pubblicitari del servizio Publisher Ads. |
set | Imposta le informazioni sui contenuti video da inviare insieme alle richieste di annunci a fini di targeting ed esclusione dei contenuti. |
update | Modifica il correlatore inviato con le richieste di annunci, avviando di fatto una nuova visualizzazione di pagina. |
Metodi
clear
clear(slots?: Slot[]): boolean
In particolare, l'eliminazione di uno slot rimuove l'annuncio dalla visualizzazione di pagina a lungo termine del GPT, pertanto le richieste future non saranno influenzate da blocchi o esclusioni della concorrenza che coinvolgono questo annuncio.
- Esempio
JavaScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
JavaScript (precedente)
var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
TypeScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
Parametri | |
---|---|
| L'array di slot da cancellare. L'array è facoltativo; se non è specificato, tutti gli slot verranno cancellati. |
Resi | |
---|---|
boolean | Restituisce true se gli slot sono stati cancellati, false in caso contrario. |
clearCategoryExclusions
clearCategoryExclusions(): PubAdsService
- Esempio
JavaScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.pubads().setCategoryExclusion("AirlineAd"); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.pubads().clearCategoryExclusions(); // Make ad requests. Any ad can be returned.
JavaScript (precedente)
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.pubads().setCategoryExclusion("AirlineAd"); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.pubads().clearCategoryExclusions(); // Make ad requests. Any ad can be returned.
TypeScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.pubads().setCategoryExclusion("AirlineAd"); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.pubads().clearCategoryExclusions(); // Make ad requests. Any ad can be returned.
Resi | |
---|---|
PubAdsService | L'oggetto servizio su cui è stato chiamato il metodo. |
clearTargeting
clearTargeting(key?: string): PubAdsService
- Esempio
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); googletag.pubads().clearTargeting("interests"); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.pubads().clearTargeting(); // All targeting has been cleared.
JavaScript (precedente)
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); googletag.pubads().clearTargeting("interests"); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.pubads().clearTargeting(); // All targeting has been cleared.
TypeScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); googletag.pubads().clearTargeting("interests"); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.pubads().clearTargeting(); // All targeting has been cleared.
- Vedi anche
Parametri | |
---|---|
| Chiave del parametro di targeting. La chiave è facoltativa; se non è specificata, tutti i parametri di targeting verranno cancellati. |
Resi | |
---|---|
PubAdsService | L'oggetto servizio su cui è stato chiamato il metodo. |
collapseEmptyDivs
collapseEmptyDivs(collapseBeforeAdFetch?: boolean): boolean
Parametri | |
---|---|
| Indica se comprimere gli slot anche prima del recupero degli annunci. Questo parametro è facoltativo. Se non viene fornito, verrà utilizzato false come valore predefinito. |
Resi | |
---|---|
boolean | Restituisce true se la modalità di chiusura di div è stata attivata e false se non è possibile attivare la modalità di chiusura perché il metodo è stato chiamato dopo l'attivazione del servizio. |
disableInitialLoad
disableInitialLoad(): void
refresh
.display
display(adUnitPath: string, size: GeneralSize, div?: string | Element, clickUrl?: string): void
Nota: quando viene chiamato questo metodo, viene creato uno snapshot dello stato della pagina e dello slot per garantire la coerenza durante l'invio della richiesta di annuncio e il rendering della risposta. Eventuali modifiche apportate allo stato dello slot o della pagina dopo la chiamata di questo metodo (inclusi targeting, impostazioni della privacy, forzatura di SafeFrame e così via) verranno applicate solo alle richieste
display()
o refresh()
successive.- Esempio
JavaScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
JavaScript (precedente)
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
Parametri | |
---|---|
adUnitPath: string | Il percorso dell'unità pubblicitaria della posizione da visualizzare. |
size: GeneralSize | Larghezza e altezza della sezione. |
| L'ID del div contenente lo slot o l'elemento div stesso. |
| L'URL di clic da utilizzare in questo slot. |
enableLazyLoad
enableLazyLoad(config?: {
fetchMarginPercent?: number;
mobileScaling?: number;
renderMarginPercent?: number;
}): void
Nota: il recupero lento in SRA funziona solo se tutti gli slot sono al di fuori del margine di recupero.
- Esempio
JavaScript
googletag.pubads().enableLazyLoad({ // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, });
JavaScript (precedente)
googletag.pubads().enableLazyLoad({ // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, });
TypeScript
googletag.pubads().enableLazyLoad({ // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, });
- Vedi anche
Parametri | |
---|---|
| L'oggetto di configurazione consente di personalizzare il comportamento lazy. Per le configurazioni omesse verrà utilizzato un valore predefinito impostato da Google che verrà ottimizzato nel tempo. Per disattivare una determinata impostazione, ad esempio un margine di recupero, imposta il valore su -1 .
|
enableSingleRequest
enableSingleRequest(): boolean
- Vedi anche
Resi | |
---|---|
boolean | Restituisce true se è stata attivata la modalità di richiesta singola e false se non è possibile attivarla perché il metodo è stato chiamato dopo l'attivazione del servizio. |
enableVideoAds
enableVideoAds(): void
get
get(key: string): null | string
- Esempio
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
JavaScript (precedente)
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
- Vedi anche
Parametri | |
---|---|
key: string | Nome dell'attributo da cercare. |
Resi | |
---|---|
null | string | Valore corrente per la chiave dell'attributo o null se la chiave non è presente. |
getAttributeKeys
getAttributeKeys(): string[]
- Esempio
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().set("adsense_border_color", "#AABBCC"); googletag.pubads().getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
JavaScript (precedente)
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().set("adsense_border_color", "#AABBCC"); googletag.pubads().getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().set("adsense_border_color", "#AABBCC"); googletag.pubads().getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
Resi | |
---|---|
string[] | Array di chiavi degli attributi impostate su questo servizio. L'ordinamento non è definito. |
getTargeting
getTargeting(key: string): string[]
- Esempio
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
JavaScript (precedente)
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
TypeScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
Parametri | |
---|---|
key: string | La chiave di targeting da cercare. |
Resi | |
---|---|
string[] | I valori associati a questa chiave o un array vuoto se non esiste questa chiave. |
getTargetingKeys
getTargetingKeys(): string[]
- Esempio
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
JavaScript (precedente)
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
TypeScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
Resi | |
---|---|
string[] | Array di chiavi di targeting. L'ordinamento non è definito. |
isInitialLoadDisabled
isInitialLoadDisabled(): boolean
Resi | |
---|---|
boolean | Restituisce true se una chiamata precedente a PubAdsService.disableInitialLoad è andata a buon fine, false in caso contrario. |
aggiorna
refresh(slots?: null | Slot[], options?: {
changeCorrelator: boolean;
}): void
Per un comportamento corretto in tutti i browser, la chiamata a
refresh
deve essere preceduta da una chiamata a display
l'area annuncio. Se la chiamata a display
viene omessa, l'aggiornamento potrebbe comportarsi in modo imprevisto. Se vuoi, puoi utilizzare il metodo PubAdsService.disableInitialLoad per impedire a display
di recuperare un annuncio.L'aggiornamento di uno slot rimuove l'annuncio precedente dalla visualizzazione di pagina a lungo termine di GPT, pertanto le richieste future non saranno influenzate da blocchi o esclusioni della concorrenza che coinvolgono l'annuncio.
- Esempio
JavaScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to refresh fetches a new ad for slot1 only. googletag.pubads().refresh([slot1]); // This call to refresh fetches a new ad for both slot1 and slot2. googletag.pubads().refresh([slot1, slot2]); // This call to refresh fetches a new ad for each slot. googletag.pubads().refresh(); // This call to refresh fetches a new ad for slot1, without changing // the correlator. googletag.pubads().refresh([slot1], { changeCorrelator: false }); // This call to refresh fetches a new ad for each slot, without // changing the correlator. googletag.pubads().refresh(null, { changeCorrelator: false });
JavaScript (precedente)
var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to refresh fetches a new ad for slot1 only. googletag.pubads().refresh([slot1]); // This call to refresh fetches a new ad for both slot1 and slot2. googletag.pubads().refresh([slot1, slot2]); // This call to refresh fetches a new ad for each slot. googletag.pubads().refresh(); // This call to refresh fetches a new ad for slot1, without changing // the correlator. googletag.pubads().refresh([slot1], { changeCorrelator: false }); // This call to refresh fetches a new ad for each slot, without // changing the correlator. googletag.pubads().refresh(null, { changeCorrelator: false });
TypeScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to refresh fetches a new ad for slot1 only. googletag.pubads().refresh([slot1]); // This call to refresh fetches a new ad for both slot1 and slot2. googletag.pubads().refresh([slot1, slot2]); // This call to refresh fetches a new ad for each slot. googletag.pubads().refresh(); // This call to refresh fetches a new ad for slot1, without changing // the correlator. googletag.pubads().refresh([slot1], { changeCorrelator: false }); // This call to refresh fetches a new ad for each slot, without // changing the correlator. googletag.pubads().refresh(null, { changeCorrelator: false });
Parametri | |
---|---|
| Le caselle da aggiornare. L'array è facoltativo; se non è specificato, verranno aggiornati tutti gli slot. |
| Opzioni di configurazione associate a questa chiamata di aggiornamento.
|
set
set(key: string, value: string): PubAdsService
Se la chiami più volte per la stessa chiave, i valori impostati in precedenza per quella chiave verranno sostituiti. Tutti i valori devono essere impostati prima di chiamare
display
o refresh
.- Esempio
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF");
JavaScript (precedente)
googletag.pubads().set("adsense_background_color", "#FFFFFF");
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF");
- Vedi anche
Parametri | |
---|---|
key: string | Il nome dell'attributo. |
value: string | Valore dell'attributo. |
Resi | |
---|---|
PubAdsService | L'oggetto servizio su cui è stato chiamato il metodo. |
setCategoryExclusion
setCategoryExclusion(categoryExclusion: string): PubAdsService
- Esempio
JavaScript
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
JavaScript (precedente)
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
TypeScript
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
Parametri | |
---|---|
categoryExclusion: string | L'etichetta di esclusione della categoria di annunci da aggiungere. |
Resi | |
---|---|
PubAdsService | L'oggetto servizio su cui è stato chiamato il metodo. |
setCentering
setCentering(centerAds: boolean): void
Questo metodo deve essere invocato prima di chiamare
display
o refresh
perché solo gli annunci richiesti dopo la chiamata di questo metodo verranno centrati.- Esempio
JavaScript
// Make ads centered. googletag.pubads().setCentering(true);
JavaScript (precedente)
// Make ads centered. googletag.pubads().setCentering(true);
TypeScript
// Make ads centered. googletag.pubads().setCentering(true);
Parametri | |
---|---|
centerAds: boolean | true per allineare gli annunci al centro, false per allinearli a sinistra. |
setForceSafeFrame
setForceSafeFrame(forceSafeFrame: boolean): PubAdsService
Tieni presente quanto segue quando utilizzi questa API:
- Questa impostazione verrà applicata solo alle richieste di annunci successive effettuate per i rispettivi slot.
- L'impostazione a livello di area, se specificata, sostituirà sempre l'impostazione a livello di pagina.
- Se impostato su
true
(a livello di area annuncio o di pagina), l'annuncio verrà sempre visualizzato utilizzando un contenitore SafeFrame, indipendentemente dalla scelta effettuata nell'interfaccia utente di Google Ad Manager. - Tuttavia, se impostato su
false
o lasciato non specificato, l'annuncio verrà visualizzato utilizzando un contenitore SafeFrame a seconda del tipo di creatività e della selezione effettuata nell'interfaccia utente di Google Ad Manager. - Questa API deve essere utilizzata con cautela in quanto potrebbe influire sul comportamento delle creatività che tentano di uscire dai propri iframe o che si basano sul loro rendering direttamente nella pagina di un publisher.
- Esempio
JavaScript
googletag.pubads().setForceSafeFrame(true); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setForceSafeFrame(false) .addService(googletag.pubads()); // The following slot will have SafeFrame forced. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
JavaScript (precedente)
googletag.pubads().setForceSafeFrame(true); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setForceSafeFrame(false) .addService(googletag.pubads()); // The following slot will have SafeFrame forced. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
TypeScript
googletag.pubads().setForceSafeFrame(true); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setForceSafeFrame(false) .addService(googletag.pubads()); // The following slot will have SafeFrame forced. googletag.defineSlot("/1234567/news", [160, 600], "div-2")!.addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
Parametri | |
---|---|
forceSafeFrame: boolean | true per forzare il rendering di tutti gli annunci nella pagina in SafeFrame e false per impostare su false l'impostazione precedente. Se non è stato specificato in precedenza, l'impostazione su false non cambia nulla. |
Resi | |
---|---|
PubAdsService | L'oggetto servizio su cui è stata chiamata la funzione. |
setLocation
setLocation(address: string): PubAdsService
- Esempio
JavaScript
// Postal code: googletag.pubads().setLocation("10001,US");
JavaScript (precedente)
// Postal code: googletag.pubads().setLocation("10001,US");
TypeScript
// Postal code: googletag.pubads().setLocation("10001,US");
Parametri | |
---|---|
address: string | Indirizzo in formato libero. |
Resi | |
---|---|
PubAdsService | L'oggetto servizio su cui è stato chiamato il metodo. |
setPrivacySettings
setPrivacySettings(privacySettings: PrivacySettingsConfig): PubAdsService
- Esempio
JavaScript
googletag.pubads().setPrivacySettings({ restrictDataProcessing: true, }); // Set multiple privacy settings at the same time. googletag.pubads().setPrivacySettings({ childDirectedTreatment: true, underAgeOfConsent: true, }); // Clear the configuration for childDirectedTreatment. googletag.pubads().setPrivacySettings({ childDirectedTreatment: null, });
JavaScript (precedente)
googletag.pubads().setPrivacySettings({ restrictDataProcessing: true, }); // Set multiple privacy settings at the same time. googletag.pubads().setPrivacySettings({ childDirectedTreatment: true, underAgeOfConsent: true, }); // Clear the configuration for childDirectedTreatment. googletag.pubads().setPrivacySettings({ childDirectedTreatment: null, });
TypeScript
googletag.pubads().setPrivacySettings({ restrictDataProcessing: true, }); // Set multiple privacy settings at the same time. googletag.pubads().setPrivacySettings({ childDirectedTreatment: true, underAgeOfConsent: true, }); // Clear the configuration for childDirectedTreatment. googletag.pubads().setPrivacySettings({ childDirectedTreatment: null, });
Parametri | |
---|---|
privacySettings: PrivacySettingsConfig | Oggetto contenente la configurazione delle impostazioni della privacy. |
Resi | |
---|---|
PubAdsService | L'oggetto servizio su cui è stata chiamata la funzione. |
setPublisherProvidedId
setPublisherProvidedId(ppid: string): PubAdsService
- Esempio
JavaScript
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
JavaScript (precedente)
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
TypeScript
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
Parametri | |
---|---|
ppid: string | Un ID alfanumerico fornito dal publisher. Deve avere una lunghezza compresa tra 32 e 150 caratteri. |
Resi | |
---|---|
PubAdsService | L'oggetto servizio su cui è stato chiamato il metodo. |
setSafeFrameConfig
setSafeFrameConfig(config: SafeFrameConfig): PubAdsService
Queste preferenze a livello di pagina verranno sostituite dalle preferenze a livello di slot, se specificate.
- Esempio
JavaScript
googletag.pubads().setForceSafeFrame(true); const pageConfig = { allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }; const slotConfig = { allowOverlayExpansion: false }; googletag.pubads().setSafeFrameConfig(pageConfig); // The following slot will not allow for expansion by overlay. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig(slotConfig) .addService(googletag.pubads()); // The following slot will inherit the page level settings, and hence // would allow for expansion by overlay. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
JavaScript (precedente)
googletag.pubads().setForceSafeFrame(true); var pageConfig = { allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }; var slotConfig = { allowOverlayExpansion: false }; googletag.pubads().setSafeFrameConfig(pageConfig); // The following slot will not allow for expansion by overlay. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig(slotConfig) .addService(googletag.pubads()); // The following slot will inherit the page level settings, and hence // would allow for expansion by overlay. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
TypeScript
googletag.pubads().setForceSafeFrame(true); const pageConfig = { allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }; const slotConfig = { allowOverlayExpansion: false }; googletag.pubads().setSafeFrameConfig(pageConfig); // The following slot will not allow for expansion by overlay. googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setSafeFrameConfig(slotConfig) .addService(googletag.pubads()); // The following slot will inherit the page level settings, and hence // would allow for expansion by overlay. googletag.defineSlot("/1234567/news", [160, 600], "div-2")!.addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
Parametri | |
---|---|
config: SafeFrameConfig | L'oggetto di configurazione. |
Resi | |
---|---|
PubAdsService | L'oggetto servizio su cui è stato chiamato il metodo. |
setTargeting
setTargeting(key: string, value: string | string[]): PubAdsService
- Esempio
JavaScript
// Example with a single value for a key. googletag.pubads().setTargeting("interests", "sports"); // Example with multiple values for a key inside in an array. googletag.pubads().setTargeting("interests", ["sports", "music"]);
JavaScript (precedente)
// Example with a single value for a key. googletag.pubads().setTargeting("interests", "sports"); // Example with multiple values for a key inside in an array. googletag.pubads().setTargeting("interests", ["sports", "music"]);
TypeScript
// Example with a single value for a key. googletag.pubads().setTargeting("interests", "sports"); // Example with multiple values for a key inside in an array. googletag.pubads().setTargeting("interests", ["sports", "music"]);
- Vedi anche
Parametri | |
---|---|
key: string | Chiave del parametro di targeting. |
value: string | string[] | Valore del parametro di targeting o array di valori. |
Resi | |
---|---|
PubAdsService | L'oggetto servizio su cui è stato chiamato il metodo. |
setVideoContent
setVideoContent(videoContentId: string, videoCmsId: string): void
videoContentId
e videoCmsId
, utilizza i valori forniti al servizio di importazione dei contenuti di Google Ad Manager.- Vedi anche
Parametri | |
---|---|
videoContentId: string | L'ID dei contenuti video. |
videoCmsId: string | L'ID CMS del video. |
updateCorrelator
updateCorrelator(): PubAdsService
Nota: questo non influisce sulla visualizzazione di pagina a lungo termine di GPT, che riflette automaticamente gli annunci effettivamente presenti nella pagina e non ha scadenza.
- Esempio
JavaScript
// Assume that the correlator is currently 12345. All ad requests made // by this page will currently use that value. // Replace the current correlator with a new correlator. googletag.pubads().updateCorrelator(); // The correlator will now be a new randomly selected value, different // from 12345. All subsequent ad requests made by this page will use // the new value.
JavaScript (precedente)
// Assume that the correlator is currently 12345. All ad requests made // by this page will currently use that value. // Replace the current correlator with a new correlator. googletag.pubads().updateCorrelator(); // The correlator will now be a new randomly selected value, different // from 12345. All subsequent ad requests made by this page will use // the new value.
TypeScript
// Assume that the correlator is currently 12345. All ad requests made // by this page will currently use that value. // Replace the current correlator with a new correlator. googletag.pubads().updateCorrelator(); // The correlator will now be a new randomly selected value, different // from 12345. All subsequent ad requests made by this page will use // the new value.
Resi | |
---|---|
PubAdsService | L'oggetto servizio su cui è stata chiamata la funzione. |
googletag.ResponseInformation
Proprietà | |
---|---|
advertiser | L'ID dell'inserzionista. |
campaign | L'ID della campagna. |
creative | L'ID della creatività. |
creative | L'ID del modello dell'annuncio. |
line | L'ID della voce. |
- Vedi anche
Proprietà
advertiserId
advertiserId: null | number
campaignId
campaignId: null | number
creativeId
creativeId: null | number
creativeTemplateId
creativeTemplateId: null | number
lineItemId
lineItemId: null | number
googletag.RewardedPayload
Proprietà | |
---|---|
amount | Il numero di articoli inclusi nel premio. |
type | Il tipo di elemento incluso nel premio (ad esempio, "coin"). |
- Vedi anche
Proprietà
amount
amount: number
type
type: string
googletag.SafeFrameConfig
Proprietà | |
---|---|
allow | Indica se SafeFrame deve consentire l'espansione dei contenuti dell'annuncio sovrapponendo i contenuti della pagina. |
allow | Indica se SafeFrame deve consentire l'espansione dei contenuti dell'annuncio spingendo i contenuti della pagina. |
sandbox | Indica se SafeFrame deve utilizzare l'attributo sandbox HTML5 per impedire la navigazione di primo livello senza interazione dell'utente. |
use | Ritirata. Se SafeFrame deve utilizzare sottodomini casuali per le creatività di prenotazione. |
- Vedi anche
Proprietà
Optional
allowOverlayExpansion
allowOverlayExpansion?: boolean
Optional
allowPushExpansion
allowPushExpansion?: boolean
Optional
sandbox
sandbox?: boolean
true
(non può essere impostato su false
). Tieni presente che l'attributo sandbox disattiva i plug-in (ad es. Flash).Optional
useUniqueDomain
useUniqueDomain?: null | boolean
null
per cancellare il valore memorizzato.Nota: questa funzionalità è attiva per impostazione predefinita.
googletag.Service
Metodi | |
---|---|
add | Registra un ascoltatore che ti consente di configurare e chiamare una funzione JavaScript quando si verifica un evento GPT specifico nella pagina. |
get | Visualizza l'elenco degli slot associati a questo servizio. |
remove | Rimuove un ascoltatore registrato in precedenza. |
Metodi
addEventListener
addEventListener<K extends keyof EventTypeMap>(eventType: K, listener: ((arg: EventTypeMap[K]) => void)): Service
- events.GameManualInterstitialSlotClosedEvent
- events.GameManualInterstitialSlotReadyEvent
- events.ImpressionViewableEvent
- events.RewardedSlotClosedEvent
- events.RewardedSlotGrantedEvent
- events.RewardedSlotReadyEvent
- events.SlotOnloadEvent
- events.SlotRenderEndedEvent
- events.SlotRequestedEvent
- events.SlotResponseReceived
- events.SlotVisibilityChangedEvent
- Esempio
JavaScript
// 1. Adding an event listener for the PubAdsService. googletag.pubads().addEventListener("slotOnload", (event) => { console.log("Slot has been loaded:"); console.log(event); }); // 2. Adding an event listener with slot specific logic. // Listeners operate at service level, which means that you cannot add // a listener for an event for a specific slot only. You can, however, // programmatically filter a listener to respond only to a certain ad // slot, using this pattern: const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { if (event.slot === targetSlot) { // Slot specific logic. } });
JavaScript (precedente)
// 1. Adding an event listener for the PubAdsService. googletag.pubads().addEventListener("slotOnload", function (event) { console.log("Slot has been loaded:"); console.log(event); }); // 2. Adding an event listener with slot specific logic. // Listeners operate at service level, which means that you cannot add // a listener for an event for a specific slot only. You can, however, // programmatically filter a listener to respond only to a certain ad // slot, using this pattern: var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", function (event) { if (event.slot === targetSlot) { // Slot specific logic. } });
TypeScript
// 1. Adding an event listener for the PubAdsService. googletag.pubads().addEventListener("slotOnload", (event) => { console.log("Slot has been loaded:"); console.log(event); }); // 2. Adding an event listener with slot specific logic. // Listeners operate at service level, which means that you cannot add // a listener for an event for a specific slot only. You can, however, // programmatically filter a listener to respond only to a certain ad // slot, using this pattern: const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { if (event.slot === targetSlot) { // Slot specific logic. } });
Parametri | |
---|---|
eventType: K | Una stringa che rappresenta il tipo di evento generato da GPT. I tipi di evento sono sensibili alle maiuscole. |
listener: ((arg: EventTypeMap[K]) => void) | Funzione che accetta un singolo argomento oggetto evento. |
Resi | |
---|---|
Service | L'oggetto servizio su cui è stato chiamato il metodo. |
getSlots
removeEventListener
removeEventListener<K extends keyof EventTypeMap>(eventType: K, listener: ((event: EventTypeMap[K]) => void)): void
- Esempio
JavaScript
googletag.cmd.push(() => { // Define a new ad slot. googletag.defineSlot("/6355419/Travel", [728, 90], "div-for-slot").addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. const onViewableListener = (event) => { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(() => { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
JavaScript (precedente)
googletag.cmd.push(function () { // Define a new ad slot. googletag.defineSlot("/6355419/Travel", [728, 90], "div-for-slot").addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. var onViewableListener = function (event) { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(function () { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
TypeScript
googletag.cmd.push(() => { // Define a new ad slot. googletag .defineSlot("/6355419/Travel", [728, 90], "div-for-slot")! .addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. const onViewableListener = (event: googletag.events.ImpressionViewableEvent) => { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(() => { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
Parametri | |
---|---|
eventType: K | Una stringa che rappresenta il tipo di evento generato da GPT. I tipi di evento sono sensibili alle maiuscole. |
listener: ((event: EventTypeMap[K]) => void) | Funzione che accetta un singolo argomento oggetto evento. |
googletag.SizeMappingBuilder
Metodi | |
---|---|
add | Aggiunge una mappatura da un array di dimensioni singole (che rappresenta la visualizzazione) a un array di dimensioni singole o multiple che rappresenta l'area. |
build | Genera una specifica della mappa delle dimensioni dalle mappature aggiunte a questo generatore. |
Metodi
addSize
addSize(viewportSize: SingleSizeArray, slotSize: GeneralSize): SizeMappingBuilder
- Esempio
JavaScript
// Mapping 1 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], [728, 90]) .addSize([640, 480], "fluid") .addSize([0, 0], [88, 31]) // All viewports < 640x480 .build(); // Mapping 2 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], []) .addSize([640, 480], [120, 60]) .addSize([0, 0], []) .build(); // Mapping 2 will not show any ads for the following viewport sizes: // [1024, 768] > size >= [980, 690] and // [640, 480] > size >= [0, 0]
JavaScript (precedente)
// Mapping 1 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], [728, 90]) .addSize([640, 480], "fluid") .addSize([0, 0], [88, 31]) // All viewports < 640x480 .build(); // Mapping 2 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], []) .addSize([640, 480], [120, 60]) .addSize([0, 0], []) .build(); // Mapping 2 will not show any ads for the following viewport sizes: // [1024, 768] > size >= [980, 690] and // [640, 480] > size >= [0, 0]
TypeScript
// Mapping 1 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], [728, 90]) .addSize([640, 480], "fluid") .addSize([0, 0], [88, 31]) // All viewports < 640x480 .build(); // Mapping 2 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], []) .addSize([640, 480], [120, 60]) .addSize([0, 0], []) .build(); // Mapping 2 will not show any ads for the following viewport sizes: // [1024, 768] > size >= [980, 690] and // [640, 480] > size >= [0, 0]
Parametri | |
---|---|
viewportSize: SingleSizeArray | Le dimensioni dell'area visibile per questa voce di mappatura. |
slotSize: GeneralSize | Le dimensioni dell'area per questa voce di mappatura. |
Resi | |
---|---|
SizeMappingBuilder | Un riferimento a questo generatore. |
build
build(): null | SizeMappingArray
Se sono state fornite mappature non valide, questo metodo restituirà
null
. In caso contrario, restituisce una specifica nel formato corretto da passare a Slot.defineSizeMapping.Nota: il comportamento del builder dopo l'chiamata di questo metodo non è definito.
Resi | |
---|---|
null | SizeMappingArray | Il risultato creato da questo generatore. Può essere nullo se sono state fornite mappature delle dimensioni non valide. |
googletag.Slot
Metodi | |
---|---|
add | Aggiunge un servizio a questo slot. |
clear | Cancella tutte le etichette di esclusione delle categorie di annunci a livello di area annuncio per questa area. |
clear | Cancella uno o tutti i parametri di targeting personalizzato a livello di area per questa area. |
define | Imposta un array di mappature da una dimensione minima dell'area visibile alla dimensione dello spazio per questo spazio. |
get | Restituisce il valore dell'attributo AdSense associato alla chiave specificata per questo spazio. |
get | Restituisce il percorso completo dell'unità pubblicitaria, con il codice di rete e il percorso dell'unità pubblicitaria. |
get | Restituisce l'elenco delle chiavi degli attributi impostate in questo slot. |
get | Restituisce le etichette di esclusione delle categorie di annunci per questo spazio. |
get | Restituisce le informazioni sulla risposta all'annuncio. |
get | Restituisce l'ID dell'area div specificata al momento della definizione. |
get | Restituisce un parametro di targeting personalizzato specifico impostato su questo slot. |
get | Restituisce l'elenco di tutte le chiavi di targeting personalizzate impostate in questo slot. |
set | Imposta un valore per un attributo AdSense in questa area annuncio. |
set | Imposta un'etichetta di esclusione di categorie di annunci a livello di area su questa area. |
set | Imposta l'URL di clic a cui gli utenti verranno reindirizzati dopo aver fatto clic sull'annuncio. |
set | Imposta se l'area annuncio div deve essere nascosta quando non è presente alcun annuncio. |
set | Imposta le opzioni di configurazione generali per questo slot. |
set | Consente di configurare se gli annunci in questa area devono essere visualizzati utilizzando un contenitore SafeFrame. |
set | Imposta le preferenze a livello di slot per la configurazione di SafeFrame. |
set | Imposta un parametro di targeting personalizzato per questo spazio. |
update | Imposta i parametri di targeting personalizzato per questo slot da una mappa chiave:valore in un oggetto JSON. |
Metodi
addService
addService(service: Service): Slot
- Esempio
JavaScript
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
JavaScript (precedente)
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
TypeScript
googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
Parametri | |
---|---|
service: Service | Il servizio da aggiungere. |
Resi | |
---|---|
Slot | L'oggetto area su cui è stato chiamato il metodo. |
clearCategoryExclusions
clearCategoryExclusions(): Slot
- Esempio
JavaScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads()); // Make an ad request. No ad with 'AirlineAd' label will be returned // for the slot. // Clear category exclusions so all ads can be returned. slot.clearCategoryExclusions(); // Make an ad request. Any ad can be returned for the slot.
JavaScript (precedente)
// Set category exclusion to exclude ads with 'AirlineAd' labels. var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads()); // Make an ad request. No ad with 'AirlineAd' label will be returned // for the slot. // Clear category exclusions so all ads can be returned. slot.clearCategoryExclusions(); // Make an ad request. Any ad can be returned for the slot.
TypeScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setCategoryExclusion("AirlineAd") .addService(googletag.pubads()); // Make an ad request. No ad with 'AirlineAd' label will be returned // for the slot. // Clear category exclusions so all ads can be returned. slot.clearCategoryExclusions(); // Make an ad request. Any ad can be returned for the slot.
Resi | |
---|---|
Slot | L'oggetto area su cui è stato chiamato il metodo. |
clearTargeting
clearTargeting(key?: string): Slot
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .setTargeting("color", "red") .addService(googletag.pubads()); slot.clearTargeting("color"); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.clearTargeting(); // All targeting has been cleared.
JavaScript (precedente)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .setTargeting("color", "red") .addService(googletag.pubads()); slot.clearTargeting("color"); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.clearTargeting(); // All targeting has been cleared.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .setTargeting("color", "red") .addService(googletag.pubads()); slot.clearTargeting("color"); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.clearTargeting(); // All targeting has been cleared.
- Vedi anche
Parametri | |
---|---|
| Chiave del parametro di targeting. La chiave è facoltativa; se non è specificata, tutti i parametri di targeting verranno cancellati. |
Resi | |
---|---|
Slot | L'oggetto area su cui è stato chiamato il metodo. |
defineSizeMapping
defineSizeMapping(sizeMapping: SizeMappingArray): Slot
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); const mapping = googletag .sizeMapping() .addSize([100, 100], [88, 31]) .addSize( [320, 400], [ [320, 50], [300, 50], ], ) .build(); slot.defineSizeMapping(mapping);
JavaScript (precedente)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); var mapping = googletag .sizeMapping() .addSize([100, 100], [88, 31]) .addSize( [320, 400], [ [320, 50], [300, 50], ], ) .build(); slot.defineSizeMapping(mapping);
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); const mapping = googletag .sizeMapping() .addSize([100, 100], [88, 31]) .addSize( [320, 400], [ [320, 50], [300, 50], ], ) .build(); slot.defineSizeMapping(mapping!);
Parametri | |
---|---|
sizeMapping: SizeMappingArray | Array di mappature delle dimensioni. Puoi utilizzare SizeMappingBuilder per crearlo. Ogni mappatura delle taglie è un array di due elementi: SingleSizeArray e GeneralSize. |
Resi | |
---|---|
Slot | L'oggetto area su cui è stato chiamato il metodo. |
get
get(key: string): null | string
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads()); slot.get("adsense_background_color"); // Returns '#FFFFFF'.
JavaScript (precedente)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads()); slot.get("adsense_background_color"); // Returns '#FFFFFF'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads()); slot.get("adsense_background_color"); // Returns '#FFFFFF'.
- Vedi anche
Parametri | |
---|---|
key: string | Nome dell'attributo da cercare. |
Resi | |
---|---|
null | string | Valore corrente per la chiave dell'attributo o null se la chiave non è presente. |
getAdUnitPath
getAdUnitPath(): string
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
JavaScript (precedente)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
Resi | |
---|---|
string | Percorso dell'unità pubblicitaria. |
getAttributeKeys
getAttributeKeys(): string[]
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .set("adsense_border_color", "#AABBCC") .addService(googletag.pubads()); slot.getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
JavaScript (precedente)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .set("adsense_border_color", "#AABBCC") .addService(googletag.pubads()); slot.getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .set("adsense_background_color", "#FFFFFF") .set("adsense_border_color", "#AABBCC") .addService(googletag.pubads()); slot.getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
Resi | |
---|---|
string[] | Array di chiavi degli attributi. L'ordinamento non è definito. |
getCategoryExclusions
getCategoryExclusions(): string[]
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
JavaScript (precedente)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
Resi | |
---|---|
string[] | Le etichette di esclusione delle categorie di annunci per questo spazio o un array vuoto se non ne sono state impostate. |
getResponseInformation
getResponseInformation(): null | ResponseInformation
null
.Resi | |
---|---|
null | ResponseInformation | Le informazioni più recenti sulla risposta all'annuncio o null se lo spazio non contiene annunci. |
getSlotElementId
getSlotElementId(): string
div
specificata al momento della definizione.- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
JavaScript (precedente)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
Resi | |
---|---|
string | ID area annuncio div . |
getTargeting
getTargeting(key: string): string[]
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .addService(googletag.pubads()); slot.getTargeting("allow_expandable"); // Returns ['true']. slot.getTargeting("age"); // Returns [] (empty array).
JavaScript (precedente)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .addService(googletag.pubads()); slot.getTargeting("allow_expandable"); // Returns ['true']. slot.getTargeting("age"); // Returns [] (empty array).
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setTargeting("allow_expandable", "true") .addService(googletag.pubads()); slot.getTargeting("allow_expandable"); // Returns ['true']. slot.getTargeting("age"); // Returns [] (empty array).
Parametri | |
---|---|
key: string | La chiave di targeting da cercare. |
Resi | |
---|---|
string[] | I valori associati a questa chiave o un array vuoto se non esiste questa chiave. |
getTargetingKeys
getTargetingKeys(): string[]
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .addService(googletag.pubads()); slot.getTargetingKeys(); // Returns ['interests', 'allow_expandable'].
JavaScript (precedente)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .addService(googletag.pubads()); slot.getTargetingKeys(); // Returns ['interests', 'allow_expandable'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .addService(googletag.pubads()); slot.getTargetingKeys(); // Returns ['interests', 'allow_expandable'].
Resi | |
---|---|
string[] | Array di chiavi di targeting. L'ordinamento non è definito. |
set
set(key: string, value: string): Slot
La chiamata di questo metodo più di una volta per la stessa chiave sostituirà i valori impostati in precedenza per la chiave in questione. Tutti i valori devono essere impostati prima di chiamare
display
o refresh
.- Esempio
JavaScript
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
JavaScript (precedente)
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
TypeScript
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div")! .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
- Vedi anche
Parametri | |
---|---|
key: string | Il nome dell'attributo. |
value: string | Valore dell'attributo. |
Resi | |
---|---|
Slot | L'oggetto area su cui è stato chiamato il metodo. |
setCategoryExclusion
setCategoryExclusion(categoryExclusion: string): Slot
- Esempio
JavaScript
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
JavaScript (precedente)
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
TypeScript
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
Parametri | |
---|---|
categoryExclusion: string | L'etichetta di esclusione della categoria di annunci da aggiungere. |
Resi | |
---|---|
Slot | L'oggetto area su cui è stato chiamato il metodo. |
setClickUrl
setClickUrl(value: string): Slot
I server Google Ad Manager registrano comunque un clic anche se l'URL di clic viene sostituito. Qualsiasi URL pagina di destinazione associato alla creatività pubblicata viene aggiunto al valore fornito. Le chiamate successive sovrascrivono il valore. Questo funziona solo per le richieste non SRA.
- Esempio
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
JavaScript (precedente)
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
TypeScript
googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
Parametri | |
---|---|
value: string | L'URL di clic da impostare. |
Resi | |
---|---|
Slot | L'oggetto area su cui è stato chiamato il metodo. |
setCollapseEmptyDiv
setCollapseEmptyDiv(collapse: boolean, collapseBeforeAdFetch?: boolean): Slot
div
deve essere nascosta quando non è presente alcun annuncio. Questo valore sostituisce le impostazioni a livello di servizio.- Esempio
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setCollapseEmptyDiv(true, true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. googletag .defineSlot("/1234567/sports", [160, 600], "div-2") .setCollapseEmptyDiv(true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
JavaScript (precedente)
googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setCollapseEmptyDiv(true, true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. googletag .defineSlot("/1234567/sports", [160, 600], "div-2") .setCollapseEmptyDiv(true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
TypeScript
googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setCollapseEmptyDiv(true, true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. googletag .defineSlot("/1234567/sports", [160, 600], "div-2")! .setCollapseEmptyDiv(true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
Parametri | |
---|---|
collapse: boolean | Indica se comprimere l'area se non viene restituito alcun annuncio. |
| Indica se comprimere l'area anche prima del recupero di un annuncio. Ignorato se collapse non è true . |
Resi | |
---|---|
Slot | L'oggetto area su cui è stato chiamato il metodo. |
setConfig
setConfig(slotConfig: SlotSettingsConfig): void
Parametri | |
---|---|
slotConfig: SlotSettingsConfig | L'oggetto di configurazione. |
setForceSafeFrame
setForceSafeFrame(forceSafeFrame: boolean): Slot
Tieni presente quanto segue quando utilizzi questa API:
- Questa impostazione verrà applicata solo alle richieste di annunci successive effettuate per i rispettivi slot.
- L'impostazione a livello di area, se specificata, sostituirà sempre l'impostazione a livello di pagina.
- Se impostato su
true
(a livello di area annuncio o di pagina), l'annuncio verrà sempre visualizzato utilizzando un contenitore SafeFrame, indipendentemente dalla scelta effettuata nell'interfaccia utente di Google Ad Manager. - Tuttavia, se impostato su
false
o lasciato non specificato, l'annuncio verrà visualizzato utilizzando un contenitore SafeFrame a seconda del tipo di creatività e della selezione effettuata nell'interfaccia utente di Google Ad Manager. - Questa API deve essere utilizzata con cautela in quanto potrebbe influire sul comportamento delle creatività che tentano di uscire dai propri iframe o che si basano sul loro rendering direttamente nella pagina di un publisher.
- Esempio
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setForceSafeFrame(true) .addService(googletag.pubads());
JavaScript (precedente)
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setForceSafeFrame(true) .addService(googletag.pubads());
TypeScript
googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setForceSafeFrame(true) .addService(googletag.pubads());
Parametri | |
---|---|
forceSafeFrame: boolean | true per forzare il rendering di tutti gli annunci in questa area in SafeFrame e false per disattivare un'impostazione a livello di pagina (se presente). Se non specificato a livello di pagina, l'impostazione false non cambia nulla. |
Resi | |
---|---|
Slot | L'oggetto area su cui è stato chiamato il metodo. |
setSafeFrameConfig
setSafeFrameConfig(config: null | SafeFrameConfig): Slot
Queste preferenze a livello di slot, se specificate, sostituiranno eventuali preferenze a livello di pagina.
- Esempio
JavaScript
googletag.pubads().setForceSafeFrame(true); // The following slot will have a sandboxed safeframe that only // disallows top-level navigation. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig({ sandbox: true }) .addService(googletag.pubads()); // The following slot will inherit page-level settings. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
JavaScript (precedente)
googletag.pubads().setForceSafeFrame(true); // The following slot will have a sandboxed safeframe that only // disallows top-level navigation. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig({ sandbox: true }) .addService(googletag.pubads()); // The following slot will inherit page-level settings. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
TypeScript
googletag.pubads().setForceSafeFrame(true); // The following slot will have a sandboxed safeframe that only // disallows top-level navigation. googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setSafeFrameConfig({ sandbox: true }) .addService(googletag.pubads()); // The following slot will inherit page-level settings. googletag.defineSlot("/1234567/news", [160, 600], "div-2")!.addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
Parametri | |
---|---|
config: null | SafeFrameConfig | L'oggetto di configurazione. |
Resi | |
---|---|
Slot | L'oggetto area su cui è stato chiamato il metodo. |
setTargeting
setTargeting(key: string, value: string | string[]): Slot
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Example with a single value for a key. slot.setTargeting("allow_expandable", "true"); // Example with multiple values for a key inside in an array. slot.setTargeting("interests", ["sports", "music"]);
JavaScript (precedente)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Example with a single value for a key. slot.setTargeting("allow_expandable", "true"); // Example with multiple values for a key inside in an array. slot.setTargeting("interests", ["sports", "music"]);
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Example with a single value for a key. slot.setTargeting("allow_expandable", "true"); // Example with multiple values for a key inside in an array. slot.setTargeting("interests", ["sports", "music"]);
- Vedi anche
Parametri | |
---|---|
key: string | Chiave del parametro di targeting. |
value: string | string[] | Valore del parametro di targeting o array di valori. |
Resi | |
---|---|
Slot | L'oggetto area su cui è stato chiamato il metodo. |
updateTargetingFromMap
updateTargetingFromMap(map: {
[adUnitPath: string]: string | string[];
}): Slot
Note:
- In caso di sovrascrittura, verrà mantenuto solo l'ultimo valore.
- Se il valore è un array, qualsiasi valore precedente verrà sovrascritto, non unito.
- I valori impostati qui sovrascriveranno i parametri di targeting impostati a livello di servizio.
- Esempio
JavaScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
JavaScript (precedente)
var slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
TypeScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!; slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
Parametri | |
---|---|
map: { | Mappa chiave:valore del parametro di targeting. |
Resi | |
---|---|
Slot | L'oggetto area su cui è stato chiamato il metodo. |
googletag.config
Interfacce | |
---|---|
Ad | Impostazioni per controllare l'espansione dell'annuncio. |
Component | Un oggetto che rappresenta un'asta di un singolo componente in un'asta di annunci on-device. |
Interstitial | Un oggetto che definisce il comportamento di un singolo spazio annuncio interstitial. |
Page | Interfaccia di configurazione principale per le impostazioni a livello di pagina. |
Privacy | Impostazioni per controllare i trattamenti della privacy del publisher. |
Publisher | Oggetto di configurazione degli indicatori forniti dal publisher (PPS). |
Slot | Interfaccia di configurazione principale per le impostazioni a livello di slot. |
Taxonomy | Un oggetto contenente i valori di una singola tassonomia. |
Alias del tipo | |
---|---|
Interstitial | Attivatori di annunci interstitial supportati. |
Privacy | Trattamenti della privacy del publisher supportati. |
Taxonomy | Tassonomie supportate per gli indicatori forniti dal publisher (PPS). |
Alias del tipo
InterstitialTrigger
InterstitialTrigger: "unhideWindow" | "navBar"
PrivacyTreatment
PrivacyTreatment: "disablePersonalization"
Tassonomia
Taxonomy: "IAB_AUDIENCE_1_1" | "IAB_CONTENT_2_2"
googletag.config.AdExpansionConfig
Proprietà | |
---|---|
enabled | Indica se l'espansione dell'annuncio è attivata o disattivata. |
- Esempio
JavaScript
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
JavaScript (precedente)
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
TypeScript
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
Proprietà
Optional
abilitato
enabled?: null | boolean
L'impostazione di questo valore sostituisce il valore predefinito configurato in Google Ad Manager.
googletag.config.ComponentAuctionConfig
Proprietà | |
---|---|
auction | Un oggetto di configurazione dell'asta per l'asta del componente. |
config | La chiave di configurazione associata a questa asta di componenti. |
Proprietà
auctionConfig
auctionConfig: null | {
auctionSignals?: unknown;
decisionLogicURL: string;
interestGroupBuyers?: string[];
perBuyerExperimentGroupIds?: {
[buyer: string]: number;
};
perBuyerGroupLimits?: {
[buyer: string]: number;
};
perBuyerSignals?: {
[buyer: string]: unknown;
};
perBuyerTimeouts?: {
[buyer: string]: number;
};
seller: string;
sellerExperimentGroupId?: number;
sellerSignals?: unknown;
sellerTimeout?: number;
trustedScoringSignalsURL?: string;
}
Se questo valore è impostato su
null
, qualsiasi configurazione esistente per il configKey
specificato verrà eliminata.- Esempio
JavaScript
const componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicURL's origin seller: "https://testSeller.com", decisionLogicURL: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; const auctionSlot = googletag.defineSlot("/1234567/example", [160, 600]); // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
JavaScript (precedente)
var componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicURL's origin seller: "https://testSeller.com", decisionLogicURL: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; var auctionSlot = googletag.defineSlot("/1234567/example", [160, 600]); // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
TypeScript
const componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicURL's origin seller: "https://testSeller.com", decisionLogicURL: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; const auctionSlot = googletag.defineSlot("/1234567/example", [160, 600])!; // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
configKey
configKey: string
Questo valore non deve essere vuoto e deve essere univoco. Se due oggetti
ComponentAuctionConfig
condividono lo stesso valore configKey, l'ultimo impostato sovrascriverà le configurazioni precedenti.googletag.config.InterstitialConfig
Proprietà | |
---|---|
require | Indica se è necessario il consenso per lo spazio di archiviazione locale per la visualizzazione di questo annuncio interstitial. |
triggers | La configurazione dell'attivatore interstitial per questo annuncio interstitial. |
Proprietà
Optional
requireStorageAccess
requireStorageAccess?: null | boolean
Il GPT utilizza lo spazio di archiviazione locale per applicare una quota limite per gli annunci interstitial. Tuttavia, gli utenti che non hanno fornito il consenso per lo spazio di archiviazione locale sono comunque idonei alla visualizzazione di annunci interstitial. Se imposti questa proprietà su
true
, viene disattivato il comportamento predefinito e gli annunci interstitial vengono mostrati solo agli utenti che hanno fornito il consenso per lo spazio di archiviazione locale.- Esempio
JavaScript
// Opt out of showing interstitials to users // without local storage consent. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, ); interstitialSlot.setConfig({ interstitial: { requireStorageAccess: true, // defaults to false }, });
JavaScript (precedente)
// Opt out of showing interstitials to users // without local storage consent. var interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, ); interstitialSlot.setConfig({ interstitial: { requireStorageAccess: true, // defaults to false }, });
TypeScript
// Opt out of showing interstitials to users // without local storage consent. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, )!; interstitialSlot.setConfig({ interstitial: { requireStorageAccess: true, // defaults to false }, });
Optional
trigger
triggers?: null | Partial<Record<InterstitialTrigger, boolean>>
Se imposti il valore di un attivatore interstitial su
true
, lo attivi, mentre se lo imposti su false
, lo disattivi. Verranno sostituiti i valori predefiniti configurati in Google Ad Manager.- Esempio
JavaScript
// Define a GPT managed web interstitial ad slot. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, ); // Enable optional interstitial triggers. // Change this value to false to disable. const enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
JavaScript (precedente)
// Define a GPT managed web interstitial ad slot. var interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, ); // Enable optional interstitial triggers. // Change this value to false to disable. var enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
TypeScript
// Define a GPT managed web interstitial ad slot. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, )!; // Enable optional interstitial triggers. // Change this value to false to disable. const enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
googletag.config.PageSettingsConfig
Consente di impostare più funzionalità con una singola chiamata API.
Tutte le proprietà elencate di seguito sono esempi e non riflettono le funzionalità effettive che utilizzano setConfig. Per l'insieme di funzionalità, consulta i campi del tipo PageSettingsConfig di seguito.
Esempi:
- Vengono modificate solo le funzionalità specificate nella chiamata googletag.setConfig.
// Configure feature alpha. googletag.setConfig({ alpha: {...} }); // Configure feature bravo. Feature alpha is unchanged. googletag.setConfig({ bravo: {...} });
- Tutte le impostazioni di una determinata funzionalità vengono aggiornate a ogni chiamata a googletag.setConfig.
// Configure feature charlie to echo = 1, foxtrot = true. googletag.setConfig({ charlie: { echo: 1, foxtrot: true, } }); // Update feature charlie to echo = 2. Since foxtrot was not specified, // the value is cleared. googletag.setConfig({ charlie: { echo: 2 } });
- Tutte le impostazioni di una funzionalità possono essere cancellate passando
null
.// Configure features delta, golf, and hotel. googletag.setConfig({ delta: {...}, golf: {...}, hotel: {...}, }); // Feature delta and hotel are cleared, but feature golf remains set. googletag.setConfig({ delta: null, hotel: null, });
Proprietà | |
---|---|
ad | Impostazioni per controllare l'espansione dell'annuncio. |
ad | Deprecato. |
pps | Impostazioni per controllare gli indicatori forniti dal publisher (PPS). |
privacy | Impostazioni per controllare i trattamenti della privacy del publisher. |
thread | Impostazione per controllare se GPT deve restituire il thread JS durante il rendering delle creatività. |
Proprietà
Optional
adExpansion
adExpansion?: null | AdExpansionConfig
Optional
adYield
adYield?: null | "DISABLED" | "ENABLED_ALL_SLOTS"
Optional
pps
pps?: null | PublisherProvidedSignalsConfig
Optional
privacyTreatments
privacyTreatments?: null | PrivacyTreatmentsConfig
Optional
threadYield
threadYield?: null | "DISABLED" | "ENABLED_ALL_SLOTS"
GPT cederà solo per i browser che supportano l'API Scheduler.postTask o Scheduler.yield.
Valori supportati:
null
(valore predefinito): GPT restituisce il thread JS per le aree annuncio al di fuori dell'area visibile.ENABLED_ALL_SLOTS
: GPT restituirà il thread JS per tutte le aree, indipendentemente dal fatto che siano all'interno dell'area visibile.DISABLED
: GPT non restituirà il thread JS.
- Esempio
JavaScript
// Disable yielding. googletag.setConfig({ threadYield: "DISABLED" }); // Enable yielding for all slots. googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" }); // Enable yielding only for slots outside of the viewport (default). googletag.setConfig({ threadYield: null });
JavaScript (precedente)
// Disable yielding. googletag.setConfig({ threadYield: "DISABLED" }); // Enable yielding for all slots. googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" }); // Enable yielding only for slots outside of the viewport (default). googletag.setConfig({ threadYield: null });
TypeScript
// Disable yielding. googletag.setConfig({ threadYield: "DISABLED" }); // Enable yielding for all slots. googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" }); // Enable yielding only for slots outside of the viewport (default). googletag.setConfig({ threadYield: null });
- Vedi anche
googletag.config.PrivacyTreatmentsConfig
Proprietà | |
---|---|
treatments | Una serie di trattamenti della privacy del publisher da attivare. |
Proprietà
cure
treatments: null | "disablePersonalization"[]
- Esempio
JavaScript
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
JavaScript (precedente)
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
TypeScript
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
googletag.config.PublisherProvidedSignalsConfig
Proprietà | |
---|---|
taxonomies | Un oggetto contenente le mappature della tassonomia. |
- Esempio
JavaScript
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 30-34' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
JavaScript (precedente)
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 30-34' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
TypeScript
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 30-34' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
Proprietà
taxonomie
taxonomies: Partial<Record<Taxonomy, TaxonomyData>>
googletag.config.SlotSettingsConfig
Consente di impostare più funzionalità con una singola chiamata API per un singolo slot.
Tutte le proprietà elencate di seguito sono esempi e non riflettono le funzionalità effettive che utilizzano setConfig. Per l'insieme di funzionalità, consulta i campi del tipo SlotSettingsConfig di seguito.
Esempi:
- Vengono modificate solo le funzionalità specificate nella chiamata Slot.setConfig.
const slot = googletag.defineSlot("/1234567/example", [160, 600]); // Configure feature alpha. slot.setConfig({ alpha: {...} }); // Configure feature bravo. Feature alpha is unchanged. slot.setConfig({ bravo: {...} });
- Tutte le impostazioni di una determinata funzionalità vengono aggiornate a ogni chiamata a Slot.setConfig.
// Configure feature charlie to echo = 1, foxtrot = true. slot.setConfig({ charlie: { echo: 1, foxtrot: true, } }); // Update feature charlie to echo = 2. Since foxtrot was not specified, // the value is cleared. slot.setConfig({ charlie: { echo: 2 } });
- Tutte le impostazioni di una funzionalità possono essere cancellate passando
null
.// Configure features delta, golf, and hotel. slot.setConfig({ delta: {...}, golf: {...}, hotel: {...}, }); // Feature delta and hotel are cleared, but feature golf remains set. slot.setConfig({ delta: null, hotel: null, });
Proprietà | |
---|---|
ad | Impostazioni per controllare l'espansione dell'annuncio. |
component | Un array di aste di componenti da includere in un'asta di annunci on-device. |
interstitial | Impostazioni che controllano il comportamento delle aree annuncio interstitial. |
Proprietà
Optional
adExpansion
adExpansion?: null | AdExpansionConfig
Optional
componentAuction
componentAuction?: null | ComponentAuctionConfig[]
Optional
interstitial
interstitial?: null | InterstitialConfig
googletag.config.TaxonomyData
Proprietà | |
---|---|
values | Un elenco di valori Taxonomy. |
Proprietà
values
values: string[]
googletag.enums
Enumerazioni | |
---|---|
Out | Formati fuori pagina supportati da GPT. |
Traffic | Sorgenti di traffico supportate da GPT. |
Enumerazioni
OutOfPageFormat
OutOfPageFormat
- Vedi anche
Membri dell'enumerazione | |
---|---|
BOTTOM_ | Formato di ancoraggio in cui l'area si attacca alla parte inferiore dell'area visibile. |
GAME_ | Formato interstitial manuale di gioco. Nota: l'interstitial manuale di gioco è un formato ad accesso limitato. |
INTERSTITIAL | Formato della creatività interstitial web. |
LEFT_ | Formato del laterale sinistro. |
REWARDED | Formato con premio. |
RIGHT_ | Formato del riquadro laterale destro. |
TOP_ | Formato di ancoraggio in cui l'area si attacca alla parte superiore dell'area visibile. |
TrafficSource
TrafficSource
- Vedi anche
googletag.events
Interfacce | |
---|---|
Event | Interfaccia di base per tutti gli eventi GPT. |
Event | Si tratta di uno pseudo-tipo che mappa un nome di evento al relativo tipo di oggetto evento per Service.addEventListener e Service.removeEventListener. |
Game | Questo evento viene attivato quando un utente chiude uno slot interstitial manuale del gioco. |
Game | Questo evento viene attivato quando uno slot interstitial manuale per i giochi è pronto per essere mostrato all'utente. |
Impression | Questo evento viene attivato quando un'impressione diventa visibile in base ai criteri di Visualizzazione attiva. |
Rewarded | Questo evento viene attivato quando un utente chiude uno spazio annuncio con premio. |
Rewarded | Questo evento viene attivato quando viene concesso un premio per la visualizzazione di un annuncio con premio. |
Rewarded | Questo evento viene attivato quando un annuncio con premio è pronto per essere visualizzato. |
Slot | Questo evento viene attivato quando l'iframe della creatività attiva il relativo evento di caricamento. |
Slot | Questo evento viene attivato quando il codice della creatività viene inserito in uno slot. |
Slot | Questo evento viene attivato quando viene richiesto un annuncio per una determinata area. |
Slot | Questo evento viene attivato quando viene ricevuta una risposta all'annuncio per un determinato slot. |
Slot | Questo evento viene attivato ogni volta che cambia la percentuale sullo schermo dell'area di uno spazio pubblicitario. |
googletag.events.Event
Proprietà | |
---|---|
service | Nome del servizio che ha attivato l'evento. |
slot | Lo slot che ha attivato l'evento. |
Proprietà
serviceName
serviceName: string
slot
slot: Slot
googletag.events.EventTypeMap
Proprietà
gameManualInterstitialSlotClosed
gameManualInterstitialSlotClosed: GameManualInterstitialSlotClosedEvent
gameManualInterstitialSlotReady
gameManualInterstitialSlotReady: GameManualInterstitialSlotReadyEvent
impressionViewable
impressionViewable: ImpressionViewableEvent
rewardedSlotClosed
rewardedSlotClosed: RewardedSlotClosedEvent
rewardedSlotGranted
rewardedSlotGranted: RewardedSlotGrantedEvent
rewardedSlotReady
rewardedSlotReady: RewardedSlotReadyEvent
slotOnload
slotOnload: SlotOnloadEvent
slotRenderEnded
slotRenderEnded: SlotRenderEndedEvent
slotRequested
slotRequested: SlotRequestedEvent
slotResponseReceived
slotResponseReceived: SlotResponseReceived
slotVisibilityChanged
slotVisibilityChanged: SlotVisibilityChangedEvent
googletag.events.GameManualInterstitialSlotClosedEvent
Si estendeNota: l'interstitial manuale di gioco è un formato ad accesso limitato.
Proprietà | |
---|---|
service | Nome del servizio che ha attivato l'evento. Ereditata da |
slot | Lo slot che ha attivato l'evento. Ereditata da |
- Esempio
JavaScript
// This listener is called when a game manual interstitial slot is closed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", (event) => { const slot = event.slot; console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (precedente)
// This listener is called when a game manual interstitial slot is closed. var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", function (event) { var slot = event.slot; console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
// This listener is called when a game manual interstitial slot is closed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", (event) => { const slot = event.slot; console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
googletag.events.GameManualInterstitialSlotReadyEvent
Si estendeNota: l'interstitial manuale di gioco è un formato ad accesso limitato.
Proprietà | |
---|---|
service | Nome del servizio che ha attivato l'evento. Ereditata da |
slot | Lo slot che ha attivato l'evento. Ereditata da |
Metodi | |
---|---|
make | Mostra all'utente l'annuncio interstitial manuale per i giochi. |
- Esempio
JavaScript
// This listener is called when a game manual interstitial slot is ready to // be displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotReady", (event) => { const slot = event.slot; console.log( "Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed.", ); // Replace with custom logic. const displayGmiAd = true; if (displayGmiAd) { event.makeGameManualInterstitialVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (precedente)
// This listener is called when a game manual interstitial slot is ready to // be displayed. var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotReady", function (event) { var slot = event.slot; console.log( "Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed.", ); // Replace with custom logic. var displayGmiAd = true; if (displayGmiAd) { event.makeGameManualInterstitialVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
// This listener is called when a game manual interstitial slot is ready to // be displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotReady", (event) => { const slot = event.slot; console.log( "Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed.", ); // Replace with custom logic. const displayGmiAd = true; if (displayGmiAd) { event.makeGameManualInterstitialVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
Metodi
makeGameManualInterstitialVisible
makeGameManualInterstitialVisible(): void
googletag.events.ImpressionViewableEvent
Si estendeProprietà | |
---|---|
service | Nome del servizio che ha attivato l'evento. Ereditata da |
slot | Lo slot che ha attivato l'evento. Ereditata da |
- Esempio
JavaScript
// This listener is called when an impression becomes viewable. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", (event) => { const slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (precedente)
// This listener is called when an impression becomes viewable. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", function (event) { var slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when an impression becomes viewable. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", (event) => { const slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
googletag.events.RewardedSlotClosedEvent
Si estendeProprietà | |
---|---|
service | Nome del servizio che ha attivato l'evento. Ereditata da |
slot | Lo slot che ha attivato l'evento. Ereditata da |
- Esempio
JavaScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called when the user closes a rewarded ad slot. googletag.pubads().addEventListener("rewardedSlotClosed", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (precedente)
var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called when the user closes a rewarded ad slot. googletag.pubads().addEventListener("rewardedSlotClosed", function (event) { var slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called when the user closes a rewarded ad slot. googletag.pubads().addEventListener("rewardedSlotClosed", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
googletag.events.RewardedSlotGrantedEvent
Si estendeProprietà | |
---|---|
payload | Un oggetto contenente informazioni sul premio concesso. |
service | Nome del servizio che ha attivato l'evento. Ereditata da |
slot | Lo slot che ha attivato l'evento. Ereditata da |
- Esempio
JavaScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotGranted", (event) => { const slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", event.payload?.type); console.log("Reward amount:", event.payload?.amount); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (precedente)
var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotGranted", function (event) { var _a, _b; var slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", (_a = event.payload) === null || _a === void 0 ? void 0 : _a.type); console.log( "Reward amount:", (_b = event.payload) === null || _b === void 0 ? void 0 : _b.amount, ); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotGranted", (event) => { const slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", event.payload?.type); console.log("Reward amount:", event.payload?.amount); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } }); }
Proprietà
payload
payload: null | RewardedPayload
googletag.events.RewardedSlotReadyEvent
Si estendeProprietà | |
---|---|
service | Nome del servizio che ha attivato l'evento. Ereditata da |
slot | Lo slot che ha attivato l'evento. Ereditata da |
Metodi | |
---|---|
make | Mostra l'annuncio con premio. |
- Esempio
JavaScript
// This listener is called when a rewarded ad slot becomes ready to be // displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotReady", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. const userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (precedente)
// This listener is called when a rewarded ad slot becomes ready to be // displayed. var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotReady", function (event) { var slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. var userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
// This listener is called when a rewarded ad slot becomes ready to be // displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotReady", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. const userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
Metodi
makeRewardedVisible
makeRewardedVisible(): void
googletag.events.SlotOnloadEvent
Si estendeSlotOnloadEvent
.Proprietà | |
---|---|
service | Nome del servizio che ha attivato l'evento. Ereditata da |
slot | Lo slot che ha attivato l'evento. Ereditata da |
- Esempio
JavaScript
// This listener is called when a creative iframe load event fires. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { const slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (precedente)
// This listener is called when a creative iframe load event fires. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", function (event) { var slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when a creative iframe load event fires. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { const slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
googletag.events.SlotRenderEndedEvent
Si estendeProprietà | |
---|---|
advertiser | ID inserzionista dell'annuncio visualizzato. |
campaign | L'ID della campagna dell'annuncio visualizzato. |
company | ID delle aziende che hanno fatto offerte per l'annuncio di backfill visualizzato. |
creative | ID creatività dell'annuncio di prenotazione visualizzato. |
creative | L'ID del modello di creatività dell'annuncio di prenotazione visualizzato. |
is | Indica se un annuncio era di backfill. |
is | Indica se è stato restituito un annuncio per l'area. |
label | Deprecato. |
line | ID elemento pubblicitario dell'annuncio di prenotazione visualizzato. |
service | Nome del servizio che ha attivato l'evento. Ereditata da |
size | Indica le dimensioni in pixel della creatività visualizzata. |
slot | Lo slot che ha attivato l'evento. Ereditata da |
slot | Indica se i contenuti dell'area sono stati modificati con l'annuncio visualizzato. |
source | ID creatività dell'annuncio di backfill o della prenotazione visualizzato. |
source | ID elemento pubblicitario dell'annuncio di prenotazione o di backfill visualizzato. |
yield | ID dei gruppi di rendimento per l'annuncio di backfill visualizzato. |
- Esempio
JavaScript
// This listener is called when a slot has finished rendering. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRenderEnded", (event) => { const slot = event.slot; console.group("Slot", slot.getSlotElementId(), "finished rendering."); // Log details of the rendered ad. console.log("Advertiser ID:", event.advertiserId); console.log("Campaign ID:", event.campaignId); console.log("Company IDs:", event.companyIds); console.log("Creative ID:", event.creativeId); console.log("Creative Template ID:", event.creativeTemplateId); console.log("Is backfill?:", event.isBackfill); console.log("Is empty?:", event.isEmpty); console.log("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (precedente)
// This listener is called when a slot has finished rendering. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRenderEnded", function (event) { var slot = event.slot; console.group("Slot", slot.getSlotElementId(), "finished rendering."); // Log details of the rendered ad. console.log("Advertiser ID:", event.advertiserId); console.log("Campaign ID:", event.campaignId); console.log("Company IDs:", event.companyIds); console.log("Creative ID:", event.creativeId); console.log("Creative Template ID:", event.creativeTemplateId); console.log("Is backfill?:", event.isBackfill); console.log("Is empty?:", event.isEmpty); console.log("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when a slot has finished rendering. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRenderEnded", (event) => { const slot = event.slot; console.group("Slot", slot.getSlotElementId(), "finished rendering."); // Log details of the rendered ad. console.log("Advertiser ID:", event.advertiserId); console.log("Campaign ID:", event.campaignId); console.log("Company IDs:", event.companyIds); console.log("Creative ID:", event.creativeId); console.log("Creative Template ID:", event.creativeTemplateId); console.log("Is backfill?:", event.isBackfill); console.log("Is empty?:", event.isEmpty); console.log("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
Proprietà
advertiserId
advertiserId: null | number
null
per gli spazi vuoti, gli annunci di backfill e le creatività visualizzate da servizi diversi da PubAdsService.campaignId
campaignId: null | number
null
per gli spazi vuoti, gli annunci di backfill e le creatività visualizzate da servizi diversi da PubAdsService.companyIds
companyIds: null | number[]
null
per gli spazi vuoti, gli annunci basati su prenotazione e le creatività visualizzate da servizi diversi da PubAdsService.creativeId
creativeId: null | number
null
per gli spazi vuoti, gli annunci di backfill e le creatività visualizzate da servizi diversi da PubAdsService.creativeTemplateId
creativeTemplateId: null | number
null
per gli spazi vuoti, gli annunci di backfill e le creatività visualizzate da servizi diversi da PubAdsService.isBackfill
isBackfill: boolean
true
se l'annuncio è un annuncio di backfill, false
altrimenti.isEmpty
isEmpty: boolean
true
se non è stato restituito alcun annuncio, false
in caso contrario.labelIds
labelIds: null | number[]
lineItemId
lineItemId: null | number
null
per gli spazi vuoti, gli annunci di backfill e le creatività visualizzate da servizi diversi da PubAdsService.size
size: null | string | number[]
[728, 90]
. Il valore è null
per gli spazi pubblicitari vuoti.slotContentChanged
slotContentChanged: boolean
true
se i contenuti sono stati modificati, false
altrimenti.sourceAgnosticCreativeId
sourceAgnosticCreativeId: null | number
null
se l'annuncio non è una prenotazione o un completamento automatico dell'elemento pubblicitario oppure se la creatività viene visualizzata da servizi diversi da PubAdsService.sourceAgnosticLineItemId
sourceAgnosticLineItemId: null | number
null
se l'annuncio non è una prenotazione o un completamento automatico dell'elemento pubblicitario oppure se la creatività viene visualizzata da servizi diversi da PubAdsService.yieldGroupIds
yieldGroupIds: null | number[]
null
per gli spazi vuoti, gli annunci basati su prenotazione e le creatività visualizzate da servizi diversi da PubAdsService.googletag.events.SlotRequestedEvent
Si estendeProprietà | |
---|---|
service | Nome del servizio che ha attivato l'evento. Ereditata da |
slot | Lo slot che ha attivato l'evento. Ereditata da |
- Esempio
JavaScript
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", (event) => { const slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (precedente)
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", function (event) { var slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", (event) => { const slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
googletag.events.SlotResponseReceived
Si estendeProprietà | |
---|---|
service | Nome del servizio che ha attivato l'evento. Ereditata da |
slot | Lo slot che ha attivato l'evento. Ereditata da |
- Esempio
JavaScript
// This listener is called when an ad response has been received // for a slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", (event) => { const slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (precedente)
// This listener is called when an ad response has been received // for a slot. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", function (event) { var slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when an ad response has been received // for a slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", (event) => { const slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
googletag.events.SlotVisibilityChangedEvent
Si estendeProprietà | |
---|---|
in | La percentuale dell'area dell'annuncio visibile. |
service | Nome del servizio che ha attivato l'evento. Ereditata da |
slot | Lo slot che ha attivato l'evento. Ereditata da |
- Esempio
JavaScript
// This listener is called whenever the on-screen percentage of an // ad slot's area changes. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotVisibilityChanged", (event) => { const slot = event.slot; console.group("Visibility of slot", slot.getSlotElementId(), "changed."); // Log details of the event. console.log("Visible area:", `${event.inViewPercentage}%`); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (precedente)
// This listener is called whenever the on-screen percentage of an // ad slot's area changes. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotVisibilityChanged", function (event) { var slot = event.slot; console.group("Visibility of slot", slot.getSlotElementId(), "changed."); // Log details of the event. console.log("Visible area:", "".concat(event.inViewPercentage, "%")); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called whenever the on-screen percentage of an // ad slot's area changes. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotVisibilityChanged", (event) => { const slot = event.slot; console.group("Visibility of slot", slot.getSlotElementId(), "changed."); // Log details of the event. console.log("Visible area:", `${event.inViewPercentage}%`); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
Proprietà
inViewPercentage
inViewPercentage: number
googletag.secureSignals
Interfacce | |
---|---|
Bidder | Restituisce un indicatore sicuro per un offerente specifico. |
Publisher | Restituisce un indicatore sicuro per un publisher specifico. |
Secure | Un'interfaccia per la gestione degli indicatori sicuri. |
Alias del tipo | |
---|---|
Secure | Interfaccia per restituire un indicatore sicuro per un offerente o un fornitore specifico. |
Alias del tipo
SecureSignalProvider
SecureSignalProvider: BidderSignalProvider | PublisherSignalProvider
id
o networkCode
, non entrambi.googletag.secureSignals.BidderSignalProvider
Un fornitore di indicatori sicuri per gli offerenti è costituito da due parti:
- Una funzione di raccolta che restituisce un
Promise
che si risolve in un indicatore sicuro. - Un
id
che identifica l'offerente associato all'indicatore.
Proprietà | |
---|---|
collector | Una funzione che restituisce un Promise che si risolve in un indicatore sicuro. |
id | Un identificatore univoco per il collettore associato a questo indicatore sicuro, come registrato in Google Ad Manager. |
- Esempio
JavaScript
// id is provided googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript (precedente)
// id is provided googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: function () { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
TypeScript
// id is provided googletag.secureSignalProviders!.push({ id: "collector123", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
Proprietà
collectorFunction
collectorFunction: (() => Promise<string>)
Promise
che si risolve in un indicatore sicuro.id
id: string
googletag.secureSignals.PublisherSignalProvider
Un fornitore di indicatori del publisher è costituito da due parti:
- Una funzione di raccolta che restituisce un
Promise
che si risolve in un indicatore sicuro. - Un
networkCode
che identifica il publisher associato all'indicatore.
Proprietà | |
---|---|
collector | Una funzione che restituisce un Promise che si risolve in un indicatore sicuro. |
network | Il codice di rete (come visualizzato nel percorso dell'unità pubblicitaria) del publisher associato a questo indicatore sicuro. |
- Esempio
JavaScript
// networkCode is provided googletag.secureSignalProviders.push({ networkCode: "123456", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript (precedente)
// networkCode is provided googletag.secureSignalProviders.push({ networkCode: "123456", collectorFunction: function () { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
TypeScript
// networkCode is provided googletag.secureSignalProviders!.push({ networkCode: "123456", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
Proprietà
collectorFunction
collectorFunction: (() => Promise<string>)
Promise
che si risolve in un indicatore sicuro.networkCode
networkCode: string
googletag.secureSignals.SecureSignalProvidersArray
Metodi | |
---|---|
clear | Cancella tutti gli indicatori per tutti i collector dalla cache. |
push | Aggiunge un nuovo secureSignals.SecureSignalProvider all'array di fornitori di indicatori e avvia il processo di generazione degli indicatori. |
Metodi
clearAllCache
clearAllCache(): void
La chiamata a questo metodo potrebbe ridurre la probabilità che i segnali vengano inclusi nelle richieste di annunci per le visualizzazioni di pagina attuali e potenzialmente successive. Per questo motivo, deve essere chiamato solo quando si verificano modifiche dello stato significative, ad esempio eventi che indicano un nuovo utente (accesso, logout, registrazione e così via).
push
push(provider: SecureSignalProvider): void
Parametri | |
---|---|
provider: SecureSignalProvider | L'oggetto secureSignals.SecureSignalProvider da aggiungere all'array. |