Questo riferimento utilizza la notazione TypeScript per descrivere i tipi. La tabella seguente fornisce una breve spiegazione con un esempio.
Espressione di tipo | |
---|---|
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 un 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, in cui il 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 .
Tipi di annotazioni
I due punti dopo una variabile, un nome di parametro, un nome di proprietà o una firma di funzione indicano un'annotazione di tipo. Le annotazioni di tipo descrivono i tipi che l'elemento a sinistra dei due punti può accettare o restituire. La tabella seguente mostra esempi di annotazioni di tipo che potresti vedere in questo riferimento.
Annotazione del tipo | |
---|---|
param: string |
Indica che param accetta o restituisce un valore stringa. Questa sintassi viene utilizzata
per variabili, parametri, proprietà e tipi restituiti.
|
param?: number | string |
Indica che param è facoltativo, ma accetta un numero o una stringa
se specificato. Questa sintassi viene utilizzata per parametri e 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 enumerazione. |
events | Questo è lo spazio dei nomi utilizzato da GPT per gli eventi. |
secure | Questo è lo spazio dei nomi utilizzato da GPT per la gestione degli 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 dell'annuncio. |
Rewarded | Un oggetto che rappresenta il premio associato a un annuncio con premio. |
Service | Classe di servizio di base che contiene metodi comuni a tutti i servizi. |
Size | Generatore per oggetti di specifica di mappatura delle dimensioni. |
Slot | Slot è un oggetto che rappresenta una singola area annuncio su una pagina. |
Alias del tipo | |
---|---|
General | Una configurazione delle dimensioni valida per uno slot, che può essere una o più dimensioni. |
Multi | Un elenco di singole dimensioni valide. |
Named | Dimensioni denominate che un'area 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 | Flag che indica che l'API GPT è caricata e pronta per essere chiamata. |
cmd | Riferimento alla coda di comandi globale per l'esecuzione asincrona delle chiamate correlate 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 | Crea uno spazio pubblicitario con un determinato percorso e dimensioni dell'unità pubblicitaria e lo associa 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 Google Publisher Console. |
display | Indica ai servizi di slot di eseguire il rendering dello slot. |
enable | Attiva tutti i servizi GPT definiti per le aree annuncio della pagina. |
get | Recupera le opzioni di configurazione generali per la pagina impostate da setConfig. |
get | Restituisce la versione corrente di GPT. |
open | Apre 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"]
- Flessibile: il contenitore dell'annuncio occupa il 100% della larghezza del div principale e ridimensiona l'altezza per adattarla ai contenuti della creatività. Simile al comportamento dei normali elementi di blocco di una pagina. Utilizzato per gli annunci nativi (vedi l'articolo correlato). Tieni presente che sia
fluid
che['fluid']
sono forme accettabili per dichiarare che le dimensioni di uno spazio pubblicitario sono fluide.
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'async è utilizzare googletag.cmd per mettere in coda i callback quando GPT è pronto. Questi callback non devono controllare googletag.apiReady, in quanto vengono eseguiti una volta configurata l'API.
Const
cmd
cmd: ((this: typeof globalThis) => void)[] | CommandArray
La variabile
googletag.cmd
viene inizializzata in un array JavaScript vuoto dalla sintassi del tag GPT sulla pagina e cmd.push
è il metodo Array.push
standard che aggiunge un elemento alla fine dell'array. Quando viene caricato il codice JavaScript di GPT, questo 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 passato. Questo meccanismo consente a GPT di ridurre la latenza percepita recuperando 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 (legacy)
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 chiamato enableServices e PubAdsService non viene caricato e inizializzato.secureSignalProviders
secureSignalProviders: SecureSignalProvider[] | SecureSignalProvidersArray | undefined
L'array dei fornitori di indicatori sicuri accetta una sequenza di funzioni di generazione degli indicatori e le richiama in ordine. È progettato per sostituire un array standard utilizzato per mettere in coda le funzioni di generazione degli indicatori da richiamare una volta caricata GPT.
- Esempio
JavaScript
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { return Promise.resolve("signal"); }, });
JavaScript (legacy)
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 da 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 (legacy)
// 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 | Il 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 creare uno slot. |
defineSlot
defineSlot(adUnitPath: string, size: GeneralSize, div?: string): Slot | null
- Esempio
JavaScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
JavaScript (legacy)
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
- Vedi anche
Parametri | |
---|---|
adUnitPath: string | Il percorso dell'unità pubblicitaria completo con il codice di rete e il codice dell'unità. |
size: GeneralSize | Larghezza e altezza dello spazio aggiunto. Questa è la dimensione utilizzata nella richiesta di annuncio se non viene fornito alcun mapping delle dimensioni adattabili o se la dimensione dell'area visibile è inferiore alla dimensione più piccola fornita nel mapping. |
| ID del div che conterrà questa unità pubblicitaria. |
Resi | |
---|---|
Slot | null | Lo slot appena creato o null se non è possibile creare uno slot. |
destroySlots
destroySlots(slots?: Slot[]): boolean
La chiamata di questa API su uno slot cancella l'annuncio e rimuove l'oggetto slot dallo stato interno gestito da GPT. La chiamata di altre funzioni sull'oggetto slot comporterà un comportamento indefinito. Tieni presente che il browser potrebbe comunque non liberare la memoria associata a questo slot se viene mantenuto un riferimento alla pagina dell'editore. La chiamata di questa API rende disponibile per il riutilizzo il div associato a questa area annuncio.
In particolare, la distruzione di un'area annuncio rimuove l'annuncio dalla visualizzazione di pagina di lunga durata di GPT, quindi 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 (legacy)
// 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; se non viene specificato, tutti gli slot verranno eliminati. |
Resi | |
---|---|
boolean | true se gli slot sono stati eliminati, false in caso contrario. |
disablePublisherConsole
disablePublisherConsole(): void
- Vedi anche
display
display(divOrSlot: string | Element | Slot): void
Se viene utilizzata l'architettura di richiesta singola (SRA), tutte le aree annunci non recuperate al momento della chiamata a questo metodo verranno recuperate contemporaneamente. Per forzare la mancata visualizzazione di uno spazio pubblicitario, è necessario rimuovere l'intero div.
- Vedi anche
Parametri | |
---|---|
divOrSlot: string | Element | Slot | L'ID dell'elemento div contenente l'area annuncio o l'elemento div oppure l'oggetto slot. Se viene fornito un elemento div, deve avere un attributo "id" che corrisponda all'ID passato a defineSlot. |
enableServices
enableServices(): void
getConfig
getConfig(keys: string | string[]): Pick<PageSettingsConfig, "adsenseAttributes" | "disableInitialLoad" | "targeting">
Non tutte le proprietà
setConfig()
sono supportate da questo metodo. Le proprietà supportate sono:- Esempio
JavaScript
// Get the value of the `targeting` setting. const targetingConfig = googletag.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `disableInitialLoad` settings. const config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
JavaScript (legacy)
// Get the value of the `targeting` setting. var targetingConfig = googletag.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `disableInitialLoad` settings. var config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
TypeScript
// Get the value of the `targeting` setting. const targetingConfig = googletag.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `disableInitialLoad` settings. const config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
Parametri | |
---|---|
keys: string | string[] | Le chiavi delle opzioni di configurazione da recuperare. |
Resi | |
---|---|
Pick<PageSettingsConfig, "adsenseAttributes" | "disableInitialLoad" | "targeting"> | Le opzioni di configurazione per lo slot. |
getVersion
getVersion(): string
- Vedi anche
Resi | |
---|---|
string | La stringa della versione di 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 (legacy)
// 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 | |
---|---|
| ID div di un'area annuncio. Questo valore è facoltativo. Se fornita, la Publisher Console tenterà di aprirsi con i dettagli dello spazio pubblicitario specificato in visualizzazione. |
pubads
pubads(): PubAdsService
Resi | |
---|---|
PubAdsService | Il servizio Publisher Ads. |
setAdIframeTitle
setAdIframeTitle(title: string): void
- Esempio
JavaScript
googletag.setAdIframeTitle("title");
JavaScript (legacy)
googletag.setAdIframeTitle("title");
TypeScript
googletag.setAdIframeTitle("title");
Parametri | |
---|---|
title: string | Il nuovo titolo per tutti gli iframe dei contenitori degli annunci. |
setConfig
setConfig(config: PageSettingsConfig): void
Parametri | |
---|---|
config: PageSettingsConfig |
sizeMapping
sizeMapping(): SizeMappingBuilder
Resi | |
---|---|
SizeMappingBuilder | Un nuovo builder. |
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 (legacy)
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. Il binding di runtime sarà sempre globalThis . Valuta la possibilità di passare una funzione freccia per conservare il valore this del contesto lessicale di inclusione. |
Resi | |
---|---|
number | Il numero di comandi elaborati finora. Questo è compatibile con il valore restituito di Array.push (la lunghezza attuale dell'array). |
googletag.CompanionAdsService
EstendeMetodi | |
---|---|
add | Registra un listener che ti consente di configurare e chiamare una funzione JavaScript quando si verifica un evento GPT specifico nella pagina. Ereditata da |
get | Recupera l'elenco degli slot associati a questo servizio. Ereditata da |
remove | Rimuove un listener registrato in precedenza. Ereditata da |
set | Imposta se le aree companion che non sono ancora riempite verranno riempite automaticamente. |
- Vedi anche
Metodi
setRefreshUnfilledSlots
setRefreshUnfilledSlots(value: boolean): void
Questo metodo può essere chiamato più volte durante il ciclo di vita della pagina per attivare e disattivare il backfill. Verranno riempite solo le aree registrate anche con PubAdsService. A causa delle limitazioni delle norme, questo metodo non è progettato per riempire gli spazi companion vuoti quando viene pubblicato un video di Ad Exchange.
- Esempio
JavaScript
googletag.companionAds().setRefreshUnfilledSlots(true);
JavaScript (legacy)
googletag.companionAds().setRefreshUnfilledSlots(true);
TypeScript
googletag.companionAds().setRefreshUnfilledSlots(true);
Parametri | |
---|---|
value: boolean | true per riempire automaticamente gli spazi vuoti, 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à annunci con limitazioni per soddisfare le esigenze di conformità normativa dei publisher. |
non | Consente di eseguire la pubblicazione in modalità annunci non personalizzati per soddisfare le esigenze di conformità normativa dei publisher. |
restrict | Consente la pubblicazione in modalità di trattamento con limitazioni per soddisfare le esigenze di conformità normativa dei publisher. |
traffic | Indica se le richieste rappresentano traffico acquistato o organico. |
under | Indica se contrassegnare le richieste di annunci come provenienti da utenti sotto l'età del consenso digitale. |
Proprietà
Optional
childDirectedTreatment
childDirectedTreatment?: boolean
null
per cancellare la configurazione.Optional
limitedAds
limitedAds?: boolean
Puoi indicare a GPT di richiedere annunci con limitazioni in due modi:
- Automaticamente, utilizzando un indicatore di una piattaforma di gestione del consenso TCF di IAB v2.0.
- Manualmente, impostando il valore di questo campo su
true
.
Tieni presente che non è necessario attivare manualmente gli annunci con limitazioni quando viene utilizzata 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 (legacy)
// 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 (legacy)
// 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?: boolean
null
per cancellare la configurazione.googletag.PubAdsService
EstendeMetodi | |
---|---|
add | Registra un listener 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 spazi pubblicitari specificati e li sostituisce con contenuti vuoti. |
clear | Obsoleta. Cancella tutte le etichette di esclusione delle categorie di annunci a livello di pagina. |
clear | Obsoleta. Cancella i parametri di targeting personalizzato per una chiave specifica o per tutte le chiavi. |
collapse | Obsoleta. Consente di comprimere i div degli spazi pubblicitari in modo che non occupino spazio sulla pagina quando non sono presenti contenuti dell'annuncio da visualizzare. |
disable | Obsoleta. Disabilita le richieste di annunci durante il caricamento della pagina, ma consente di richiedere gli annunci con una chiamata PubAdsService.refresh. |
display | Crea e mostra un'area annuncio con il percorso e le dimensioni dell'unità pubblicitaria specificati. |
enable | Obsoleta. Attiva il caricamento differito in GPT come definito dall'oggetto di configurazione. |
enable | Obsoleta. Attiva la modalità di richiesta singola per recuperare più annunci contemporaneamente. |
enable | Obsoleta. Indica a GPT che nella pagina saranno presenti annunci video. |
get | Obsoleta. Restituisce il valore dell'attributo AdSense associato alla chiave specificata. |
get | Obsoleta. Restituisce le chiavi degli attributi impostate su questo servizio. |
get | Recupera l'elenco degli slot associati a questo servizio. Ereditata da |
get | Obsoleta. Restituisce un parametro di targeting a livello di servizio personalizzato specifico che è stato impostato. |
get | Obsoleta. Restituisce l'elenco di tutte le chiavi di targeting a livello di servizio personalizzate impostate. |
is | Obsoleta. Restituisce un valore che indica se le richieste iniziali di annunci sono state disattivate correttamente da una precedente chiamata PubAdsService.disableInitialLoad. |
refresh | Recupera e visualizza nuovi annunci per aree specifiche o tutte le aree della pagina. |
remove | Rimuove un listener registrato in precedenza. Ereditata da |
set | Obsoleta. Imposta i valori per gli attributi AdSense che si applicano a tutte le aree annuncio nel servizio Publisher Ads. |
set | Obsoleta. Imposta un'esclusione di categorie di annunci a livello di pagina per il nome dell'etichetta specificato. |
set | Obsoleta. Attiva e disattiva il centraggio orizzontale degli annunci. |
set | Obsoleta. Configura se il rendering di tutti gli annunci nella pagina deve essere forzato utilizzando un contenitore SafeFrame. |
set | Obsoleta. Trasmette le informazioni sulla posizione dai siti web in modo da poter scegliere come target degli elementi pubblicitari 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 dell'ID fornito dal publisher. |
set | Obsoleta. Imposta le preferenze a livello di pagina per la configurazione di SafeFrame. |
set | Obsoleta. Imposta parametri di targeting personalizzato per una determinata chiave che si applicano a tutte le aree annuncio del servizio Publisher Ads. |
set | Obsoleta. Imposta le informazioni sui contenuti video da inviare insieme alle richieste di annuncio per scopi 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, la cancellazione di uno spazio pubblicitario rimuove l'annuncio dalla visualizzazione di pagina a lunga durata di GPT, pertanto le richieste future non saranno influenzate da blocchi stradali 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 (legacy)
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 viene specificato, tutti gli slot verranno cancellati. |
Resi | |
---|---|
boolean | Restituisce true se gli slot sono stati svuotati, false altrimenti. |
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 (legacy)
// 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 (legacy)
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 viene 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 | |
---|---|
| Se comprimere gli spazi 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 compressione della divisione è stata attivata e false se è impossibile attivare la modalità di compressione 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 dello slot e della pagina per garantire la coerenza durante l'invio della richiesta di annuncio e il rendering della risposta. Qualsiasi modifica apportata allo stato dello slot o della pagina dopo la chiamata a questo metodo (inclusi targeting, impostazioni della privacy, forzatura di SafeFrame e così via) verrà applicata solo alle successive richieste
display()
o refresh()
.- Esempio
JavaScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
JavaScript (legacy)
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
- Vedi anche
Parametri | |
---|---|
adUnitPath: string | Il percorso dell'unità pubblicitaria dello spazio da visualizzare. |
size: GeneralSize | Larghezza e altezza dello spazio pubblicitario. |
| L'ID del div contenente lo spazio pubblicitario o l'elemento div stesso. |
| L'URL di clic da utilizzare in questo spazio. |
enableLazyLoad
enableLazyLoad(config?: {
fetchMarginPercent?: number;
mobileScaling?: number;
renderMarginPercent?: number;
}): void
Nota:il recupero lento in SRA funziona solo se tutti gli slot si trovano 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 (legacy)
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 la personalizzazione del 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 la modalità di richiesta singola è stata attivata e false se è impossibile attivare la modalità di richiesta singola perché il metodo è stato chiamato dopo l'attivazione del servizio. |
enableVideoAds
enableVideoAds(): void
get
get(key: string): string
- Esempio
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
JavaScript (legacy)
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 | Il nome dell'attributo da cercare. |
Resi | |
---|---|
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 (legacy)
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 (legacy)
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 una chiave di questo tipo. |
getTargetingKeys
getTargetingKeys(): string[]
- Esempio
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
JavaScript (legacy)
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?: 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
dell'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 spazio rimuove il vecchio annuncio dalla visualizzazione di pagina di lunga durata di GPT, pertanto le richieste future non saranno influenzate da roadblock o esclusioni competitive 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 (legacy)
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 | |
---|---|
| Gli slot da aggiornare. L'array è facoltativo; se non viene specificato, tutti gli slot verranno aggiornati. |
| Opzioni di configurazione associate a questa chiamata di aggiornamento.
|
set
set(key: string, value: string): PubAdsService
Se chiami questa funzione più di una volta per la stessa chiave, i valori impostati in precedenza per quella chiave verranno sovrascritti. Tutti i valori devono essere impostati prima di chiamare
display
o refresh
.- Esempio
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF");
JavaScript (legacy)
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 (legacy)
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
TypeScript
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
Parametri | |
---|---|
categoryExclusion: string | L'etichetta di esclusione delle categorie di annunci da aggiungere. |
Resi | |
---|---|
PubAdsService | L'oggetto servizio su cui è stato chiamato il metodo. |
setCentering
setCentering(centerAds: boolean): void
Questo metodo deve essere richiamato prima di chiamare
display
o refresh
perché verranno centrati solo gli annunci richiesti dopo la chiamata di questo metodo.- Esempio
JavaScript
// Make ads centered. googletag.pubads().setCentering(true);
JavaScript (legacy)
// Make ads centered. googletag.pubads().setCentering(true);
TypeScript
// Make ads centered. googletag.pubads().setCentering(true);
Parametri | |
---|---|
centerAds: boolean | true per centrare gli annunci, false per allinearli a sinistra. |
setForceSafeFrame
setForceSafeFrame(forceSafeFrame: boolean): PubAdsService
Tieni presente quanto segue quando utilizzi questa API:
- Questa impostazione avrà effetto solo sulle successive richieste di annunci effettuate per i rispettivi slot.
- L'impostazione a livello di slot, 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 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 si basano sulla loro visualizzazione diretta in una pagina dei 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 (legacy)
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 l'impostazione precedente su false. Se imposti questo valore su false quando non è stato specificato in precedenza, non cambierà nulla. |
Resi | |
---|---|
PubAdsService | L'oggetto servizio su cui è stato chiamato il metodo. |
setLocation
setLocation(address: string): PubAdsService
- Esempio
JavaScript
// Postal code: googletag.pubads().setLocation("10001,US");
JavaScript (legacy)
// 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 (legacy)
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 (legacy)
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 (legacy)
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 (legacy)
// 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:questa impostazione non ha alcun effetto sulla visualizzazione di pagina a lunga durata di GPT, che riflette automaticamente gli annunci effettivamente presenti nella pagina e non ha una data di 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 (legacy)
// 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 di ordine. |
- Vedi anche
Proprietà
advertiserId
advertiserId: number
campaignId
campaignId: number
creativeId
creativeId: number
creativeTemplateId
creativeTemplateId: number
lineItemId
lineItemId: number
googletag.RewardedPayload
Proprietà | |
---|---|
amount | Il numero di articoli inclusi nel premio. |
type | Il tipo di elemento incluso nella ricompensa (ad esempio, "moneta"). |
- Vedi anche
Proprietà
importo
amount: number
type
type: string
googletag.Service
Metodi | |
---|---|
add | Registra un listener che ti consente di configurare e chiamare una funzione JavaScript quando si verifica un evento GPT specifico nella pagina. |
get | Recupera l'elenco degli slot associati a questo servizio. |
remove | Rimuove un listener 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 (legacy)
// 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. } });
- Vedi anche
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 dell'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 (legacy)
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 dell'oggetto evento. |
googletag.SizeMappingBuilder
Metodi | |
---|---|
add | Aggiunge una mappatura da un array di dimensioni singole (che rappresenta la finestra) a un array di dimensioni singole o multiple che rappresenta lo slot. |
build | Crea una specifica della mappa delle taglie 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 (legacy)
// 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 | La dimensione dell'area visibile per questa voce di mappatura. |
slotSize: GeneralSize | Le dimensioni dello spazio per questa voce di mappatura. |
Resi | |
---|---|
SizeMappingBuilder | Un riferimento a questo generatore. |
build
build(): 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 la chiamata di questo metodo non è definito.
Resi | |
---|---|
SizeMappingArray | Il risultato creato da questo generatore. Può essere null se sono state fornite mappature delle dimensioni non valide. |
googletag.Slot
Metodi | |
---|---|
add | Aggiunge un servizio a questo spazio. |
clear | Obsoleta. Cancella tutte le etichette di esclusione delle categorie di annunci a livello di slot per questo slot. |
clear | Obsoleta. Cancella parametri di targeting a livello di slot personalizzati specifici o tutti per questo slot. |
define | Imposta un array di mappature da una dimensione minima dell'area visibile alla dimensione dello spazio per questo spazio. |
get | Obsoleta. Restituisce il valore dell'attributo AdSense associato alla chiave specificata per questo slot. |
get | Restituisce il percorso completo dell'unità pubblicitaria, con il codice di rete e il percorso dell'unità pubblicitaria. |
get | Obsoleta. Restituisce l'elenco delle chiavi degli attributi impostate in questo slot. |
get | Obsoleta. Restituisce le etichette di esclusione delle categorie di annunci per questo slot. |
get | Recupera le opzioni di configurazione generali per lo slot impostate da setConfig. |
get | Restituisce le informazioni sulla risposta all'annuncio. |
get | Restituisce l'ID dello slot div fornito al momento della definizione dello slot. |
get | Obsoleta. Restituisce un insieme specifico di parametri di targeting personalizzato impostati in questo slot. |
get | Obsoleta. Restituisce l'elenco di tutte le chiavi di targeting personalizzato impostate in questo slot. |
set | Obsoleta. Imposta un valore per un attributo AdSense in questa area annuncio. |
set | Obsoleta. Imposta un'etichetta di esclusione di categorie di annunci a livello di area annuncio. |
set | Obsoleta. Imposta l'URL di clic a cui gli utenti verranno reindirizzati dopo aver fatto clic sull'annuncio. |
set | Obsoleta. 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 | Obsoleta. Configura se il rendering degli annunci in questa area deve essere forzato utilizzando un contenitore SafeFrame. |
set | Obsoleta. Imposta le preferenze a livello di slot per la configurazione di SafeFrame. |
set | Obsoleta. Imposta un parametro di targeting personalizzato per questo slot. |
update | Obsoleta. Imposta i parametri di targeting personalizzati 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 (legacy)
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 slot 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 (legacy)
// 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 slot 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 (legacy)
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 viene specificata, tutti i parametri di targeting verranno cancellati. |
Resi | |
---|---|
Slot | L'oggetto slot 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 (legacy)
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 slot su cui è stato chiamato il metodo. |
get
get(key: string): 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 (legacy)
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 | Il nome dell'attributo da cercare. |
Resi | |
---|---|
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 (legacy)
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 (legacy)
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 attributo. 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 (legacy)
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 slot o un array vuoto se non ne è stata impostata nessuna. |
getConfig
getConfig(keys: string | string[]): Pick<SlotSettingsConfig, "adsenseAttributes" | "targeting" | "categoryExclusion">
Non tutte le proprietà
setConfig()
sono supportate da questo metodo. Le proprietà supportate sono:- Esempio
JavaScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); // Get the value of the `targeting` setting. const targetingConfig = slot.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `categoryExclusion` settings. const config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
JavaScript (legacy)
var slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); // Get the value of the `targeting` setting. var targetingConfig = slot.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `categoryExclusion` settings. var config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
TypeScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!; // Get the value of the `targeting` setting. const targetingConfig = slot.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `categoryExclusion` settings. const config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
Parametri | |
---|---|
keys: string | string[] | Le chiavi delle opzioni di configurazione da recuperare. |
Resi | |
---|---|
Pick<SlotSettingsConfig, "adsenseAttributes" | "targeting" | "categoryExclusion"> | Le opzioni di configurazione per lo slot. |
getResponseInformation
getResponseInformation(): ResponseInformation
null
.Resi | |
---|---|
ResponseInformation | Le informazioni più recenti sulla risposta dell'annuncio o null se l'area non contiene annunci. |
getSlotElementId
getSlotElementId(): string
div
fornito quando è stato definito lo slot.- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
JavaScript (legacy)
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 slot 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 (legacy)
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 una chiave di questo tipo. |
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 (legacy)
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
Se chiami questo metodo più di una volta 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
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
JavaScript (legacy)
// 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 slot 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 (legacy)
// 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 delle categorie di annunci da aggiungere. |
Resi | |
---|---|
Slot | L'oggetto slot su cui è stato chiamato il metodo. |
setClickUrl
setClickUrl(value: string): Slot
I server di 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. 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 (legacy)
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 slot su cui è stato chiamato il metodo. |
setCollapseEmptyDiv
setCollapseEmptyDiv(collapse: boolean, collapseBeforeAdFetch?: boolean): Slot
div
deve essere nascosta quando non è presente alcun annuncio. Esegue l'override delle 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 (legacy)
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 annuncio anche prima del recupero di un annuncio. Ignorato se collapse non è true . |
Resi | |
---|---|
Slot | L'oggetto slot 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 avrà effetto solo sulle successive richieste di annunci effettuate per i rispettivi slot.
- L'impostazione a livello di slot, 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 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 si basano sulla loro visualizzazione diretta in una pagina dei publisher.
- Esempio
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setForceSafeFrame(true) .addService(googletag.pubads());
JavaScript (legacy)
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 questo spazio pubblicitario in SafeFrame e false per disattivare un'impostazione a livello di pagina (se presente). Se non specificato a livello di pagina, l'impostazione su false non cambierà nulla. |
Resi | |
---|---|
Slot | L'oggetto slot su cui è stato chiamato il metodo. |
setSafeFrameConfig
setSafeFrameConfig(config: SafeFrameConfig): Slot
Queste preferenze a livello di slot, se specificate, sostituiranno le 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 (legacy)
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: SafeFrameConfig | L'oggetto di configurazione. |
Resi | |
---|---|
Slot | L'oggetto slot 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 (legacy)
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 slot su cui è stato chiamato il metodo. |
updateTargetingFromMap
updateTargetingFromMap(map: {
[adUnitPath: string]: string | string[];
}): Slot
Note:
- In caso di sovrascrittura, verrà conservato 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 (legacy)
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 slot su cui è stato chiamato il metodo. |
googletag.config
Interfacce | |
---|---|
Ad | Impostazioni per controllare l'espansione degli annunci. |
Ad | Impostazioni per controllare il comportamento degli annunci AdSense. |
Component | Un oggetto che rappresenta una singola asta di componenti in un'asta di annunci on-device. |
Interstitial | Un oggetto che definisce il comportamento di un singolo spazio annuncio interstitial. |
Lazy | Impostazioni per controllare l'utilizzo del caricamento lento in GPT. |
Page | Interfaccia di configurazione principale per le impostazioni a livello di pagina. |
Privacy | Impostazioni per controllare i trattamenti della privacy dei publisher. |
Publisher | Oggetto di configurazione degli indicatori forniti dal publisher (PPS). |
Safe | Impostazioni per controllare SafeFrame in GPT. |
Slot | Interfaccia di configurazione principale per le impostazioni a livello di slot. |
Taxonomy | Un oggetto contenente i valori per una singola tassonomia. |
Video | Impostazioni per configurare le impostazioni correlate agli annunci video. |
Alias del tipo | |
---|---|
Collapse | Valori supportati per controllare il comportamento di compressione delle aree annuncio. |
Interstitial | Attivatori di annunci interstitial supportati. |
Privacy | Trattamenti della privacy dei publisher supportati. |
Taxonomy | Tassonomie supportate per gli indicatori forniti dal publisher (PPS). |
Alias del tipo
CollapseDivBehavior
CollapseDivBehavior: "DISABLED" | "BEFORE_FETCH" | "ON_NO_FILL"
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 (legacy)
// 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?: boolean
L'impostazione di questo valore sostituisce il valore predefinito configurato in Google Ad Manager.
googletag.config.AdSenseAttributesConfig
Questi attributi possono essere utilizzati per eseguire l'override delle impostazioni lato server in base alla richiesta.
Proprietà | |
---|---|
adsense | Formato dell'annuncio AdSense. |
adsense | ID canale AdSense. |
adsense | Indica se la modalità di test è attiva. |
document | Lingua della pagina in cui vengono visualizzati gli annunci. |
page | L'URL della pagina in cui vengono visualizzati gli annunci. |
Proprietà
Optional
adsense_ad_format
adsense_ad_format?: "120x240_as" | "120x600_as" | "125x125_as" | "160x600_as" | "180x150_as" | "200x200_as" | "234x60_as" | "250x250_as" | "300x250_as" | "336x280_as" | "468x60_as" | "728x90_as"
Optional
adsense_channel_ids
adsense_channel_ids?: string
I valori consentiti sono gli ID canale separati da "+".
Esempio:
271828183+314159265
Optional
adsense_test_mode
adsense_test_mode?: "on"
Se impostato su
on
, gli annunci vengono contrassegnati come solo test e non verranno inclusi nel conteggio o nella fatturazione. Questa impostazione deve essere disattivata per il traffico di produzione non di test.Optional
document_language
document_language?: string
I valori consentiti sono codici lingua ISO 639-1 validi.
Esempio:
en
- Vedi anche
Optional
page_url
page_url?: string
I valori consentiti sono URL validi.
Esempio:
http://www.example.com
googletag.config.ComponentAuctionConfig
Proprietà | |
---|---|
auction | Un oggetto di configurazione dell'asta per l'asta di questo componente. |
config | La chiave di configurazione associata a questa asta di componenti. |
Proprietà
auctionConfig
auctionConfig: {
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 l'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 (legacy)
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 l'archiviazione locale per visualizzare questo annuncio interstitial. |
triggers | La configurazione del trigger interstitial per questo annuncio interstitial. |
Proprietà
Optional
requireStorageAccess
requireStorageAccess?: boolean
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 pubblicazione di annunci interstitial. Se imposti questa proprietà su
true
, disattivi il comportamento predefinito e garantisci che gli annunci interstitial vengano 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 (legacy)
// 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?: Partial<Record<InterstitialTrigger, boolean>>
Se imposti il valore di un trigger interstitial su
true
, questo verrà attivato, mentre se lo imposti su false
, verrà disattivato. In questo modo, verranno sovrascritti 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 (legacy)
// 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.LazyLoadConfig
Proprietà | |
---|---|
fetch | La distanza minima dall'area visibile attuale che deve avere un'area annuncio prima di richiedere un annuncio, espressa come percentuale delle dimensioni dell'area visibile. |
mobile | Un moltiplicatore applicato ai margini sui dispositivi mobili. |
render | La distanza minima dall'area visibile attuale a cui deve trovarsi uno spazio prima che venga visualizzato un annuncio, espressa come percentuale della dimensione dell'area visibile. |
- Vedi anche
Proprietà
Optional
fetchMarginPercent
fetchMarginPercent?: number
Utilizzata insieme a renderMarginPercent, questa impostazione consente di precaricare un annuncio, ma di attendere il rendering e il download di altre risorse secondarie. Pertanto, questo valore deve essere sempre maggiore o uguale a renderMarginPercent.
Un valore di
0
significa "quando lo spazio pubblicitario entra nell'area visibile", 100
significa "quando l'annuncio si trova a un'area visibile di distanza" e così via.Optional
mobileScaling
mobileScaling?: number
Ciò consente di avere margini diversi su dispositivi mobili e computer, dove le dimensioni dell'area visibile e le velocità di scorrimento possono essere diverse. Ad esempio, un valore di 2,0 moltiplicherà tutti i margini per 2 sui dispositivi mobili, aumentando la distanza minima che uno slot può avere dall'area visibile prima del recupero e del rendering.
Optional
renderMarginPercent
renderMarginPercent?: number
Utilizzata insieme a fetchMarginPercent, questa impostazione consente di precaricare un annuncio, ma di attendere per visualizzare e scaricare altre risorse secondarie. Pertanto, questo valore deve essere sempre minore o uguale a fetchMarginPercent.
Un valore di
0
significa "quando lo spazio pubblicitario entra nel riquadro visibile", 100
significa "quando l'annuncio si trova a un riquadro visibile di distanza" e così via.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à, vedi i campi all'interno 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 per 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 degli annunci. |
adsense | Impostazione per configurare gli attributi AdSense. |
ad | Deprecato. |
category | Impostazione per configurare le esclusioni di categorie di annunci. |
centering | Impostazione per controllare il centraggio orizzontale degli annunci. |
collapse | Impostazione per controllare il comportamento di compressione delle aree annunci. |
disable | Impostazione per controllare quando vengono richieste le pubblicità. |
lazy | Impostazioni per controllare l'utilizzo del caricamento lento in GPT. |
location | Impostazione per il targeting geografico degli elementi pubblicitari in base alle località geografiche. |
pps | Impostazioni per controllare gli indicatori forniti dal publisher (PPS). |
privacy | Impostazioni per controllare i trattamenti della privacy dei publisher. |
safe | Impostazioni per controllare l'utilizzo di SafeFrame in GPT. |
single | Impostazione per attivare o disattivare l'architettura di richiesta singola (SRA). |
targeting | Impostazione per controllare il targeting per coppie chiave-valore. |
thread | Impostazione per controllare se GPT deve cedere il thread JS durante la richiesta e il rendering delle creatività. |
video | Impostazioni per controllare gli annunci video. |
Proprietà
Optional
adExpansion
adExpansion?: AdExpansionConfig
Optional
adsenseAttributes
adsenseAttributes?: AdSenseAttributesConfig
Gli attributi AdSense configurati tramite questa impostazione verranno applicati a tutte le aree annuncio della pagina. Questa impostazione può essere chiamata più volte per definire più valori degli attributi o sovrascrivere i valori esistenti.
Le modifiche agli attributi AdSense vengono applicate solo agli annunci richiesti dopo la chiamata di questo metodo. Per questo motivo, è consigliabile chiamare questo metodo prima di qualsiasi chiamata a googletag.display o PubAdsService.refresh.
- Esempio
JavaScript
// Set the document language and page URL. googletag.setConfig({ adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" }, }); // Clear the page URL only. googletag.setConfig({ adsenseAttributes: { page_url: null } }); // Clear all AdSense attributes. googletag.setConfig({ adsenseAttributes: null });
JavaScript (legacy)
// Set the document language and page URL. googletag.setConfig({ adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" }, }); // Clear the page URL only. googletag.setConfig({ adsenseAttributes: { page_url: null } }); // Clear all AdSense attributes. googletag.setConfig({ adsenseAttributes: null });
TypeScript
// Set the document language and page URL. googletag.setConfig({ adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" }, }); // Clear the page URL only. googletag.setConfig({ adsenseAttributes: { page_url: null } }); // Clear all AdSense attributes. googletag.setConfig({ adsenseAttributes: null });
Optional
adYield
adYield?: "DISABLED" | "ENABLED_ALL_SLOTS"
Optional
categoryExclusion
categoryExclusion?: string[]
- Esempio
JavaScript
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"] }); // Clearing category exclusion setting. googletag.setConfig({ categoryExclusion: null });
JavaScript (legacy)
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"] }); // Clearing category exclusion setting. googletag.setConfig({ categoryExclusion: null });
TypeScript
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"] }); // Clearing category exclusion setting. googletag.setConfig({ categoryExclusion: null });
Optional
centratura
centering?: boolean
Le modifiche alla centratura orizzontale si applicano solo agli annunci richiesti dopo la chiamata di questo metodo. Per questo motivo, è consigliabile chiamare questo metodo prima di qualsiasi chiamata a googletag.display o PubAdsService.refresh.
- Esempio
JavaScript
// Make ads centered. googletag.setConfig({ centering: true }); // Clear the centering setting. googletag.setConfig({ centering: null });
JavaScript (legacy)
// Make ads centered. googletag.setConfig({ centering: true }); // Clear the centering setting. googletag.setConfig({ centering: null });
TypeScript
// Make ads centered. googletag.setConfig({ centering: true }); // Clear the centering setting. googletag.setConfig({ centering: null });
Optional
collapseDiv
collapseDiv?: CollapseDivBehavior
Un'area annuncio compressa non occupa spazio nella pagina.
Valori supportati:
null
(impostazione predefinita): lo spazio non verrà compresso.DISABLED
: l'area non verrà compressa, indipendentemente dal fatto che venga restituito o meno un annuncio.BEFORE_FETCH
: l'area inizierà compressa e si espanderà quando verrà restituito un annuncio.ON_NO_FILL
: l'area inizierà espansa e si comprimerà se non viene restituito alcun annuncio.
- Esempio
JavaScript
// Collapse the div for this slot if no ad is returned. googletag.setConfig({ collapseDiv: "ON_NO_FILL" }); // Collapse the div for this slot by default, and expand only // if an ad is returned. googletag.setConfig({ collapseDiv: "BEFORE_FETCH" }); // Do not collapse the div for this slot. googletag.setConfig({ collapseDiv: "DISABLED" }); // Clear the collapse setting. googletag.setConfig({ collapseDiv: null });
JavaScript (legacy)
// Collapse the div for this slot if no ad is returned. googletag.setConfig({ collapseDiv: "ON_NO_FILL" }); // Collapse the div for this slot by default, and expand only // if an ad is returned. googletag.setConfig({ collapseDiv: "BEFORE_FETCH" }); // Do not collapse the div for this slot. googletag.setConfig({ collapseDiv: "DISABLED" }); // Clear the collapse setting. googletag.setConfig({ collapseDiv: null });
TypeScript
// Collapse the div for this slot if no ad is returned. googletag.setConfig({ collapseDiv: "ON_NO_FILL" }); // Collapse the div for this slot by default, and expand only // if an ad is returned. googletag.setConfig({ collapseDiv: "BEFORE_FETCH" }); // Do not collapse the div for this slot. googletag.setConfig({ collapseDiv: "DISABLED" }); // Clear the collapse setting. googletag.setConfig({ collapseDiv: null });
Optional
disableInitialLoad
disableInitialLoad?: boolean
Per impostazione predefinita, il metodo googletag.display registra le aree annuncio e richiede gli annunci per queste aree. Tuttavia, a volte potrebbe essere preferibile separare queste azioni per controllare in modo più preciso il momento in cui viene caricato il contenuto dell'annuncio.
Se abiliti questa impostazione, gli annunci non verranno richiesti per gli slot registrati quando viene chiamato il metodo
display()
. Al contrario, per avviare una richiesta di annuncio deve essere effettuata una chiamata separata a PubAdsService.refresh.Questo metodo deve essere chiamato prima di chiamare googletag.enableServices.
- Esempio
JavaScript
// Prevent requesting ads when `display()` is called. googletag.setConfig({ disableInitialLoad: true });
JavaScript (legacy)
// Prevent requesting ads when `display()` is called. googletag.setConfig({ disableInitialLoad: true });
TypeScript
// Prevent requesting ads when `display()` is called. googletag.setConfig({ disableInitialLoad: true });
Optional
lazyLoad
lazyLoad?: LazyLoadConfig
Il caricamento lento è una tecnica per ritardare la richiesta e il rendering degli annunci finché non si avvicinano all'area visibile dell'utente. Per un esempio più dettagliato, consulta l'esempio di caricamento differito.
Nota:se
singleRequest
è attivato, il recupero differito funziona solo quando tutti gli slot si trovano al di fuori del margine di recupero.Qualsiasi impostazione di caricamento differito non specificata durante la chiamata di
setConfig()
utilizzerà un valore predefinito impostato da Google. Questi valori predefiniti potrebbero essere modificati nel tempo. Per disattivare una determinata impostazione, imposta il valore su null
.- Esempio
JavaScript
// Enable lazy loading. googletag.setConfig({ lazyLoad: { // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, }, }); // Clear fetch margin only. googletag.setConfig({ lazyLoad: { fetchMarginPercent: null }, }); // Clear all lazy loading settings. googletag.setConfig({ lazyLoad: null });
JavaScript (legacy)
// Enable lazy loading. googletag.setConfig({ lazyLoad: { // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, }, }); // Clear fetch margin only. googletag.setConfig({ lazyLoad: { fetchMarginPercent: null }, }); // Clear all lazy loading settings. googletag.setConfig({ lazyLoad: null });
TypeScript
// Enable lazy loading. googletag.setConfig({ lazyLoad: { // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, }, }); // Clear fetch margin only. googletag.setConfig({ lazyLoad: { fetchMarginPercent: null }, }); // Clear all lazy loading settings. googletag.setConfig({ lazyLoad: null });
Optional
posizione
location?: string
- Esempio
JavaScript
// Geo-target line items to US postal code 10001. googletag.setConfig({ location: "10001,US" }); // Clear the location setting. googletag.setConfig({ location: null });
JavaScript (legacy)
// Geo-target line items to US postal code 10001. googletag.setConfig({ location: "10001,US" }); // Clear the location setting. googletag.setConfig({ location: null });
TypeScript
// Geo-target line items to US postal code 10001. googletag.setConfig({ location: "10001,US" }); // Clear the location setting. googletag.setConfig({ location: null });
Optional
pps
Optional
privacyTreatments
privacyTreatments?: PrivacyTreatmentsConfig
Optional
safeFrame
safeFrame?: SafeFrameConfig
I valori configurati tramite questa impostazione verranno applicati a tutte le aree annuncio della pagina. Le singole aree annuncio possono ignorare questi valori tramite SlotSettingsConfig.safeFrame.
- Esempio
JavaScript
// Force SafeFrame for all ads on the page. googletag.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion. googletag.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting. googletag.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings. googletag.setConfig({ safeFrame: null });
JavaScript (legacy)
// Force SafeFrame for all ads on the page. googletag.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion. googletag.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting. googletag.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings. googletag.setConfig({ safeFrame: null });
TypeScript
// Force SafeFrame for all ads on the page. googletag.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion. googletag.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting. googletag.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings. googletag.setConfig({ safeFrame: null });
Optional
singleRequest
singleRequest?: boolean
Quando l'SRA è attivata, tutte le aree annuncio definite prima di una chiamata googletag.display o PubAdsService.refresh vengono raggruppate in una singola richiesta di annuncio. Ciò offre vantaggi in termini di rendimento, ma è anche necessario per garantire che i roadblock e le esclusioni competitive vengano rispettati.
Quando la SRA è disattivata, ogni area annuncio viene richiesta singolarmente. Questo è il comportamento predefinito di GPT.
Questo metodo deve essere chiamato prima di chiamare googletag.enableServices.
- Esempio
JavaScript
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
JavaScript (legacy)
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
TypeScript
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
Optional
targeting
targeting?: Record<string, string | string[]>
Il targeting configurato tramite questa impostazione verrà applicato a tutte le aree annuncio nella pagina. Questa impostazione può essere chiamata più volte per definire più coppie chiave-valore di targeting o sovrascrivere i valori esistenti. Le chiavi di targeting sono definite nel tuo account Google Ad Manager.
- Esempio
JavaScript
// Setting a single targeting key-value. googletag.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key googletag.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. googletag.setConfig({ targeting: { interests: null } });
JavaScript (legacy)
// Setting a single targeting key-value. googletag.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key googletag.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. googletag.setConfig({ targeting: { interests: null } });
TypeScript
// Setting a single targeting key-value. googletag.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key googletag.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. googletag.setConfig({ targeting: { interests: null } });
- Vedi anche
Optional
threadYield
threadYield?: "DISABLED" | "ENABLED_ALL_SLOTS"
GPT cederà solo per i browser che supportano l'API Scheduler.postTask o Scheduler.yield.
Valori supportati:
null
(impostazione predefinita): GPT cederà il thread JS per gli slot al di fuori della finestra.ENABLED_ALL_SLOTS
: GPT genererà il thread JS per tutti gli slot, indipendentemente dal fatto che lo slot si trovi all'interno dell'area visibile.DISABLED
: GPT non genererà 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 (legacy)
// 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
Optional
videoAds
videoAds?: VideoAdsConfig
- Esempio
JavaScript
// Enable video ads and set video content and content source IDs. googletag.setConfig({ videoAds: { enableVideoAds: true, videoContentId: "e1eGlRL7ju8", videoCmsId: "1234567", }, });
JavaScript (legacy)
// Enable video ads and set video content and content source IDs. googletag.setConfig({ videoAds: { enableVideoAds: true, videoContentId: "e1eGlRL7ju8", videoCmsId: "1234567", }, });
TypeScript
// Enable video ads and set video content and content source IDs. googletag.setConfig({ videoAds: { enableVideoAds: true, videoContentId: "e1eGlRL7ju8", videoCmsId: "1234567", }, });
- Vedi anche
googletag.config.PrivacyTreatmentsConfig
Proprietà | |
---|---|
treatments | Un array di trattamenti della privacy per i publisher da attivare. |
Proprietà
trattamenti
treatments: "disablePersonalization"[]
- Esempio
JavaScript
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
JavaScript (legacy)
// 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 mappature Taxonomy o null per cancellare la configurazione. |
- 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 (legacy)
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à
tassonomie
taxonomies: Partial<Record<Taxonomy, TaxonomyData>>
googletag.config.SafeFrameConfig
Proprietà | |
---|---|
allow | Se SafeFrame deve consentire l'espansione dei contenuti dell'annuncio sovrapponendoli ai contenuti della pagina. |
allow | Se SafeFrame deve consentire l'espansione dei contenuti dell'annuncio spostando i contenuti della pagina. |
force | Indica se il rendering degli annunci deve essere forzato utilizzando un contenitore SafeFrame. |
sandbox | Indica se SafeFrame deve utilizzare l'attributo sandbox HTML5 per impedire la navigazione di livello superiore senza interazione dell'utente. |
use | Obsoleta. Se SafeFrame deve utilizzare sottodomini casuali per le creatività di prenotazione. |
Proprietà
Optional
allowOverlayExpansion
allowOverlayExpansion?: boolean
Optional
allowPushExpansion
allowPushExpansion?: boolean
Optional
forceSafeFrame
forceSafeFrame?: boolean
Optional
sandbox
sandbox?: boolean
true
(non può essere forzato a false
). Tieni presente che l'attributo sandbox disattiva i plug-in (ad es. Flash).Optional
useUniqueDomain
useUniqueDomain?: boolean
null
per cancellare il valore memorizzato.Nota: questa funzionalità è attivata per impostazione predefinita.
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à, vedi i campi all'interno 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 per 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 configurare l'espansione degli annunci. |
adsense | Impostazione per configurare gli attributi AdSense. |
category | Impostazione per configurare le esclusioni di categorie di annunci. |
click | Impostazione per configurare l'URL a cui gli utenti verranno reindirizzati dopo aver fatto clic sull'annuncio. |
collapse | Impostazione per configurare il comportamento di compressione dello spazio pubblicitario. |
component | Un array di aste dei componenti da includere in un'asta di annunci on-device. |
interstitial | Impostazioni che configurano il comportamento dello spazio pubblicitario interstitial. |
safe | Impostazioni per configurare l'utilizzo di SafeFrame in GPT. |
targeting | Impostazione per configurare il targeting per coppie chiave-valore. |
Proprietà
Optional
adExpansion
adExpansion?: AdExpansionConfig
- Vedi anche
Optional
adsenseAttributes
adsenseAttributes?: AdSenseAttributesConfig
Gli attributi AdSense configurati tramite questa impostazione verranno applicati solo allo spazio pubblicitario. Questa impostazione può essere chiamata più volte per definire più valori degli attributi o sovrascrivere i valori esistenti.
Le modifiche agli attributi AdSense vengono applicate solo agli annunci richiesti dopo la chiamata di questo metodo. Per questo motivo, è consigliabile chiamare questo metodo prima di qualsiasi chiamata a googletag.display o PubAdsService.refresh.
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Set the AdSense ad format and channel IDs. slot.setConfig({ adsenseAttributes: { adsense_ad_format: "120x240_as", adsense_channel_ids: "271828183+314159265", }, }); // Clear the AdSense channel IDs only. slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } }); // Clear all AdSense attributes. slot.setConfig({ adsenseAttributes: null });
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Set the AdSense ad format and channel IDs. slot.setConfig({ adsenseAttributes: { adsense_ad_format: "120x240_as", adsense_channel_ids: "271828183+314159265", }, }); // Clear the AdSense channel IDs only. slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } }); // Clear all AdSense attributes. slot.setConfig({ adsenseAttributes: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Set the AdSense ad format and channel IDs. slot.setConfig({ adsenseAttributes: { adsense_ad_format: "120x240_as", adsense_channel_ids: "271828183+314159265", }, }); // Clear the AdSense channel IDs only. slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } }); // Clear all AdSense attributes. slot.setConfig({ adsenseAttributes: null });
Optional
categoryExclusion
categoryExclusion?: string[]
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Label = AirlineAd slot.setConfig({ categoryExclusion: ["AirlineAd"], }); // Clearing category exclusion setting. slot.setConfig({ categoryExclusion: null });
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Label = AirlineAd slot.setConfig({ categoryExclusion: ["AirlineAd"], }); // Clearing category exclusion setting. slot.setConfig({ categoryExclusion: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Label = AirlineAd slot.setConfig({ categoryExclusion: ["AirlineAd"], }); // Clearing category exclusion setting. slot.setConfig({ categoryExclusion: null });
Optional
clickUrl
clickUrl?: string
I server di 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. Se imposti questo valore più di una volta, sovrascriverai qualsiasi valore configurato in precedenza. Se inserisci
null
, il valore verrà cancellato.Nota:questa impostazione si applica solo alle richieste non SRA.
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Sets the click URL to 'http://www.example.com?original_click_url='. slot.setConfig({ clickUrl: "http://www.example.com?original_click_url=", }); // Clears the click URL. slot.setConfig({ clickUrl: null, });
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Sets the click URL to 'http://www.example.com?original_click_url='. slot.setConfig({ clickUrl: "http://www.example.com?original_click_url=", }); // Clears the click URL. slot.setConfig({ clickUrl: null, });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Sets the click URL to 'http://www.example.com?original_click_url='. slot.setConfig({ clickUrl: "http://www.example.com?original_click_url=", }); // Clears the click URL. slot.setConfig({ clickUrl: null, });
Optional
collapseDiv
collapseDiv?: CollapseDivBehavior
Un'area annuncio compressa non occupa spazio nella pagina.
Valori supportati:
null
(impostazione predefinita): lo spazio non verrà compresso.DISABLED
: l'area non verrà compressa, indipendentemente dal fatto che venga restituito o meno un annuncio.BEFORE_FETCH
: l'area inizierà compressa e si espanderà quando verrà restituito un annuncio.ON_NO_FILL
: l'area inizierà espansa e si comprimerà se non viene restituito alcun annuncio.
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Collapse the div for this slot if no ad is returned. slot.setConfig({ collapseDiv: "ON_NO_FILL", }); // Collapse the div for this slot by default, and expand only // if an ad is returned. slot.setConfig({ collapseDiv: "BEFORE_FETCH", }); // Do not collapse the div for this slot. slot.setConfig({ collapseDiv: "DISABLED", }); // Clear the collapse setting. slot.setConfig({ collapseDiv: null, });
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Collapse the div for this slot if no ad is returned. slot.setConfig({ collapseDiv: "ON_NO_FILL", }); // Collapse the div for this slot by default, and expand only // if an ad is returned. slot.setConfig({ collapseDiv: "BEFORE_FETCH", }); // Do not collapse the div for this slot. slot.setConfig({ collapseDiv: "DISABLED", }); // Clear the collapse setting. slot.setConfig({ collapseDiv: null, });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Collapse the div for this slot if no ad is returned. slot.setConfig({ collapseDiv: "ON_NO_FILL", }); // Collapse the div for this slot by default, and expand only // if an ad is returned. slot.setConfig({ collapseDiv: "BEFORE_FETCH", }); // Do not collapse the div for this slot. slot.setConfig({ collapseDiv: "DISABLED", }); // Clear the collapse setting. slot.setConfig({ collapseDiv: null, });
Optional
componentAuction
componentAuction?: ComponentAuctionConfig[]
Optional
interstitial
interstitial?: InterstitialConfig
Optional
safeFrame
safeFrame?: SafeFrameConfig
I valori configurati tramite questa impostazione verranno applicati solo all'area annuncio e sostituiranno i valori impostati tramite PageSettingsConfig.safeFrame.
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Force SafeFrame for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion for the slot. slot.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings for the slot. slot.setConfig({ safeFrame: null });
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Force SafeFrame for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion for the slot. slot.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings for the slot. slot.setConfig({ safeFrame: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Force SafeFrame for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion for the slot. slot.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings for the slot. slot.setConfig({ safeFrame: null });
Optional
targeting
targeting?: Record<string, string | string[]>
Il targeting configurato tramite questa impostazione verrà applicato solo all'area annuncio. Questa impostazione può essere chiamata più volte per definire più coppie chiave-valore di targeting o sovrascrivere i valori esistenti. Le chiavi di targeting sono definite nel tuo account Google Ad Manager.
- Esempio
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Setting a single targeting key-value. slot.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key. slot.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. slot.setConfig({ targeting: { interests: null } }); // Clear all targeting keys. slot.setConfig({ targeting: null });
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Setting a single targeting key-value. slot.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key. slot.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. slot.setConfig({ targeting: { interests: null } }); // Clear all targeting keys. slot.setConfig({ targeting: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Setting a single targeting key-value. slot.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key. slot.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. slot.setConfig({ targeting: { interests: null } }); // Clear all targeting keys. slot.setConfig({ targeting: null });
- Vedi anche
googletag.config.TaxonomyData
Proprietà | |
---|---|
values | Un elenco di valori di tassonomia. |
Proprietà
values
values: readonly string[]
googletag.config.VideoAdsConfig
Proprietà | |
---|---|
enable | Indica se gli annunci video saranno presenti sulla pagina. |
video | L'ID dell'origine di contenuti video. |
video | L'ID dei contenuti video. |
- Vedi anche
Proprietà
enableVideoAds
enableVideoAds: boolean
Se impostato su
true
, vengono attivati i vincoli di esclusione dei contenuti per gli annunci display e video.Se i contenuti video sono noti, imposta videoContentId e videoCmsId sui valori forniti al servizio di importazione dei contenuti di Google Ad Manager per utilizzare l'esclusione dei contenuti per gli annunci display.
Optional
videoCmsId
videoCmsId?: string
Si tratta di un valore univoco assegnato dal servizio di importazione dei contenuti di Google Ad Manager per identificare la fonte dei contenuti video specificati da videoContentId.
- Vedi anche
Optional
videoContentId
videoContentId?: string
Si tratta di un valore univoco che identifica un determinato video dall'origine di contenuti specificata da videoCmsId. Questo valore viene assegnato dal CMS che ospita i tuoi contenuti video.
- Vedi anche
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 | |
---|---|
AD_ | Formato degli annunci per intenzione. |
BOTTOM_ | Formato ancorato in cui lo spazio pubblicitario rimane nella 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 laterale destro. |
TOP_ | Formato ancorato in cui lo spazio pubblicitario rimane nella 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 un pseudo-tipo che mappa un nome evento al tipo di oggetto evento corrispondente per Service.addEventListener e Service.removeEventListener. |
Game | Questo evento viene attivato quando uno spazio interstitial per il manuale di gioco è stato chiuso dall'utente. |
Game | Questo evento viene attivato quando un'area annuncio interstitial manuale per i giochi è pronta per essere mostrata 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 uno spazio pubblicitario con premio viene chiuso dall'utente. |
Rewarded | Questo evento viene attivato quando viene assegnato un premio per la visualizzazione di un annuncio con premio. |
Rewarded | Questo evento viene attivato quando un annuncio con premio è pronto per essere visualizzato. |
Rewarded | Questo evento viene attivato al termine della riproduzione di un annuncio video con premio. |
Slot | Questo evento viene attivato quando l'iframe della creatività attiva l'evento di caricamento. |
Slot | Questo evento viene attivato quando il codice della creatività viene inserito in uno slot. |
Slot | Questo evento viene attivato quando è stato richiesto un annuncio per un determinato slot. |
Slot | Questo evento viene attivato quando è stata ricevuta una risposta all'annuncio per un determinato slot. |
Slot | Questo evento viene attivato ogni volta che la percentuale sullo schermo dell'area di uno spazio pubblicitario cambia. |
googletag.events.Event
Proprietà | |
---|---|
service | Il nome del servizio che ha attivato l'evento. |
slot | Lo slot che ha attivato l'evento. |
- Vedi anche
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
rewardedSlotVideoCompleted
rewardedSlotVideoCompleted: RewardedSlotVideoCompletedEvent
slotOnload
slotOnload: SlotOnloadEvent
slotRenderEnded
slotRenderEnded: SlotRenderEndedEvent
slotRequested
slotRequested: SlotRequestedEvent
slotResponseReceived
slotResponseReceived: SlotResponseReceived
slotVisibilityChanged
slotVisibilityChanged: SlotVisibilityChangedEvent
googletag.events.GameManualInterstitialSlotClosedEvent
EstendeNota:l'interstitial manuale per giochi è un formato ad accesso limitato.
Proprietà | |
---|---|
service | Il 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 (legacy)
// 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
EstendeNota:l'interstitial manuale per i giochi è un formato ad accesso limitato.
Proprietà | |
---|---|
service | Il 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 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 (legacy)
// 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
EstendeProprietà | |
---|---|
service | Il 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 (legacy)
// 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. } });
- Vedi anche
googletag.events.RewardedSlotClosedEvent
EstendeProprietà | |
---|---|
service | Il 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 (legacy)
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
EstendeProprietà | |
---|---|
payload | Un oggetto contenente informazioni sul premio assegnato. |
service | Il 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 (legacy)
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: RewardedPayload
googletag.events.RewardedSlotReadyEvent
EstendeProprietà | |
---|---|
service | Il 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 (legacy)
// 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.RewardedSlotVideoCompletedEvent
EstendeProprietà | |
---|---|
service | Il 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 video in a rewarded ad slot has // finished playing. googletag.pubads().addEventListener("rewardedSlotVideoCompleted", (event) => { const slot = event.slot; console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing."); if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (legacy)
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 video in a rewarded ad slot has // finished playing. googletag.pubads().addEventListener("rewardedSlotVideoCompleted", function (event) { var slot = event.slot; console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing."); 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 video in a rewarded ad slot has // finished playing. googletag.pubads().addEventListener("rewardedSlotVideoCompleted", (event) => { const slot = event.slot; console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing."); if (slot === targetSlot) { // Slot specific logic. } }); }
googletag.events.SlotOnloadEvent
EstendeSlotOnloadEvent
.Proprietà | |
---|---|
service | Il 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 (legacy)
// 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. } });
- Vedi anche
googletag.events.SlotRenderEndedEvent
EstendeProprietà | |
---|---|
advertiser | ID inserzionista dell'annuncio visualizzato. |
campaign | L'ID campagna dell'annuncio visualizzato. |
company | Gli ID delle società che hanno fatto offerte per l'annuncio di backfill visualizzato. |
creative | L'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 un annuncio di backfill. |
is | Indica se è stato restituito un annuncio per lo slot. |
label | Deprecato. |
line | ID elemento pubblicitario dell'annuncio di prenotazione visualizzato. |
response | L'identificatore della risposta è un identificatore univoco per la risposta all'annuncio. |
service | Il 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 dello spazio sono stati modificati con l'annuncio visualizzato. |
source | ID creatività dell'annuncio di prenotazione o di backfill 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 (legacy)
// 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. } });
- Vedi anche
Proprietà
advertiserId
advertiserId: number
null
per gli spazi vuoti, gli annunci di backfill e le creatività visualizzate da servizi diversi da PubAdsService.campaignId
campaignId: number
null
per gli spazi vuoti, gli annunci di backfill e le creatività visualizzate da servizi diversi da PubAdsService.companyIds
companyIds: number[]
null
per gli spazi vuoti, gli annunci basati su prenotazione e le creatività visualizzate da servizi diversi da PubAdsService.creativeId
creativeId: number
null
per gli spazi vuoti, gli annunci di backfill e le creatività visualizzate da servizi diversi da PubAdsService.creativeTemplateId
creativeTemplateId: 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 era un annuncio di backfill, false
altrimenti.isEmpty
isEmpty: boolean
true
se non è stato restituito alcun annuncio, false
altrimenti.labelIds
labelIds: number[]
lineItemId
lineItemId: number
null
per gli spazi vuoti, gli annunci di backfill e le creatività visualizzate da servizi diversi da PubAdsService.responseIdentifier
responseIdentifier: string
size
size: string | number[]
[728, 90]
. Il valore è null
per le aree annuncio vuote.slotContentChanged
slotContentChanged: boolean
true
se i contenuti sono stati modificati, false
altrimenti.sourceAgnosticCreativeId
sourceAgnosticCreativeId: number
null
se l'annuncio non è una prenotazione o un riempimento dell'elemento pubblicitario oppure se la creatività viene visualizzata da servizi diversi da PubAdsService.sourceAgnosticLineItemId
sourceAgnosticLineItemId: number
null
se l'annuncio non è una prenotazione o un riempimento dell'elemento pubblicitario oppure se la creatività viene visualizzata da servizi diversi da PubAdsService.yieldGroupIds
yieldGroupIds: number[]
null
per gli spazi vuoti, gli annunci basati su prenotazione e le creatività visualizzate da servizi diversi da PubAdsService.googletag.events.SlotRequestedEvent
EstendeProprietà | |
---|---|
service | Il 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 (legacy)
// 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. } });
- Vedi anche
googletag.events.SlotResponseReceived
EstendeProprietà | |
---|---|
service | Il 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 (legacy)
// 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. } });
- Vedi anche
googletag.events.SlotVisibilityChangedEvent
EstendeProprietà | |
---|---|
in | La percentuale dell'area dell'annuncio visibile. |
service | Il 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 (legacy)
// 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. } });
- Vedi anche
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
, ma non entrambi.googletag.secureSignals.BidderSignalProvider
Un fornitore di indicatori sicuri per gli offerenti è composto 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 raccoglitore 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 (legacy)
// 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 è composto 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) per il 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 (legacy)
// 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 dalla cache tutti gli indicatori per tutti i raccoglitori. |
push | Aggiunge un nuovo secureSignals.SecureSignalProvider all'array di fornitori di indicatori e avvia la procedura di generazione degli indicatori. |
Metodi
clearAllCache
clearAllCache(): void
La chiamata a questo metodo potrebbe ridurre la probabilità che gli indicatori vengano inclusi nelle richieste di annunci per le visualizzazioni di pagina attuali e potenzialmente successive. Per questo motivo, il metodo deve essere chiamato solo in caso di modifiche di stato significative, come eventi che indicano un nuovo utente (accesso, disconnessione, iscrizione e così via).
push
push(provider: SecureSignalProvider): void
Parametri | |
---|---|
provider: SecureSignalProvider | L'oggetto secureSignals.SecureSignalProvider da aggiungere all'array. |