W tym dokumencie referencyjnym do opisywania typów używamy notacji TypeScript. W tabeli poniżej znajdziesz krótkie wyjaśnienie na przykładzie.
Wpisz wyrażenie | |
---|---|
string |
Typ ciągu znaków pierwotnych. |
string[] |
Typ tablicy, w której wartości mogą być tylko ciągami znaków. |
number | string |
Typ unii, w którym wartość może być liczbą lub ciągiem znaków. |
Array<number | string> |
Typ tablicy, w której wartości są typem złożonym (union). |
[number, string] |
Typ krotki, w którym wartość jest dwuelementową tablicą, która musi zawierać liczbę i ciąg znaków w tej kolejności. |
Slot |
Typ obiektu, w którym wartość jest instancją googletag.Slot . |
() => void |
Typ funkcji bez zdefiniowanych argumentów i wartości zwracanej. |
Więcej informacji o obsługiwanych typach i wyrażeniach typów znajdziesz w podręczniku TypeScript .
Adnotacje dotyczące typu
Dwukropek po zmiennej, nazwie parametru, nazwie właściwości lub sygnaturze funkcji oznacza adnotację typu. Adnotacje typu opisują typy, które element po lewej stronie dwukropka może akceptować lub zwracać. W tabeli poniżej znajdziesz przykłady adnotacji typów, które mogą się pojawić w tym dokumencie.
Adnotacja typu | |
---|---|
param: string |
Wskazuje, że param akceptuje lub zwraca wartość ciągu znaków. Ta składnia jest używana w przypadku zmiennych, parametrów, właściwości i typów zwracanych.
|
param?: number | string |
Oznacza, że param jest opcjonalne, ale w przypadku podania akceptuje liczbę lub ciąg znaków. Ta składnia jest używana w przypadku parametrów i właściwości.
|
...params: Array<() => void> |
Wskazuje, że params jest
parametrem reszty
, który akceptuje funkcje. Parametry reszty przyjmują nieograniczoną liczbę wartości określonego typu.
|
googletag
Przestrzenie nazw | |
---|---|
config | Główny interfejs konfiguracji ustawień na poziomie strony. |
enums | Jest to przestrzeń nazw, której GPT używa w przypadku typów wyliczeniowych. |
events | Jest to przestrzeń nazw, której GPT używa w przypadku zdarzeń. |
secure | Jest to przestrzeń nazw, której GPT używa do zarządzania bezpiecznymi sygnałami. |
Interfejsy | |
---|---|
Command | Tablica poleceń akceptuje sekwencję funkcji i wywołuje je w odpowiedniej kolejności. |
Companion | usługi Reklamy towarzyszące. |
Privacy | Obiekt konfiguracji ustawień prywatności. |
Pub | usługi Reklamy wydawcy. |
Response | Obiekt reprezentujący pojedynczą odpowiedź reklamy. |
Rewarded | Obiekt reprezentujący nagrodę związaną z reklamą z nagrodą. |
Service | Klasa usługi bazowej, która zawiera metody wspólne dla wszystkich usług. |
Size | Konstruktor obiektów specyfikacji mapowania rozmiarów. |
Slot | Slot to obiekt reprezentujący pojedynczy boks reklamowy na stronie. |
Aliasy typu | |
---|---|
General | Prawidłowa konfiguracja rozmiaru boksu, która może obejmować jeden lub kilka rozmiarów. |
Multi | Lista pojedynczych prawidłowych rozmiarów. |
Named | Nazwane rozmiary, które może mieć boks. |
Single | Pojedynczy prawidłowy rozmiar miejsca docelowego. |
Single | Tablica 2 liczb reprezentujących [szerokość, wysokość]. |
Size | Mapowanie rozmiaru widocznego obszaru na rozmiary reklam. |
Size | Lista mapowań rozmiarów. |
Zmienne | |
---|---|
api | Flaga wskazująca, że interfejs GPT API jest załadowany i gotowy do wywołania. |
cmd | Odwołanie do globalnej kolejki poleceń do asynchronicznego wykonywania wywołań związanych z GPT. |
pubads | Flaga wskazująca, że usługa PubAdsService jest włączona, załadowana i w pełni funkcjonalna. |
secure | Odwołanie do tablicy dostawców bezpiecznych sygnałów. |
Funkcje | |
---|---|
companion | Zwraca odwołanie do CompanionAdsService. |
define | Tworzy boks reklamowy poza stroną o podanej ścieżce jednostki reklamowej. |
define | Tworzy boks reklamowy o podanej ścieżce i rozmiarze jednostki reklamowej oraz powiązuje go z identyfikatorem elementu div na stronie, który będzie zawierać reklamę. |
destroy | Usuwa podane boksy reklamowe, usuwając z GPT wszystkie powiązane z nimi obiekty i odniesienia. |
disable | Wyłącza Konsolę Google dla wydawcy. |
display | Instruuje usługi związane z miejscem reklamowym, aby renderowały to miejsce. |
enable | Włącza wszystkie usługi GPT zdefiniowane dla boksów reklamowych na stronie. |
get | Pobiera ogólne opcje konfiguracji strony ustawione przez funkcję setConfig. |
get | Zwraca bieżącą wersję GPT. |
open | Otwiera Konsolę Google dla wydawcy. |
pubads | Zwraca odwołanie do PubAdsService. |
set | Ustawia tytuł wszystkich elementów iframe kontenera reklamy utworzonych przez PubAdsService od tego momentu. |
set | Ustawia ogólne opcje konfiguracji strony. |
size | Tworzy nowy obiekt SizeMappingBuilder. |
Aliasy typu
GeneralSize
GeneralSize: SingleSize | MultiSize
MultiSize
MultiSize: SingleSize[]
NamedSize
NamedSize: "fluid" | ["fluid"]
- elastyczny: kontener reklamy zajmuje 100% szerokości kontenera nadrzędnego, a następnie zmienia wysokość, aby dopasować się do treści kreacji. Podobnie jak zwykłe elementy blokowe na stronie. Używany w przypadku reklam natywnych (patrz powiązany artykuł). Pamiętaj, że zarówno
fluid
, jak i['fluid']
to akceptowane formy deklarowania płynnego rozmiaru boksu.
SingleSize
SingleSize: SingleSizeArray | NamedSize
SingleSizeArray
SingleSizeArray: [number, number]
SizeMapping
SizeMapping: [SingleSizeArray, GeneralSize]
SizeMappingArray
SizeMappingArray: SizeMapping[]
Zmienne
Const
apiReady
apiReady: boolean | undefined
undefined
, dopóki interfejs API nie będzie gotowy.Pamiętaj, że zalecanym sposobem obsługi asynchroniczności jest używanie funkcji googletag.cmd do kolejkowania wywołań zwrotnych na czas, gdy GPT będzie gotowy. Te wywołania zwrotne nie muszą sprawdzać stanu googletag.apiReady, ponieważ na pewno zostaną wykonane po skonfigurowaniu interfejsu API.
Const
cmd
cmd: ((this: typeof globalThis) => void)[] | CommandArray
Zmienna
googletag.cmd
jest inicjowana jako pusta tablica JavaScript przez składnię tagu GPT na stronie, a cmd.push
to standardowa metoda Array.push
, która dodaje element na końcu tablicy. Po wczytaniu kodu JavaScript GPT przegląda tablicę i wykonuje wszystkie funkcje w odpowiedniej kolejności. Następnie skrypt zastępuje symbol cmd
obiektem CommandArray, którego metoda push jest zdefiniowana tak, aby wykonywać argument funkcji przekazany do niej. Ten mechanizm pozwala GPT zmniejszyć odczuwalne opóźnienie przez asynchroniczne pobieranie kodu JavaScript, umożliwiając jednocześnie przeglądarce dalsze renderowanie strony.- Przykład
JavaScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
JavaScript (starsza wersja)
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
, dopóki nie zostanie wywołana funkcja enableServices oraz nie zostanie załadowana i zainicjowana usługa PubAdsService.secureSignalProviders
secureSignalProviders: SecureSignalProvider[] | SecureSignalProvidersArray | undefined
Tablica dostawców bezpiecznych sygnałów akceptuje sekwencję funkcji generujących sygnały i wywołuje je w odpowiedniej kolejności. Ma ona zastąpić standardową tablicę używaną do kolejkowania funkcji generujących sygnały, które mają być wywoływane po załadowaniu GPT.
- Przykład
JavaScript
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { return Promise.resolve("signal"); }, });
JavaScript (starsza wersja)
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"); }, });
Funkcje
companionAds
companionAds(): CompanionAdsService
Zwroty | |
---|---|
CompanionAdsService | usługi Reklamy towarzyszące, |
defineOutOfPageSlot
defineOutOfPageSlot(adUnitPath: string, div?: string | OutOfPageFormat): Slot | null
W przypadku niestandardowych reklam poza stroną
div
to identyfikator elementu div, który będzie zawierać reklamę. Więcej informacji znajdziesz w artykule o kreacjach poza stroną.W przypadku reklam poza stroną zarządzanych przez GPT
div
jest obsługiwanym formatem OutOfPageFormat.- Przykład
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 (starsza wersja)
// 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);
- Zobacz też
Parametry | |
---|---|
adUnitPath: string | Pełna ścieżka jednostki reklamowej z kodem sieci i kodem jednostki reklamowej. |
| Identyfikator elementu div, który będzie zawierać tę jednostkę reklamową, lub OutOfPageFormat. |
Zwroty | |
---|---|
Slot | null | Nowo utworzony przedział lub null , jeśli nie można utworzyć przedziału. |
defineSlot
defineSlot(adUnitPath: string, size: GeneralSize, div?: string): Slot | null
- Przykład
JavaScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
JavaScript (starsza wersja)
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
- Zobacz też
Parametry | |
---|---|
adUnitPath: string | Pełna ścieżka jednostki reklamowej z kodem sieci i kodem jednostki. |
size: GeneralSize | Szerokość i wysokość dodanego boksu. Ten rozmiar jest używany w żądaniu reklamy, jeśli nie podano mapowania rozmiarów elastycznych lub rozmiar obszaru wyświetlania jest mniejszy niż najmniejszy rozmiar podany w mapowaniu. |
| Identyfikator elementu div, który będzie zawierać tę jednostkę reklamową. |
Zwroty | |
---|---|
Slot | null | Nowo utworzony przedział lub null , jeśli nie można utworzyć przedziału. |
destroySlots
destroySlots(slots?: Slot[]): boolean
Wywołanie tego interfejsu API w przypadku miejsca docelowego powoduje wyczyszczenie reklamy i usunięcie obiektu miejsca docelowego ze stanu wewnętrznego utrzymywanego przez GPT. Wywoływanie kolejnych funkcji w obiekcie slot spowoduje zachowanie niezgodne z oczekiwaniami. Pamiętaj, że przeglądarka może nadal nie zwalniać pamięci powiązanej z tym miejscem, jeśli strona wydawcy zachowuje do niego odwołanie. Wywołanie tego interfejsu API powoduje, że element div powiązany z tym boksem reklamowym jest dostępny do ponownego użycia.
W szczególności zlikwidowanie boksu reklamowego usuwa reklamę z długotrwałego wyświetlenia strony w GPT, więc przyszłe żądania nie będą podlegać blokadom ani wykluczeniom konkurencji związanym z tą reklamą. Jeśli nie wywołasz tej funkcji przed usunięciem elementu div gniazda ze strony, wystąpi nieokreślone zachowanie.
- Przykład
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 (starsza wersja)
// 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();
Parametry | |
---|---|
| Tablica pól do zniszczenia. Tablica jest opcjonalna. Jeśli nie zostanie określona, wszystkie miejsca zostaną zniszczone. |
Zwroty | |
---|---|
boolean | true , jeśli miejsca zostały usunięte, w przeciwnym razie false . |
disablePublisherConsole
disablePublisherConsole(): void
- Zobacz też
wyświetlacz
display(divOrSlot: string | Element | Slot): void
Jeśli używana jest architektura z pojedynczym żądaniem (SRA), wszystkie niepobrane boksy reklamowe w momencie wywołania tej metody zostaną pobrane naraz. Aby wymusić niewyświetlanie boksu reklamowego, musisz usunąć cały element div.
- Zobacz też
Parametry | |
---|---|
divOrSlot: string | Element | Slot | Identyfikator elementu div zawierającego miejsce na reklamę, element div lub obiekt miejsca na reklamę. Jeśli podano element div, musi on mieć atrybut „id”, który pasuje do identyfikatora przekazanego do funkcji defineSlot. |
enableServices
enableServices(): void
getConfig
getConfig(keys: string | string[]): Pick<PageSettingsConfig, "adsenseAttributes" | "disableInitialLoad" | "targeting">
Ta metoda nie obsługuje wszystkich właściwości
setConfig()
. Obsługiwane właściwości:- Przykład
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 (starsza wersja)
// 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"]);
Parametry | |
---|---|
keys: string | string[] | Klucze opcji konfiguracji do pobrania. |
Zwroty | |
---|---|
Pick<PageSettingsConfig, "adsenseAttributes" | "disableInitialLoad" | "targeting"> | Opcje konfiguracji slota. |
getVersion
getVersion(): string
- Zobacz też
Zwroty | |
---|---|
string | Ciąg znaków bieżącej wersji tagu GPT. |
openConsole
openConsole(div?: string): void
- Przykład
JavaScript
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
JavaScript (starsza wersja)
// 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();
- Zobacz też
Parametry | |
---|---|
| Identyfikator elementu div boksu reklamowego. Ta wartość jest opcjonalna. Jeśli zostanie podany, Konsola wydawcy spróbuje otworzyć się z wyświetlonymi szczegółami określonego miejsca na reklamę. |
pubads
pubads(): PubAdsService
Zwroty | |
---|---|
PubAdsService | usługi Reklamy wydawców, |
setAdIframeTitle
setAdIframeTitle(title: string): void
- Przykład
JavaScript
googletag.setAdIframeTitle("title");
JavaScript (starsza wersja)
googletag.setAdIframeTitle("title");
TypeScript
googletag.setAdIframeTitle("title");
Parametry | |
---|---|
title: string | Nowy tytuł wszystkich elementów iframe kontenerów reklam. |
setConfig
setConfig(config: PageSettingsConfig): void
Parametry | |
---|---|
config: PageSettingsConfig |
sizeMapping
sizeMapping(): SizeMappingBuilder
googletag.CommandArray
Metody | |
---|---|
push | Wykonuje kolejno funkcje określone w argumentach. |
Metody
push
push(...f: ((this: typeof globalThis) => void)[]): number
- Przykład
JavaScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
JavaScript (starsza wersja)
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()); });
Parametry | |
---|---|
| Funkcja JavaScript do wykonania. Wiązanie w czasie działania będzie zawsze miało wartość globalThis . Rozważ przekazanie funkcji strzałkowej, aby zachować wartość this otaczającego kontekstu leksykalnego. |
Zwroty | |
---|---|
number | Liczba przetworzonych do tej pory poleceń. Jest to zgodne z wartością zwracaną przez Array.push (bieżącą długością tablicy). |
googletag.CompanionAdsService
PrzedłużaMetody | |
---|---|
add | Rejestruje detektor, który umożliwia skonfigurowanie i wywołanie funkcji JavaScriptu, gdy na stronie wystąpi określone zdarzenie GPT. Odziedziczone z: |
get | Pobierz listę miejsc powiązanych z tą usługą. Odziedziczone z: |
remove | Usuwa wcześniej zarejestrowanego detektora. Odziedziczone z: |
set | Określa, czy puste boksy towarzyszące mają być automatycznie wypełniane reklamami zapasowymi. |
Metody
setRefreshUnfilledSlots
setRefreshUnfilledSlots(value: boolean): void
Tę metodę można wywoływać wielokrotnie w trakcie działania strony, aby włączać i wyłączać wypełnianie reklamami zapasowymi. Wypełniane będą tylko boksy zarejestrowane w usłudze PubAdsService. Ze względu na ograniczenia wynikające z zasad ta metoda nie jest przeznaczona do wypełniania pustych miejsc na kreacje towarzyszące, gdy wyświetlana jest reklama wideo Ad Exchange.
- Przykład
JavaScript
googletag.companionAds().setRefreshUnfilledSlots(true);
JavaScript (starsza wersja)
googletag.companionAds().setRefreshUnfilledSlots(true);
TypeScript
googletag.companionAds().setRefreshUnfilledSlots(true);
Parametry | |
---|---|
value: boolean | true – automatyczne wypełnianie niewypełnionych miejsc, false – pozostawienie ich bez zmian. |
googletag.PrivacySettingsConfig
Właściwości | |
---|---|
child | Wskazuje, czy strona powinna być traktowana jako skierowana do dzieci. |
limited | Umożliwia wyświetlanie reklam w trybie ograniczonego wyświetlania reklam, aby pomóc wydawcom w spełnianiu wymagań prawnych. |
non | Umożliwia wyświetlanie reklam w trybie reklam niespersonalizowanych, aby pomóc wydawcom w spełnianiu wymagań dotyczących zgodności z przepisami. |
restrict | Umożliwia wyświetlanie reklam w trybie ograniczonego przetwarzania, aby pomóc wydawcom w spełnianiu wymagań dotyczących zgodności z przepisami. |
traffic | Wskazuje, czy żądania reprezentują ruch kupiony czy bezpłatny. |
under | Wskazuje, czy żądania reklamy mają być oznaczane jako pochodzące od użytkowników, którzy nie osiągnęli wieku samodzielnego wyrażania zgody. |
- Zobacz też
Właściwości
Optional
childDirectedTreatment
childDirectedTreatment?: boolean
null
, aby wyczyścić konfigurację.Optional
limitedAds
limitedAds?: boolean
Informacje o konieczności żądania reklam w ramach ograniczonego wyświetlania mogą być przesyłane do GPT na 2 sposoby:
- Automatycznie, za pomocą sygnału z platformy do zarządzania zgodą użytkowników zgodnej z zasadami IAB TCF w wersji 2.0.
- Ręcznie, ustawiając wartość tego pola na
true
.
Pamiętaj, że w przypadku korzystania z platformy CMP nie musisz ręcznie włączać ograniczonego wyświetlania reklam.
- Przykład
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 (starsza wersja)
// 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, });
Optional
nonPersonalizedAds
nonPersonalizedAds?: boolean
Optional
restrictDataProcessing
restrictDataProcessing?: boolean
Optional
trafficSource
trafficSource?: TrafficSource
undefined
.- Przykład
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 (starsza wersja)
// 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
, aby wyczyścić konfigurację.googletag.PubAdsService
PrzedłużaMetody | |
---|---|
add | Rejestruje detektor, który umożliwia skonfigurowanie i wywołanie funkcji JavaScriptu, gdy na stronie wystąpi określone zdarzenie GPT. Odziedziczone z: |
clear | Usuwa reklamy z określonych miejsc i zastępuje je pustą treścią. |
clear | Usuwa wszystkie etykiety wykluczenia kategorii reklam na poziomie strony. |
clear | Usuwa parametry kierowania niestandardowego dla określonego klucza lub wszystkich kluczy. |
collapse | Umożliwia zwijanie elementów div boksów reklamowych, aby nie zajmowały miejsca na stronie, gdy nie ma treści reklamy do wyświetlenia. |
disable | Wyłącza żądania reklam podczas wczytywania strony, ale umożliwia wysyłanie żądań reklam za pomocą wywołania PubAdsService.refresh. |
display | Tworzy i wyświetla boks reklamowy o podanej ścieżce i rozmiarze jednostki reklamowej. |
enable | Włącza w GPT leniwe ładowanie zdefiniowane przez obiekt konfiguracji. |
enable | Włącza tryb pojedynczego żądania, który umożliwia pobieranie wielu reklam jednocześnie. |
enable | Sygnały do tagu GPT, że na stronie będą wyświetlane reklamy wideo. |
get | Zwraca wartość atrybutu AdSense powiązanego z danym kluczem. |
get | Zwraca klucze atrybutów, które zostały ustawione w tej usłudze. |
get | Pobierz listę miejsc powiązanych z tą usługą. Odziedziczone z: |
get | Zwraca określony niestandardowy parametr kierowania na poziomie usługi, który został ustawiony. |
get | Zwraca listę wszystkich niestandardowych kluczy kierowania na poziomie usługi, które zostały ustawione. |
is | Zwraca informację, czy początkowe żądania reklam zostały wyłączone przez poprzednie wywołanie funkcji PubAdsService.disableInitialLoad. |
refresh | Pobiera i wyświetla nowe reklamy w określonych lub wszystkich boksach na stronie. |
remove | Usuwa wcześniej zarejestrowanego detektora. Odziedziczone z: |
set | Ustawia wartości atrybutów AdSense, które mają zastosowanie do wszystkich boksów reklamowych w usłudze Reklamy wydawców. |
set | Ustawia wykluczenie kategorii reklamy na poziomie strony dla podanej nazwy etykiety. |
set | Włącza i wyłącza wyśrodkowywanie reklam w poziomie. |
set | Określa, czy wszystkie reklamy na stronie mają być renderowane w kontenerze SafeFrame. |
set | Przekazuje informacje o lokalizacji z witryn, dzięki czemu możesz kierować elementy zamówienia na określone lokalizacje geograficzne. |
set | Umożliwia skonfigurowanie wszystkich ustawień prywatności za pomocą jednego interfejsu API przy użyciu obiektu konfiguracji. |
set | Ustawia wartość identyfikatora podawanego przez wydawcę. |
set | Ustawia preferencje na poziomie strony dotyczące konfiguracji SafeFrame. |
set | Ustawia niestandardowe parametry kierowania dla danego klucza, które mają zastosowanie do wszystkich miejsc na reklamy w usłudze Publisher Ads. |
set | Ustawia informacje o treściach wideo, które mają być wysyłane wraz z żądaniami reklam na potrzeby kierowania i wykluczania treści. |
update | Zmienia korelator wysyłany z żądaniami reklamy, co powoduje rozpoczęcie nowego wyświetlenia strony. |
Metody
wyczyść
clear(slots?: Slot[]): boolean
W szczególności wyczyszczenie slotu usuwa reklamę z długotrwałego wyświetlenia strony w GPT, więc przyszłe żądania nie będą podlegać blokadom ani wykluczeniom konkurencji związanym z tą reklamą.
- Przykład
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 (starsza wersja)
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();
Parametry | |
---|---|
| Tablica miejsc do wyczyszczenia. Tablica jest opcjonalna. Jeśli nie zostanie określona, wszystkie miejsca zostaną wyczyszczone. |
Zwroty | |
---|---|
boolean | Zwraca wartość true , jeśli boksy zostały wyczyszczone, a w przeciwnym razie zwraca wartość false . |
clearCategoryExclusions
clearCategoryExclusions(): PubAdsService
- Przykład
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 (starsza wersja)
// 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.
- Zobacz też
Zwroty | |
---|---|
PubAdsService | Obiekt usługi, na którym wywołano metodę. |
clearTargeting
clearTargeting(key?: string): PubAdsService
- Przykład
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 (starsza wersja)
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.
- Zobacz też
Parametry | |
---|---|
| Klucz parametru kierowania. Klucz jest opcjonalny. Jeśli nie zostanie określony, wszystkie parametry kierowania zostaną wyczyszczone. |
Zwroty | |
---|---|
PubAdsService | Obiekt usługi, na którym wywołano metodę. |
collapseEmptyDivs
collapseEmptyDivs(collapseBeforeAdFetch?: boolean): boolean
Parametry | |
---|---|
| Określa, czy zwijać sloty jeszcze przed pobraniem reklam. Ten parametr jest opcjonalny. Jeśli go nie podasz, domyślną wartością będzie false . |
Zwroty | |
---|---|
boolean | Zwraca wartość true , jeśli włączono tryb zwijania elementu div, i false , jeśli nie można włączyć trybu zwijania, ponieważ metoda została wywołana po włączeniu usługi. |
disableInitialLoad
disableInitialLoad(): void
refresh
.wyświetlacz
display(adUnitPath: string, size: GeneralSize, div?: string | Element, clickUrl?: string): void
Uwaga: gdy ta metoda jest wywoływana, tworzona jest migawka stanu slota i strony, aby zapewnić spójność podczas wysyłania żądania reklamy i renderowania odpowiedzi. Wszelkie zmiany wprowadzone w stanie slotu lub strony po wywołaniu tej metody (w tym kierowanie, ustawienia prywatności, wymuszanie SafeFrame itp.) będą miały zastosowanie tylko do kolejnych żądań
display()
lub refresh()
.- Przykład
JavaScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
JavaScript (starsza wersja)
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
Parametry | |
---|---|
adUnitPath: string | Ścieżka jednostki reklamowej boksu, który ma być renderowany. |
size: GeneralSize | Szerokość i wysokość miejsca docelowego. |
| Identyfikator elementu div zawierającego slot lub sam element div. |
| Klikany adres URL, który ma być używany w tym miejscu. |
enableLazyLoad
enableLazyLoad(config?: {
fetchMarginPercent?: number;
mobileScaling?: number;
renderMarginPercent?: number;
}): void
Uwaga: leniwe pobieranie w SRA działa tylko wtedy, gdy wszystkie miejsca docelowe znajdują się poza marginesem pobierania.
- Przykład
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 (starsza wersja)
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, });
- Zobacz też
Parametry | |
---|---|
| Obiekt konfiguracji umożliwia dostosowanie działania leniwego ładowania. W przypadku pominiętych konfiguracji używane będą domyślne ustawienia Google, które będą z czasem dostosowywane. Aby wyłączyć konkretne ustawienie, np. margines pobierania, ustaw wartość na -1 .
|
enableSingleRequest
enableSingleRequest(): boolean
- Zobacz też
Zwroty | |
---|---|
boolean | Zwraca wartość true , jeśli włączono tryb pojedynczego żądania, oraz false , jeśli nie można go włączyć, ponieważ metoda została wywołana po włączeniu usługi. |
enableVideoAds
enableVideoAds(): void
get
get(key: string): string
- Przykład
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
JavaScript (starsza wersja)
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'.
- Zobacz też
Parametry | |
---|---|
key: string | Nazwa atrybutu do wyszukania. |
Zwroty | |
---|---|
string | Bieżąca wartość klucza atrybutu lub null , jeśli klucz nie występuje. |
getAttributeKeys
getAttributeKeys(): string[]
- Przykład
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 (starsza wersja)
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'].
Zwroty | |
---|---|
string[] | Tablica kluczy atrybutów ustawionych w tej usłudze. Kolejność jest nieokreślona. |
getTargeting
getTargeting(key: string): string[]
- Przykład
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
JavaScript (starsza wersja)
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).
Parametry | |
---|---|
key: string | Klucz kierowania do wyszukania. |
Zwroty | |
---|---|
string[] | Wartości powiązane z tym kluczem lub pusta tablica, jeśli takiego klucza nie ma. |
getTargetingKeys
getTargetingKeys(): string[]
- Przykład
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
JavaScript (starsza wersja)
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'].
Zwroty | |
---|---|
string[] | Tablica kluczy kierowania. Kolejność jest nieokreślona. |
isInitialLoadDisabled
isInitialLoadDisabled(): boolean
Zwroty | |
---|---|
boolean | Zwraca wartość true , jeśli poprzednie wywołanie funkcji PubAdsService.disableInitialLoad zakończyło się powodzeniem, a w przeciwnym razie zwraca wartość false . |
odśwież
refresh(slots?: Slot[], options?: {
changeCorrelator: boolean;
}): void
Aby zapewnić prawidłowe działanie we wszystkich przeglądarkach, wywołanie funkcji
refresh
musi być poprzedzone wywołaniem funkcji display
w przypadku miejsca na reklamę. Jeśli wywołanie display
zostanie pominięte, odświeżanie może działać w nieoczekiwany sposób. W razie potrzeby możesz użyć metody PubAdsService.disableInitialLoad, aby uniemożliwić display
pobieranie reklamy.Odświeżenie boksu usuwa starą reklamę z długotrwałego wyświetlenia strony w GPT, więc przyszłe żądania nie będą podlegać ograniczeniom związanym z roadblockingiem ani wykluczeniami reklam konkurencyjnych.
- Przykład
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 (starsza wersja)
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 });
Parametry | |
---|---|
| Gniazda do odświeżenia. Tablica jest opcjonalna. Jeśli nie zostanie określona, wszystkie miejsca zostaną odświeżone. |
| Opcje konfiguracji powiązane z tym wywołaniem odświeżania.
|
set
set(key: string, value: string): PubAdsService
Wywołanie tej funkcji więcej niż raz w przypadku tego samego klucza spowoduje zastąpienie wcześniej ustawionych wartości tego klucza. Wszystkie wartości muszą być ustawione przed wywołaniem funkcji
display
lub refresh
.- Przykład
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF");
JavaScript (starsza wersja)
googletag.pubads().set("adsense_background_color", "#FFFFFF");
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF");
- Zobacz też
Parametry | |
---|---|
key: string | Nazwa atrybutu. |
value: string | Wartość atrybutu. |
Zwroty | |
---|---|
PubAdsService | Obiekt usługi, na którym wywołano metodę. |
setCategoryExclusion
setCategoryExclusion(categoryExclusion: string): PubAdsService
- Przykład
JavaScript
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
JavaScript (starsza wersja)
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
TypeScript
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
- Zobacz też
Parametry | |
---|---|
categoryExclusion: string | Etykieta wykluczenia kategorii reklam do dodania. |
Zwroty | |
---|---|
PubAdsService | Obiekt usługi, na którym wywołano metodę. |
setCentering
setCentering(centerAds: boolean): void
Tę metodę należy wywołać przed wywołaniem
display
lub refresh
, ponieważ tylko reklamy, o które poprosisz po wywołaniu tej metody, będą wyśrodkowane.- Przykład
JavaScript
// Make ads centered. googletag.pubads().setCentering(true);
JavaScript (starsza wersja)
// Make ads centered. googletag.pubads().setCentering(true);
TypeScript
// Make ads centered. googletag.pubads().setCentering(true);
Parametry | |
---|---|
centerAds: boolean | true – wyśrodkowanie reklam, false – wyrównanie do lewej. |
setForceSafeFrame
setForceSafeFrame(forceSafeFrame: boolean): PubAdsService
Podczas korzystania z tego interfejsu API pamiętaj o tych kwestiach:
- To ustawienie będzie miało wpływ tylko na kolejne żądania reklamy wysyłane w przypadku odpowiednich miejsc docelowych.
- Ustawienie na poziomie boksu, jeśli jest określone, zawsze zastępuje ustawienie na poziomie strony.
- Jeśli ta opcja jest ustawiona na
true
(na poziomie boksu lub strony), reklama będzie zawsze renderowana przy użyciu kontenera SafeFrame niezależnie od wyboru dokonanego w interfejsie Google Ad Managera. - Jeśli jednak ustawisz wartość
false
lub pozostawisz to ustawienie bez zmian, reklama będzie renderowana przy użyciu kontenera SafeFrame w zależności od typu kreacji i wyboru dokonanego w interfejsie Google Ad Managera. - Tego interfejsu API należy używać ostrożnie, ponieważ może on wpływać na działanie kreacji, które próbują wyjść z elementów iframe lub polegają na renderowaniu bezpośrednio na stronie wydawcy.
- Przykład
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 (starsza wersja)
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");
- Zobacz też
Parametry | |
---|---|
forceSafeFrame: boolean | true , aby wymusić renderowanie wszystkich reklam na stronie w ramkach SafeFrame, i false , aby zmienić poprzednie ustawienie na fałsz. Ustawienie tej wartości na false , gdy nie została ona wcześniej określona, nie spowoduje żadnych zmian. |
Zwroty | |
---|---|
PubAdsService | Obiekt usługi, na którym wywołano funkcję. |
setLocation
setLocation(address: string): PubAdsService
- Przykład
JavaScript
// Postal code: googletag.pubads().setLocation("10001,US");
JavaScript (starsza wersja)
// Postal code: googletag.pubads().setLocation("10001,US");
TypeScript
// Postal code: googletag.pubads().setLocation("10001,US");
Parametry | |
---|---|
address: string | Adres w dowolnym formacie. |
Zwroty | |
---|---|
PubAdsService | Obiekt usługi, na którym wywołano metodę. |
setPrivacySettings
setPrivacySettings(privacySettings: PrivacySettingsConfig): PubAdsService
- Przykład
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 (starsza wersja)
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, });
Parametry | |
---|---|
privacySettings: PrivacySettingsConfig | Obiekt zawierający konfigurację ustawień prywatności. |
Zwroty | |
---|---|
PubAdsService | Obiekt usługi, na którym wywołano funkcję. |
setPublisherProvidedId
setPublisherProvidedId(ppid: string): PubAdsService
- Przykład
JavaScript
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
JavaScript (starsza wersja)
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
TypeScript
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
Parametry | |
---|---|
ppid: string | Identyfikator alfanumeryczny podany przez wydawcę. Musi mieć od 32 do 150 znaków. |
Zwroty | |
---|---|
PubAdsService | Obiekt usługi, na którym wywołano metodę. |
setSafeFrameConfig
setSafeFrameConfig(config: SafeFrameConfig): PubAdsService
Te ustawienia na poziomie strony zostaną zastąpione ustawieniami na poziomie boksu, jeśli zostaną określone.
- Przykład
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 (starsza wersja)
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");
- Zobacz też
Parametry | |
---|---|
config: SafeFrameConfig | Obiekt konfiguracji. |
Zwroty | |
---|---|
PubAdsService | Obiekt usługi, na którym wywołano metodę. |
setTargeting
setTargeting(key: string, value: string | string[]): PubAdsService
- Przykład
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 (starsza wersja)
// 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"]);
- Zobacz też
Parametry | |
---|---|
key: string | Klucz parametru kierowania. |
value: string | string[] | Wartość parametru kierowania lub tablica wartości. |
Zwroty | |
---|---|
PubAdsService | Obiekt usługi, na którym wywołano metodę. |
setVideoContent
setVideoContent(videoContentId: string, videoCmsId: string): void
videoContentId
i videoCmsId
użyj wartości, które są przekazywane do usługi Ad Managera do pozyskiwania treści.- Zobacz też
Parametry | |
---|---|
videoContentId: string | Identyfikator treści wideo. |
videoCmsId: string | Identyfikator CMS filmu. |
updateCorrelator
updateCorrelator(): PubAdsService
Uwaga: nie ma to wpływu na długotrwałe wyświetlenie strony w GPT, które automatycznie odzwierciedla reklamy faktycznie znajdujące się na stronie i nie ma czasu wygaśnięcia.
- Przykład
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 (starsza wersja)
// 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.
Zwroty | |
---|---|
PubAdsService | Obiekt usługi, na którym wywołano funkcję. |
googletag.ResponseInformation
Właściwości | |
---|---|
advertiser | Identyfikator reklamodawcy. |
campaign | Identyfikator kampanii. |
creative | Identyfikator kreacji. |
creative | Identyfikator szablonu reklamy. |
line | Identyfikator elementu zamówienia. |
- Zobacz też
Właściwości
advertiserId
advertiserId: number
campaignId
campaignId: number
creativeId
creativeId: number
creativeTemplateId
creativeTemplateId: number
lineItemId
lineItemId: number
googletag.RewardedPayload
Właściwości | |
---|---|
amount | Liczba produktów w nagrodzie. |
type | Rodzaj elementu uwzględnionego w nagrodzie (np. „moneta”). |
- Zobacz też
Właściwości
kwota
amount: number
type
type: string
googletag.Service
Metody | |
---|---|
add | Rejestruje detektor, który umożliwia skonfigurowanie i wywołanie funkcji JavaScriptu, gdy na stronie wystąpi określone zdarzenie GPT. |
get | Pobierz listę miejsc powiązanych z tą usługą. |
remove | Usuwa wcześniej zarejestrowanego detektora. |
Metody
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
- Przykład
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 (starsza wersja)
// 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. } });
- Zobacz też
Parametry | |
---|---|
eventType: K | Ciąg znaków reprezentujący typ zdarzenia wygenerowanego przez GPT. W typach zdarzeń jest rozróżniana wielkość liter. |
listener: ((arg: EventTypeMap[K]) => void) | Funkcja, która przyjmuje jeden argument obiektu zdarzenia. |
Zwroty | |
---|---|
Service | Obiekt usługi, na którym wywołano metodę. |
getSlots
removeEventListener
removeEventListener<K extends keyof EventTypeMap>(eventType: K, listener: ((event: EventTypeMap[K]) => void)): void
- Przykład
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 (starsza wersja)
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(); });
Parametry | |
---|---|
eventType: K | Ciąg znaków reprezentujący typ zdarzenia wygenerowanego przez GPT. W typach zdarzeń jest rozróżniana wielkość liter. |
listener: ((event: EventTypeMap[K]) => void) | Funkcja, która przyjmuje jeden argument obiektu zdarzenia. |
googletag.SizeMappingBuilder
Metody | |
---|---|
add | Dodaje mapowanie z tablicy o jednym rozmiarze (reprezentującej widoczny obszar) na tablicę o jednym lub wielu rozmiarach reprezentującą boks. |
build | Tworzy specyfikację mapy rozmiarów na podstawie mapowań dodanych do tego narzędzia. |
- Zobacz też
Metody
addSize
addSize(viewportSize: SingleSizeArray, slotSize: GeneralSize): SizeMappingBuilder
- Przykład
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 (starsza wersja)
// 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]
Parametry | |
---|---|
viewportSize: SingleSizeArray | Rozmiar widocznego obszaru dla tego wpisu mapowania. |
slotSize: GeneralSize | Rozmiary boksu dla tego wpisu mapowania. |
Zwroty | |
---|---|
SizeMappingBuilder | Odwołanie do tego konstruktora. |
kompilacja
build(): SizeMappingArray
Jeśli podano nieprawidłowe mapowania, ta metoda zwróci wartość
null
. W przeciwnym razie zwraca specyfikację w prawidłowym formacie, która jest przekazywana do funkcji Slot.defineSizeMapping.Uwaga: działanie narzędzia po wywołaniu tej metody jest nieokreślone.
Zwroty | |
---|---|
SizeMappingArray | Wynik utworzony przez ten moduł. Może mieć wartość null, jeśli podano nieprawidłowe mapowania rozmiaru. |
googletag.Slot
Metody | |
---|---|
add | Dodaje usługę do tego boksu. |
clear | Usuwa wszystkie etykiety wykluczenia kategorii reklam na poziomie boksu reklamowego w przypadku tego boksu. |
clear | Czyści określone lub wszystkie niestandardowe parametry kierowania na poziomie boksu w przypadku tego boksu. |
define | Ustawia tablicę mapowań od minimalnego rozmiaru widocznego obszaru do rozmiaru boksu w przypadku tego boksu. |
get | Zwraca wartość atrybutu AdSense powiązanego z danym kluczem w tym boksie. |
get | Zwraca pełną ścieżkę jednostki reklamowej z kodem sieci i ścieżką jednostki reklamowej. |
get | Zwraca listę kluczy atrybutów ustawionych w tym slocie. |
get | Zwraca etykiety wykluczenia kategorii reklam dla tego boksu. |
get | Pobiera ogólne opcje konfiguracji strony ustawione przez funkcję setConfig. |
get | Zwraca informacje o odpowiedzi na reklamę. |
get | Zwraca identyfikator slota div podany podczas jego definiowania. |
get | Zwraca konkretny parametr kierowania niestandardowego ustawiony w tym slocie. |
get | Zwraca listę wszystkich kluczy kierowania niestandardowego ustawionych w tym slocie. |
set | Ustawia wartość atrybutu AdSense w tym boksie reklamowym. |
set | Ustawia w tym boksie etykietę wykluczenia kategorii reklamy na poziomie boksu. |
set | Ustawia adres URL kliknięcia, na który użytkownicy będą przekierowywani po kliknięciu reklamy. |
set | Określa, czy boks div ma być ukryty, gdy nie ma w nim reklamy. |
set | Ustawia ogólne opcje konfiguracji tego miejsca. |
set | Określa, czy reklamy w tym boksie mają być renderowane w kontenerze SafeFrame. |
set | Ustawia preferencje na poziomie slotu dotyczące konfiguracji SafeFrame. |
set | Ustawia niestandardowy parametr kierowania dla tego boksu. |
update | Ustawia niestandardowe parametry kierowania dla tego miejsca na reklamy na podstawie mapy klucz:wartość w obiekcie JSON. |
Metody
addService
addService(service: Service): Slot
- Przykład
JavaScript
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
JavaScript (starsza wersja)
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
TypeScript
googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
Parametry | |
---|---|
service: Service | Usługa do dodania. |
Zwroty | |
---|---|
Slot | Obiekt boksu, w którym wywołano metodę. |
clearCategoryExclusions
clearCategoryExclusions(): Slot
- Przykład
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 (starsza wersja)
// 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.
Zwroty | |
---|---|
Slot | Obiekt boksu, w którym wywołano metodę. |
clearTargeting
clearTargeting(key?: string): Slot
- Przykład
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 (starsza wersja)
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.
- Zobacz też
Parametry | |
---|---|
| Klucz parametru kierowania. Klucz jest opcjonalny. Jeśli nie zostanie określony, wszystkie parametry kierowania zostaną wyczyszczone. |
Zwroty | |
---|---|
Slot | Obiekt boksu, w którym wywołano metodę. |
defineSizeMapping
defineSizeMapping(sizeMapping: SizeMappingArray): Slot
- Przykład
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 (starsza wersja)
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!);
- Zobacz też
Parametry | |
---|---|
sizeMapping: SizeMappingArray | Tablica mapowań rozmiarów. Możesz go utworzyć za pomocą klasy SizeMappingBuilder. Każde mapowanie rozmiaru to tablica składająca się z 2 elementów: SingleSizeArray i GeneralSize. |
Zwroty | |
---|---|
Slot | Obiekt boksu, w którym wywołano metodę. |
get
get(key: string): string
- Przykład
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 (starsza wersja)
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'.
- Zobacz też
Parametry | |
---|---|
key: string | Nazwa atrybutu do wyszukania. |
Zwroty | |
---|---|
string | Bieżąca wartość klucza atrybutu lub null , jeśli klucz nie występuje. |
getAdUnitPath
getAdUnitPath(): string
- Przykład
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
JavaScript (starsza wersja)
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'.
Zwroty | |
---|---|
string | Ścieżka jednostki reklamowej. |
getAttributeKeys
getAttributeKeys(): string[]
- Przykład
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 (starsza wersja)
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'].
Zwroty | |
---|---|
string[] | Tablica kluczy atrybutów. Kolejność jest nieokreślona. |
getCategoryExclusions
getCategoryExclusions(): string[]
- Przykład
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
JavaScript (starsza wersja)
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'].
Zwroty | |
---|---|
string[] | Etykiety wykluczenia kategorii reklam w przypadku tego boksu reklamowego lub pusta tablica, jeśli nie zostały ustawione żadne etykiety. |
getConfig
getConfig(keys: string | string[]): Pick<SlotSettingsConfig, "adsenseAttributes" | "targeting" | "categoryExclusion">
Ta metoda nie obsługuje wszystkich właściwości
setConfig()
. Obsługiwane właściwości:- Przykład
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 (starsza wersja)
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"]);
Parametry | |
---|---|
keys: string | string[] | Klucze opcji konfiguracji do pobrania. |
Zwroty | |
---|---|
Pick<SlotSettingsConfig, "adsenseAttributes" | "targeting" | "categoryExclusion"> | Opcje konfiguracji slota. |
getResponseInformation
getResponseInformation(): ResponseInformation
null
.Zwroty | |
---|---|
ResponseInformation | Najnowsze informacje o odpowiedzi reklamy lub null , jeśli w boksu nie ma reklamy. |
getSlotElementId
getSlotElementId(): string
div
podany podczas jego definiowania.- Przykład
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
JavaScript (starsza wersja)
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'.
Zwroty | |
---|---|
string | Identyfikator boksu div . |
getTargeting
getTargeting(key: string): string[]
- Przykład
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 (starsza wersja)
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).
Parametry | |
---|---|
key: string | Klucz kierowania do wyszukania. |
Zwroty | |
---|---|
string[] | Wartości powiązane z tym kluczem lub pusta tablica, jeśli takiego klucza nie ma. |
getTargetingKeys
getTargetingKeys(): string[]
- Przykład
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 (starsza wersja)
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'].
Zwroty | |
---|---|
string[] | Tablica kluczy kierowania. Kolejność jest nieokreślona. |
set
set(key: string, value: string): Slot
Wywołanie tej metody więcej niż raz w przypadku tego samego klucza spowoduje zastąpienie wcześniej ustawionych wartości tego klucza. Wszystkie wartości muszą być ustawione przed wywołaniem funkcji
display
lub refresh
.- Przykład
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 (starsza wersja)
// 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());
- Zobacz też
Parametry | |
---|---|
key: string | Nazwa atrybutu. |
value: string | Wartość atrybutu. |
Zwroty | |
---|---|
Slot | Obiekt boksu, w którym wywołano metodę. |
setCategoryExclusion
setCategoryExclusion(categoryExclusion: string): Slot
- Przykład
JavaScript
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
JavaScript (starsza wersja)
// 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());
- Zobacz też
Parametry | |
---|---|
categoryExclusion: string | Etykieta wykluczenia kategorii reklam do dodania. |
Zwroty | |
---|---|
Slot | Obiekt boksu, w którym wywołano metodę. |
setClickUrl
setClickUrl(value: string): Slot
Serwery Google Ad Managera nadal rejestrują kliknięcie, nawet jeśli URL kliknięcia zostanie zastąpiony. Do podanej wartości zostanie dołączony każdy adres URL strony docelowej powiązany z wyświetlaną kreacją. Kolejne wywołania zastępują tę wartość. Działa to tylko w przypadku żądań innych niż SRA.
- Przykład
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
JavaScript (starsza wersja)
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());
Parametry | |
---|---|
value: string | Adres URL kliknięcia do ustawienia. |
Zwroty | |
---|---|
Slot | Obiekt boksu, w którym wywołano metodę. |
setCollapseEmptyDiv
setCollapseEmptyDiv(collapse: boolean, collapseBeforeAdFetch?: boolean): Slot
div
ma być ukryty, gdy nie ma w nim reklamy. Zastępuje to ustawienia na poziomie usługi.- Przykład
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 (starsza wersja)
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.
Parametry | |
---|---|
collapse: boolean | Określa, czy boks ma zostać zwinięty, jeśli nie zostanie zwrócona żadna reklama. |
| Czy zwinąć boks jeszcze przed pobraniem reklamy. Ignorowane, jeśli zwijanie nie jest ustawione na true . |
Zwroty | |
---|---|
Slot | Obiekt boksu, w którym wywołano metodę. |
setConfig
setConfig(slotConfig: SlotSettingsConfig): void
Parametry | |
---|---|
slotConfig: SlotSettingsConfig | Obiekt konfiguracji. |
setForceSafeFrame
setForceSafeFrame(forceSafeFrame: boolean): Slot
Podczas korzystania z tego interfejsu API pamiętaj o tych kwestiach:
- To ustawienie będzie miało wpływ tylko na kolejne żądania reklamy wysyłane w przypadku odpowiednich miejsc docelowych.
- Ustawienie na poziomie boksu, jeśli jest określone, zawsze zastępuje ustawienie na poziomie strony.
- Jeśli ta opcja jest ustawiona na
true
(na poziomie boksu lub strony), reklama będzie zawsze renderowana przy użyciu kontenera SafeFrame niezależnie od wyboru dokonanego w interfejsie Google Ad Managera. - Jeśli jednak ustawisz wartość
false
lub pozostawisz to ustawienie bez zmian, reklama będzie renderowana przy użyciu kontenera SafeFrame w zależności od typu kreacji i wyboru dokonanego w interfejsie Google Ad Managera. - Tego interfejsu API należy używać ostrożnie, ponieważ może on wpływać na działanie kreacji, które próbują wyjść z elementów iframe lub polegają na renderowaniu bezpośrednio na stronie wydawcy.
- Przykład
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setForceSafeFrame(true) .addService(googletag.pubads());
JavaScript (starsza wersja)
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());
- Zobacz też
Parametry | |
---|---|
forceSafeFrame: boolean | true , aby wymusić renderowanie wszystkich reklam w tym boksie w ramkach SafeFrame, i false , aby zrezygnować z ustawienia na poziomie strony (jeśli jest obecne). Ustawienie tej wartości na false , gdy nie jest ona określona na poziomie strony, nie spowoduje żadnych zmian. |
Zwroty | |
---|---|
Slot | Obiekt boksu, w którym wywołano metodę. |
setSafeFrameConfig
setSafeFrameConfig(config: SafeFrameConfig): Slot
Te preferencje na poziomie boksu, jeśli zostaną określone, zastąpią wszelkie preferencje na poziomie strony.
- Przykład
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 (starsza wersja)
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");
- Zobacz też
Parametry | |
---|---|
config: SafeFrameConfig | Obiekt konfiguracji. |
Zwroty | |
---|---|
Slot | Obiekt boksu, w którym wywołano metodę. |
setTargeting
setTargeting(key: string, value: string | string[]): Slot
- Przykład
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 (starsza wersja)
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"]);
- Zobacz też
Parametry | |
---|---|
key: string | Klucz parametru kierowania. |
value: string | string[] | Wartość parametru kierowania lub tablica wartości. |
Zwroty | |
---|---|
Slot | Obiekt boksu, w którym wywołano metodę. |
updateTargetingFromMap
updateTargetingFromMap(map: {
[adUnitPath: string]: string | string[];
}): Slot
Uwagi:
- W przypadku zastąpienia zachowana zostanie tylko ostatnia wartość.
- Jeśli wartość jest tablicą, poprzednia wartość zostanie nadpisana, a nie scalona.
- Wartości ustawione w tym miejscu zastąpią parametry kierowania ustawione na poziomie usługi.
- Przykład
JavaScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
JavaScript (starsza wersja)
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"], });
Parametry | |
---|---|
map: { | Mapa klucz-wartość parametru kierowania. |
Zwroty | |
---|---|
Slot | Obiekt boksu, w którym wywołano metodę. |
googletag.config
Interfejsy | |
---|---|
Ad | Ustawienia kontrolujące rozwijanie reklam. |
Ad | Ustawienia kontrolujące działanie reklam AdSense. |
Component | Obiekt reprezentujący pojedynczą aukcję komponentu w aukcji reklam na urządzeniu. |
Interstitial | Obiekt, który określa działanie pojedynczego boksu reklamy pełnoekranowej. |
Lazy | Ustawienia kontrolujące użycie leniwego wczytywania w GPT. |
Page | Główny interfejs konfiguracji ustawień na poziomie strony. |
Privacy | Ustawienia umożliwiające kontrolowanie sposobu traktowania prywatności użytkowników przez wydawców. |
Publisher | Obiekt konfiguracji sygnałów dostarczanych przez wydawcę. |
Safe | Ustawienia kontrolujące SafeFrame w GPT. |
Slot | Główny interfejs konfiguracji ustawień na poziomie gniazda. |
Taxonomy | Obiekt zawierający wartości pojedynczej mapy kategorii. |
Video | Ustawienia do konfigurowania ustawień związanych z reklamami wideo. |
Aliasy typu | |
---|---|
Interstitial | Obsługiwane aktywatory reklam pełnoekranowych. |
Privacy | Obsługiwane ustawienia prywatności wydawcy. |
Taxonomy | Obsługiwane taksonomie w przypadku sygnałów dostarczanych przez wydawcę. |
Aliasy typu
InterstitialTrigger
InterstitialTrigger: "unhideWindow" | "navBar"
PrivacyTreatment
PrivacyTreatment: "disablePersonalization"
Taksonomia
Taxonomy: "IAB_AUDIENCE_1_1" | "IAB_CONTENT_2_2"
googletag.config.AdExpansionConfig
Właściwości | |
---|---|
enabled | Określa, czy rozwijanie reklam jest włączone czy wyłączone. |
- Przykład
JavaScript
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
JavaScript (starsza wersja)
// 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 }, });
Właściwości
Optional
włączono
enabled?: boolean
Ustawienie tej wartości zastępuje domyślną konfigurację w usłudze Google Ad Manager.
googletag.config.AdSenseAttributesConfig
Te atrybuty mogą służyć do zastępowania ustawień po stronie serwera w przypadku poszczególnych żądań.
Właściwości | |
---|---|
adsense | format reklamy AdSense. |
adsense | Identyfikatory kanałów AdSense. |
adsense | Informacja o tym, czy tryb testowy jest włączony. |
document | Język strony, na której wyświetlają się reklamy. |
page | Adres URL strony, na której wyświetlają się reklamy. |
Właściwości
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
Dozwolone wartości to identyfikatory kanałów rozdzielone znakiem „+”.
Przykład:
271828183+314159265
Optional
adsense_test_mode
adsense_test_mode?: "on"
Gdy wartość jest ustawiona na
on
, reklamy są oznaczane jako przeznaczone tylko do testowania i nie są uwzględniane w zliczaniu ani rozliczeniach. W przypadku ruchu produkcyjnego, który nie jest ruchem testowym, to ustawienie musi być wyłączone.Optional
document_language
document_language?: string
Dozwolone wartości to prawidłowe kody języków w formacie ISO 639-1.
Przykład:
en
Optional
page_url
page_url?: string
Dozwolone wartości to prawidłowe adresy URL.
Przykład:
http://www.example.com
googletag.config.ComponentAuctionConfig
Właściwości | |
---|---|
auction | Obiekt konfiguracji aukcji dla tej aukcji komponentu. |
config | Klucz konfiguracji powiązany z aukcją komponentu. |
Właściwości
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;
}
Jeśli ta wartość jest ustawiona na
null
, wszelkie istniejące konfiguracje dla określonego configKey
zostaną usunięte.- Przykład
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 (starsza wersja)
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
Ta wartość nie może być pusta i powinna być niepowtarzalna. Jeśli 2 obiekty
ComponentAuctionConfig
mają tę samą wartość configKey, ostatni z nich zastąpi poprzednie konfiguracje.googletag.config.InterstitialConfig
Właściwości | |
---|---|
require | Określa, czy do wyświetlenia tej reklamy pełnoekranowej wymagana jest zgoda na dostęp do pamięci lokalnej. |
triggers | Konfiguracja wyzwalacza reklamy pełnoekranowej. |
Właściwości
Optional
requireStorageAccess
requireStorageAccess?: boolean
GPT używa pamięci lokalnej do egzekwowania limitu wyświetleń reklam pełnoekranowych. Użytkownicy, którzy nie wyrazili zgody na korzystanie z pamięci lokalnej, nadal mogą widzieć reklamy pełnoekranowe. Ustawienie tej właściwości na
true
wyłącza domyślne działanie i zapewnia, że reklamy pełnoekranowe będą wyświetlane tylko użytkownikom, którzy wyrazili zgodę na korzystanie z pamięci lokalnej.- Przykład
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 (starsza wersja)
// 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
aktywatory
triggers?: Partial<Record<InterstitialTrigger, boolean>>
Ustawienie wartości wyzwalacza reklamy pełnoekranowej na
true
włączy go, a ustawienie na false
wyłączy. Zastąpi to wartości domyślne skonfigurowane w usłudze Google Ad Manager.- Przykład
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 (starsza wersja)
// 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
Właściwości | |
---|---|
fetch | Minimalna odległość od bieżącego widocznego obszaru, jaką musi mieć boks, zanim wyślemy żądanie reklamy. Jest ona wyrażona jako procent rozmiaru widocznego obszaru. |
mobile | Mnożnik stosowany do marginesów na urządzeniach mobilnych. |
render | Minimalna odległość od bieżącego widocznego obszaru, w jakiej musi znajdować się boks, zanim wyrenderujemy w nim reklamę. Jest ona wyrażona jako procent rozmiaru widocznego obszaru. |
- Zobacz też
Właściwości
Optional
fetchMarginPercent
fetchMarginPercent?: number
Używane w połączeniu z parametrem renderMarginPercent to ustawienie umożliwia wstępne pobieranie reklamy, ale czeka z renderowaniem i pobieraniem innych zasobów podrzędnych. Dlatego ta wartość powinna być zawsze większa lub równa wartości renderMarginPercent.
Wartość
0
oznacza „gdy slot wchodzi w obszar widoczny”, 100
oznacza „gdy reklama znajduje się w odległości 1 obszaru widocznego” itd.Optional
mobileScaling
mobileScaling?: number
Umożliwia to stosowanie różnych marginesów na urządzeniach mobilnych i komputerach, na których rozmiary widocznego obszaru i szybkość przewijania mogą się różnić. Na przykład wartość 2,0 spowoduje pomnożenie wszystkich marginesów na urządzeniach mobilnych przez 2, co zwiększy minimalną odległość, jaką slot może mieć od widocznego obszaru przed pobraniem i wyrenderowaniem.
Optional
renderMarginPercent
renderMarginPercent?: number
Używane w połączeniu z ustawieniem fetchMarginPercent. To ustawienie umożliwia wstępne pobieranie reklamy, ale czeka z wyświetlaniem i pobieraniem innych zasobów podrzędnych. W związku z tym ta wartość powinna być zawsze mniejsza lub równa wartości parametru fetchMarginPercent.
Wartość
0
oznacza „gdy slot wchodzi w obszar widoczny”, 100
oznacza „gdy reklama znajduje się w odległości 1 obszaru widocznego” itd.googletag.config.PageSettingsConfig
Umożliwia ustawianie wielu funkcji za pomocą jednego wywołania interfejsu API.
Wszystkie wymienione poniżej właściwości są przykładami i nie odzwierciedlają rzeczywistych funkcji, które korzystają z polecenia setConfig. Zestaw funkcji znajdziesz w polach typu PageSettingsConfig poniżej.
Przykłady:
- Zmieniane są tylko funkcje określone w wywołaniu googletag.setConfig.
// Configure feature alpha. googletag.setConfig({ alpha: {...} }); // Configure feature bravo. Feature alpha is unchanged. googletag.setConfig({ bravo: {...} });
- Wszystkie ustawienia danej funkcji są aktualizowane przy każdym wywołaniu funkcji 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 } });
- Wszystkie ustawienia funkcji można wyczyścić, przekazując wartość
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, });
Właściwości | |
---|---|
ad | Ustawienia kontrolujące rozwijanie reklam. |
adsense | Ustawienie do konfigurowania atrybutów AdSense. |
ad | Wycofano. |
category | Ustawienie do konfigurowania wykluczeń kategorii reklam. |
centering | Ustawienie umożliwiające kontrolowanie poziomego wyśrodkowania reklam. |
collapse | Ustawienie kontrolujące zwijanie boksów reklamowych. |
disable | Ustawienie, które pozwala kontrolować, kiedy mają być wysyłane żądania reklam. |
lazy | Ustawienia kontrolujące użycie leniwego wczytywania w GPT. |
location | Ustawienie kierowania elementów zamówienia na lokalizacje geograficzne. |
pps | Ustawienia umożliwiające kontrolowanie sygnałów dostarczanych przez wydawcę. |
privacy | Ustawienia umożliwiające kontrolowanie sposobu traktowania prywatności użytkowników przez wydawców. |
safe | Ustawienia kontrolujące użycie SafeFrame w GPT. |
single | Ustawienie umożliwiające włączanie i wyłączanie architektury z pojedynczym żądaniem (SRA). |
targeting | Ustawienie kontrolujące kierowanie na pary klucz-wartość. |
thread | Ustawienie określające, czy GPT ma zwalniać wątek JS podczas wysyłania żądań kreacji i ich renderowania. |
video | Ustawienia umożliwiające kontrolowanie reklam wideo. |
Właściwości
Optional
adExpansion
adExpansion?: AdExpansionConfig
Optional
adsenseAttributes
adsenseAttributes?: AdSenseAttributesConfig
Atrybuty AdSense skonfigurowane za pomocą tego ustawienia będą stosowane do wszystkich boksów reklamowych na stronie. To ustawienie może być wywoływane wielokrotnie, aby zdefiniować wiele wartości atrybutów lub zastąpić istniejące wartości.
Zmiany atrybutów AdSense mają zastosowanie tylko do reklam, o które poproszono po wywołaniu tej metody. Z tego powodu zalecamy wywoływanie tej metody przed wywołaniami googletag.display lub PubAdsService.refresh.
- Przykład
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 (starsza wersja)
// 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[]
- Przykład
JavaScript
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"] }); // Clearing category exclusion setting. googletag.setConfig({ categoryExclusion: null });
JavaScript (starsza wersja)
// 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 });
- Zobacz też
Optional
wyśrodkowanie
centering?: boolean
Zmiany wyśrodkowywania w poziomie dotyczą tylko reklam, o które poproszono po wywołaniu tej metody. Z tego powodu zalecamy wywoływanie tej metody przed wywołaniami googletag.display lub PubAdsService.refresh.
- Przykład
JavaScript
// Make ads centered. googletag.setConfig({ centering: true }); // Clear the centering setting. googletag.setConfig({ centering: null });
JavaScript (starsza wersja)
// 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?: "DISABLED" | "BEFORE_FETCH" | "ON_NO_FILL"
Zwinięty boks reklamowy nie zajmuje miejsca na stronie.
Obsługiwane wartości:
null
(domyślnie): miejsce nie zostanie zwinięte.DISABLED
: boks nie zostanie zwinięty, niezależnie od tego, czy reklama zostanie zwrócona.BEFORE_FETCH
: boks będzie początkowo zwinięty i rozwinie się, gdy zostanie w nim wyświetlona reklama.ON_NO_FILL
: boks będzie początkowo rozwinięty, a jeśli nie zostanie zwrócona żadna reklama, zostanie zwinięty.
- Przykład
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 (starsza wersja)
// 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
Domyślnie metoda googletag.display rejestruje boks reklamowy i wysyła do niego żądania reklam. Czasami jednak warto rozdzielić te działania, aby precyzyjniej kontrolować, kiedy wczytywana jest treść reklamy.
Jeśli włączysz to ustawienie, w przypadku zarejestrowanych miejsc docelowych nie będą wysyłane żądania reklam, gdy wywoływana jest metoda
display()
. Zamiast tego należy wykonać osobne wywołanie funkcji PubAdsService.refresh, aby zainicjować żądanie reklamy.Tę metodę musisz wywołać przed wywołaniem funkcji googletag.enableServices.
- Przykład
JavaScript
// Prevent requesting ads when `display()` is called. googletag.setConfig({ disableInitialLoad: true });
JavaScript (starsza wersja)
// 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
Leniwe ładowanie to technika opóźniająca wysyłanie żądań reklam i renderowanie ich do momentu, gdy zbliżają się do widocznego obszaru użytkownika. Bardziej szczegółowy przykład znajdziesz w próbce Lazy loading (Lenistwo w ładowaniu).
Uwaga: jeśli włączona jest funkcja
singleRequest
, leniwe pobieranie działa tylko wtedy, gdy wszystkie miejsca docelowe znajdują się poza marginesem pobierania.Wszystkie ustawienia leniwego ładowania, które nie są określone podczas wywoływania funkcji
setConfig()
, będą używać wartości domyślnej ustawionej przez Google. Te wartości domyślne mogą się z czasem zmieniać. Aby wyłączyć określone ustawienie, ustaw wartość na null
.- Przykład
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 (starsza wersja)
// 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
lokalizacja
location?: string
- Przykład
JavaScript
// Geo-target line items to US postal code 10001. googletag.setConfig({ location: "10001,US" }); // Clear the location setting. googletag.setConfig({ location: null });
JavaScript (starsza wersja)
// 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
Wartości skonfigurowane za pomocą tego ustawienia będą miały zastosowanie do wszystkich boksów reklamowych na stronie. Poszczególne boksy reklamowe mogą zastępować te wartości za pomocą parametru SlotSettingsConfig.safeFrame.
- Przykład
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 (starsza wersja)
// 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
Gdy SRA jest włączona, wszystkie boksy reklamowe zdefiniowane przed wywołaniem funkcji googletag.display lub PubAdsService.refresh są łączone w jedno żądanie reklamy. Zapewnia to korzyści w zakresie skuteczności, ale jest też niezbędne do zapewnienia działania reklam na wyłączność i wykluczeń konkurencji.
Gdy SRA jest wyłączona, każdy boks reklamowy jest wysyłany osobno. Jest to domyślne zachowanie GPT.
Tę metodę należy wywołać przed wywołaniem metody googletag.enableServices.
- Przykład
JavaScript
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
JavaScript (starsza wersja)
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
TypeScript
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
Optional
kierowanie
targeting?: Record<string, string | string[]>
Kierowanie skonfigurowane za pomocą tego ustawienia będzie stosowane do wszystkich boksów reklamowych na stronie. To ustawienie może być wywoływane wielokrotnie, aby zdefiniować wiele par klucz-wartość kierowania lub zastąpić istniejące wartości. Klucze kierowania są zdefiniowane na koncie Google Ad Managera.
- Przykład
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 (starsza wersja)
// 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 } });
- Zobacz też
Optional
threadYield
threadYield?: "DISABLED" | "ENABLED_ALL_SLOTS"
GPT będzie zwalniać wątek tylko w przeglądarkach, które obsługują interfejs API Scheduler.postTask lub Scheduler.yield.
Obsługiwane wartości:
null
(domyślnie): GPT zwalnia wątek JS w przypadku boksów reklamowych znajdujących się poza widocznym obszarem.ENABLED_ALL_SLOTS
: GPT będzie zwalniać wątek JS dla wszystkich boksów, niezależnie od tego, czy znajdują się one w widocznym obszarze.DISABLED
: GPT nie będzie zwalniać wątku JS.
- Przykład
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 (starsza wersja)
// 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 });
- Zobacz też
Optional
videoAds
videoAds?: VideoAdsConfig
- Przykład
JavaScript
// Enable video ads and set video content and content source IDs. googletag.setConfig({ videoAds: { enableVideoAds: true, videoContentId: "e1eGlRL7ju8", videoCmsId: "1234567", }, });
JavaScript (starsza wersja)
// 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", }, });
- Zobacz też
googletag.config.PrivacyTreatmentsConfig
Właściwości | |
---|---|
treatments | Tablica ustawień ochrony prywatności wydawcy do włączenia. |
Właściwości
leczenie
treatments: "disablePersonalization"[]
- Przykład
JavaScript
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
JavaScript (starsza wersja)
// 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
Właściwości | |
---|---|
taxonomies | Obiekt zawierający mapowania taksonomii lub wartość null, aby wyczyścić konfigurację. |
- Przykład
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 (starsza wersja)
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' }, }, });
Właściwości
taksonomie
taxonomies: Partial<Record<Taxonomy, TaxonomyData>>
googletag.config.SafeFrameConfig
Właściwości | |
---|---|
allow | Określa, czy SafeFrame ma zezwalać na rozszerzanie treści reklamy przez nakładanie jej na zawartość strony. |
allow | Określa, czy element SafeFrame powinien zezwalać na rozszerzanie treści reklamy przez przesuwanie treści strony. |
force | Określa, czy reklamy mają być renderowane w kontenerze SafeFrame. |
sandbox | Określa, czy SafeFrame ma używać atrybutu sandbox HTML5, aby zapobiegać nawigacji na najwyższym poziomie bez interakcji użytkownika. |
use | Wycofano. Określa, czy SafeFrame ma używać losowych subdomen w przypadku kreacji z rezerwacji. |
Właściwości
Optional
allowOverlayExpansion
allowOverlayExpansion?: boolean
Optional
allowPushExpansion
allowPushExpansion?: boolean
Optional
forceSafeFrame
forceSafeFrame?: boolean
Optional
sandbox
sandbox?: boolean
true
(nie można wymusić wartości false
). Pamiętaj, że atrybut sandbox wyłącza wtyczki (np. Flash).Optional
useUniqueDomain
useUniqueDomain?: boolean
null
.Uwaga: ta funkcja jest domyślnie włączona.
- Zobacz też
googletag.config.SlotSettingsConfig
Umożliwia ustawianie wielu funkcji za pomocą jednego wywołania interfejsu API dla jednego slotu.
Wszystkie właściwości wymienione poniżej są przykładami i nie odzwierciedlają rzeczywistych funkcji, które korzystają z setConfig. Zestaw funkcji znajdziesz w polach typu SlotSettingsConfig poniżej.
Przykłady:
- Modyfikowane są tylko funkcje określone w wywołaniu 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: {...} });
- Wszystkie ustawienia danej funkcji są aktualizowane przy każdym wywołaniu funkcji 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 } });
- Wszystkie ustawienia funkcji można wyczyścić, przekazując wartość
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, });
Właściwości | |
---|---|
ad | Ustawienia konfigurowania rozszerzania reklam. |
adsense | Ustawienie do konfigurowania atrybutów AdSense. |
category | Ustawienie do konfigurowania wykluczeń kategorii reklam. |
click | Ustawienie służące do konfigurowania adresu URL, na który użytkownicy będą przekierowywani po kliknięciu reklamy. |
collapse | Ustawienie konfigurowania zwijania się miejsca na reklamę. |
component | Tablica aukcji komponentów, które mają być uwzględnione w aukcji reklam na urządzeniu. |
interstitial | Ustawienia, które konfigurują działanie slotu na reklamę pełnoekranową. |
safe | Ustawienia konfigurowania użycia SafeFrame w GPT. |
targeting | Ustawienie do konfigurowania kierowania na pary klucz-wartość. |
Właściwości
Optional
adExpansion
adExpansion?: AdExpansionConfig
- Zobacz też
Optional
adsenseAttributes
adsenseAttributes?: AdSenseAttributesConfig
Atrybuty AdSense skonfigurowane za pomocą tego ustawienia będą stosowane tylko do miejsca na reklamę. To ustawienie może być wywoływane wielokrotnie, aby zdefiniować wiele wartości atrybutów lub zastąpić istniejące wartości.
Zmiany atrybutów AdSense mają zastosowanie tylko do reklam, o które poproszono po wywołaniu tej metody. Z tego powodu zalecamy wywoływanie tej metody przed wywołaniami googletag.display lub PubAdsService.refresh.
- Przykład
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 (starsza wersja)
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[]
- Przykład
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 (starsza wersja)
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 });
- Zobacz też
Optional
clickUrl
clickUrl?: string
Serwery Google Ad Managera nadal rejestrują kliknięcie, nawet jeśli URL kliknięcia zostanie zastąpiony. Do podanej wartości zostanie dołączony każdy adres URL strony docelowej powiązany z wyświetlaną kreacją. Ustawienie tej wartości więcej niż raz spowoduje zastąpienie wcześniej skonfigurowanej wartości. Przekazanie wartości
null
spowoduje wyczyszczenie wartości.Uwaga: to ustawienie dotyczy tylko żądań innych niż SRA.
- Przykład
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 (starsza wersja)
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?: "DISABLED" | "BEFORE_FETCH" | "ON_NO_FILL"
Zwinięty boks reklamowy nie zajmuje miejsca na stronie.
Obsługiwane wartości:
null
(domyślnie): miejsce nie zostanie zwinięte.DISABLED
: boks nie zostanie zwinięty, niezależnie od tego, czy reklama zostanie zwrócona.BEFORE_FETCH
: boks będzie początkowo zwinięty i rozwinie się, gdy zostanie w nim wyświetlona reklama.ON_NO_FILL
: boks będzie początkowo rozwinięty, a jeśli nie zostanie zwrócona żadna reklama, zostanie zwinięty.
- Przykład
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 (starsza wersja)
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
reklama pełnoekranowa
interstitial?: InterstitialConfig
Optional
safeFrame
safeFrame?: SafeFrameConfig
Wartości skonfigurowane za pomocą tego ustawienia będą stosowane tylko do boksu reklamowego i zastąpią wartości ustawione za pomocą parametru PageSettingsConfig.safeFrame.
- Przykład
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 (starsza wersja)
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
kierowanie
targeting?: Record<string, string | string[]>
Kierowanie skonfigurowane za pomocą tego ustawienia będzie stosowane tylko do boksu reklamowego. To ustawienie może być wywoływane wielokrotnie, aby zdefiniować wiele par klucz-wartość kierowania lub zastąpić istniejące wartości. Klucze kierowania są zdefiniowane na koncie Google Ad Managera.
- Przykład
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 (starsza wersja)
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 });
- Zobacz też
googletag.config.TaxonomyData
Właściwości | |
---|---|
values | Lista wartości Taxonomy. |
Właściwości
values
values: readonly string[]
googletag.config.VideoAdsConfig
Właściwości | |
---|---|
enable | czy na stronie będą wyświetlane reklamy wideo. |
video | Identyfikator źródła treści wideo. |
video | Identyfikator treści wideo. |
- Zobacz też
Właściwości
enableVideoAds
enableVideoAds: boolean
Jeśli to pole ma wartość
true
, włącza to ograniczenia wykluczeń treści w przypadku reklam displayowych i wideo.Jeśli treść wideo jest znana, ustaw wartości videoContentId i videoCmsId na wartości podane w usłudze wprowadzania treści Google Ad Manager, aby korzystać z wykluczeń treści w przypadku reklam displayowych.
Optional
videoCmsId
videoCmsId?: string
Jest to unikalna wartość przypisana przez usługę pobierania treści Google Ad Managera w celu identyfikacji źródła treści wideo określonego przez parametr videoContentId.
- Zobacz też
Optional
videoContentId
videoContentId?: string
Jest to unikalna wartość, która identyfikuje konkretny film ze źródła treści określonego przez atrybut videoCmsId. Ta wartość jest przypisywana przez system CMS, który hostuje Twoje treści wideo.
- Zobacz też
googletag.enums
Wyliczenia | |
---|---|
Out | Formaty poza stroną obsługiwane przez GPT. |
Traffic | Źródła wizyt obsługiwane przez GPT. |
Wyliczenia
OutOfPageFormat
OutOfPageFormat
- Zobacz też
Elementy wyliczenia | |
---|---|
BOTTOM_ | Format zakotwiczony, w którym boks jest przyklejony do dolnej części widocznego obszaru. |
GAME_ | Format reklamy pełnoekranowej z ręczną konfiguracją w grze. Uwaga: reklama pełnoekranowa z ręczną konfiguracją w grze to format z ograniczonym dostępem. |
INTERSTITIAL | Format kreacji pełnoekranowej w internecie. |
LEFT_ | Format lewej kolumny bocznej. |
REWARDED | Format z nagrodą. |
RIGHT_ | Format prawej kolumny bocznej. |
TOP_ | Format kotwicy, w którym boks reklamowy jest przyklejony do górnej części widocznego obszaru. |
TrafficSource
TrafficSource
- Zobacz też
googletag.events
Interfejsy | |
---|---|
Event | Interfejs podstawowy dla wszystkich zdarzeń GPT. |
Event | Jest to pseudotyp, który mapuje nazwę zdarzenia na odpowiadający jej typ obiektu zdarzenia w przypadku funkcji Service.addEventListener i Service.removeEventListener. |
Game | To zdarzenie jest uruchamiane, gdy użytkownik zamknie slot reklamy pełnoekranowej z instrukcją do gry. |
Game | To zdarzenie jest wywoływane, gdy boks reklamy pełnoekranowej konfigurowanej ręcznie do wyświetlenia w grze jest gotowy do wyświetlenia użytkownikowi. |
Impression | To zdarzenie jest wywoływane, gdy wyświetlenie staje się widoczne zgodnie z kryteriami Widoku aktywnego. |
Rewarded | To zdarzenie jest uruchamiane, gdy użytkownik zamknie slot na reklamę z nagrodą. |
Rewarded | To zdarzenie jest wywoływane, gdy użytkownik otrzyma nagrodę za obejrzenie reklamy z nagrodą. |
Rewarded | To zdarzenie jest wywoływane, gdy reklama z nagrodą jest gotowa do wyświetlenia. |
Slot | To zdarzenie jest uruchamiane, gdy element iframe kreacji uruchamia zdarzenie wczytywania. |
Slot | To zdarzenie jest wywoływane, gdy kod kreacji zostanie wstawiony do boksu. |
Slot | To zdarzenie jest uruchamiane, gdy w przypadku danego boksu wysłano żądanie reklamy. |
Slot | To zdarzenie jest wywoływane po otrzymaniu odpowiedzi na reklamę w przypadku danego miejsca na reklamę. |
Slot | To zdarzenie jest uruchamiane za każdym razem, gdy zmienia się procent powierzchni boksu reklamowego widoczny na ekranie. |
googletag.events.Event
Właściwości | |
---|---|
service | Nazwa usługi, która wywołała zdarzenie. |
slot | Slot, który wywołał zdarzenie. |
- Zobacz też
Właściwości
serviceName
serviceName: string
slot
slot: Slot
googletag.events.EventTypeMap
Właściwości
gameManualInterstitialSlotClosed
gameManualInterstitialSlotClosed: GameManualInterstitialSlotClosedEvent
gameManualInterstitialSlotReady
gameManualInterstitialSlotReady: GameManualInterstitialSlotReadyEvent
impressionViewable
impressionViewable: ImpressionViewableEvent
rewardedSlotClosed
rewardedSlotClosed: RewardedSlotClosedEvent
rewardedSlotGranted
rewardedSlotGranted: RewardedSlotGrantedEvent
rewardedSlotReady
rewardedSlotReady: RewardedSlotReadyEvent
slotOnload
slotOnload: SlotOnloadEvent
slotRenderEnded
slotRenderEnded: SlotRenderEndedEvent
slotRequested
slotRequested: SlotRequestedEvent
slotResponseReceived
slotResponseReceived: SlotResponseReceived
slotVisibilityChanged
slotVisibilityChanged: SlotVisibilityChangedEvent
googletag.events.GameManualInterstitialSlotClosedEvent
PrzedłużaUwaga: reklama pełnoekranowa w instrukcji do gry to format o ograniczonym dostępie.
Właściwości | |
---|---|
service | Nazwa usługi, która wywołała zdarzenie. Odziedziczone z: |
slot | Slot, który wywołał zdarzenie. Odziedziczone z: |
- Przykład
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 (starsza wersja)
// 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
PrzedłużaUwaga: reklama pełnoekranowa konfigurowana ręcznie do wyświetlenia w grze to format o ograniczonym dostępie.
Właściwości | |
---|---|
service | Nazwa usługi, która wywołała zdarzenie. Odziedziczone z: |
slot | Slot, który wywołał zdarzenie. Odziedziczone z: |
Metody | |
---|---|
make | Wyświetla użytkownikowi reklamę pełnoekranową konfigurowaną ręcznie w grze. |
- Przykład
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 (starsza wersja)
// 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. } }); }
Metody
makeGameManualInterstitialVisible
makeGameManualInterstitialVisible(): void
googletag.events.ImpressionViewableEvent
PrzedłużaWłaściwości | |
---|---|
service | Nazwa usługi, która wywołała zdarzenie. Odziedziczone z: |
slot | Slot, który wywołał zdarzenie. Odziedziczone z: |
- Przykład
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 (starsza wersja)
// 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. } });
- Zobacz też
googletag.events.RewardedSlotClosedEvent
PrzedłużaWłaściwości | |
---|---|
service | Nazwa usługi, która wywołała zdarzenie. Odziedziczone z: |
slot | Slot, który wywołał zdarzenie. Odziedziczone z: |
- Przykład
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 (starsza wersja)
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
PrzedłużaWłaściwości | |
---|---|
payload | Obiekt zawierający informacje o przyznanej nagrodzie. |
service | Nazwa usługi, która wywołała zdarzenie. Odziedziczone z: |
slot | Slot, który wywołał zdarzenie. Odziedziczone z: |
- Przykład
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 (starsza wersja)
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. } }); }
Właściwości
payload
payload: RewardedPayload
googletag.events.RewardedSlotReadyEvent
PrzedłużaWłaściwości | |
---|---|
service | Nazwa usługi, która wywołała zdarzenie. Odziedziczone z: |
slot | Slot, który wywołał zdarzenie. Odziedziczone z: |
Metody | |
---|---|
make | Wyświetla reklamę z nagrodą. |
- Przykład
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 (starsza wersja)
// 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. } }); }
Metody
makeRewardedVisible
makeRewardedVisible(): void
googletag.events.SlotOnloadEvent
PrzedłużaSlotOnloadEvent
.Właściwości | |
---|---|
service | Nazwa usługi, która wywołała zdarzenie. Odziedziczone z: |
slot | Slot, który wywołał zdarzenie. Odziedziczone z: |
- Przykład
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 (starsza wersja)
// 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. } });
- Zobacz też
googletag.events.SlotRenderEndedEvent
PrzedłużaWłaściwości | |
---|---|
advertiser | Identyfikator reklamodawcy wyświetlonej reklamy. |
campaign | Identyfikator kampanii wyświetlonej reklamy. |
company | Identyfikatory firm, które przesłały stawkę za wyświetloną reklamę zapasową. |
creative | Identyfikator kreacji wyświetlonej reklamy z rezerwacji. |
creative | Identyfikator szablonu kreacji wyświetlonej reklamy rezerwacyjnej. |
is | Czy reklama była reklamą zapasową. |
is | Czy w przypadku boksu reklamowego zwrócono reklamę. |
label | Wycofano. |
line | Identyfikator elementu zamówienia wyświetlonej reklamy rezerwacyjnej. |
response | Identyfikator reakcji to niepowtarzalny identyfikator reakcji na reklamę. |
service | Nazwa usługi, która wywołała zdarzenie. Odziedziczone z: |
size | Wskazuje rozmiar w pikselach wyrenderowanej kreacji. |
slot | Slot, który wywołał zdarzenie. Odziedziczone z: |
slot | czy treść boksu została zmieniona przez wyrenderowaną reklamę. |
source | Identyfikator kreacji wyświetlonej reklamy z rezerwacji lub reklamy zapasowej. |
source | Identyfikator elementu zamówienia wyświetlonej rezerwacji lub reklamy zapasowej. |
yield | Identyfikatory grup zysku w przypadku wyświetlonej reklamy zastępczej. |
- Przykład
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 (starsza wersja)
// 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. } });
- Zobacz też
Właściwości
advertiserId
advertiserId: number
null
w przypadku pustych boksów, reklam zapasowych i kreacji renderowanych przez usługi inne niż PubAdsService.campaignId
campaignId: number
null
w przypadku pustych boksów, reklam zapasowych i kreacji renderowanych przez usługi inne niż PubAdsService.companyIds
companyIds: number[]
null
w przypadku pustych boksów, reklam z rezerwacji i kreacji renderowanych przez usługi inne niż PubAdsService.creativeId
creativeId: number
null
w przypadku pustych boksów, reklam zapasowych i kreacji renderowanych przez usługi inne niż PubAdsService.creativeTemplateId
creativeTemplateId: number
null
w przypadku pustych boksów, reklam zapasowych i kreacji renderowanych przez usługi inne niż PubAdsService.isBackfill
isBackfill: boolean
true
, jeśli reklama była reklamą zapasową, a w przeciwnym razie false
.isEmpty
isEmpty: boolean
true
, jeśli nie zwrócono żadnej reklamy, a false
w przeciwnym razie.labelIds
labelIds: number[]
lineItemId
lineItemId: number
null
w przypadku pustych boksów, reklam zapasowych i kreacji renderowanych przez usługi inne niż PubAdsService.responseIdentifier
responseIdentifier: string
size
size: string | number[]
[728, 90]
. W przypadku pustych boksów reklamowych wartość wynosi null
.slotContentChanged
slotContentChanged: boolean
true
, jeśli treść została zmieniona, a w przeciwnym razie false
.sourceAgnosticCreativeId
sourceAgnosticCreativeId: number
null
, jeśli reklama nie jest rezerwacją ani wypełnieniem elementu zamówienia lub kreacja jest renderowana przez usługi inne niż PubAdsService.sourceAgnosticLineItemId
sourceAgnosticLineItemId: number
null
, jeśli reklama nie jest rezerwacją ani wypełnieniem elementu zamówienia lub kreacja jest renderowana przez usługi inne niż PubAdsService.yieldGroupIds
yieldGroupIds: number[]
null
w przypadku pustych boksów, reklam z rezerwacji i kreacji renderowanych przez usługi inne niż PubAdsService.googletag.events.SlotRequestedEvent
PrzedłużaWłaściwości | |
---|---|
service | Nazwa usługi, która wywołała zdarzenie. Odziedziczone z: |
slot | Slot, który wywołał zdarzenie. Odziedziczone z: |
- Przykład
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 (starsza wersja)
// 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. } });
- Zobacz też
googletag.events.SlotResponseReceived
PrzedłużaWłaściwości | |
---|---|
service | Nazwa usługi, która wywołała zdarzenie. Odziedziczone z: |
slot | Slot, który wywołał zdarzenie. Odziedziczone z: |
- Przykład
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 (starsza wersja)
// 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. } });
- Zobacz też
googletag.events.SlotVisibilityChangedEvent
PrzedłużaWłaściwości | |
---|---|
in | Odsetek powierzchni reklamy, która jest widoczna. |
service | Nazwa usługi, która wywołała zdarzenie. Odziedziczone z: |
slot | Slot, który wywołał zdarzenie. Odziedziczone z: |
- Przykład
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 (starsza wersja)
// 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. } });
- Zobacz też
Właściwości
inViewPercentage
inViewPercentage: number
googletag.secureSignals
Interfejsy | |
---|---|
Bidder | Zwraca bezpieczny sygnał dla określonego licytującego. |
Publisher | Zwraca bezpieczny sygnał dla konkretnego wydawcy. |
Secure | Interfejs do zarządzania bezpiecznymi sygnałami. |
Aliasy typu | |
---|---|
Secure | Interfejs do zwracania bezpiecznego sygnału w przypadku konkretnego licytującego lub dostawcy. |
Aliasy typu
SecureSignalProvider
SecureSignalProvider: BidderSignalProvider | PublisherSignalProvider
id
lub networkCode
, ale nie oba.googletag.secureSignals.BidderSignalProvider
Dostawca bezpiecznych sygnałów licytującego składa się z 2 części:
- Funkcja kolektora, która zwraca
Promise
prowadzący do bezpiecznego sygnału. id
, który identyfikuje reklamodawcę powiązanego z sygnałem.
Właściwości | |
---|---|
collector | Funkcja, która zwraca Promise prowadzący do bezpiecznego sygnału. |
id | Unikalny identyfikator podmiotu zbierającego dane powiązanego z tym bezpiecznym sygnałem, zarejestrowany w usłudze Google Ad Manager. |
- Przykład
JavaScript
// id is provided googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript (starsza wersja)
// 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"); }, });
Właściwości
collectorFunction
collectorFunction: (() => Promise<string>)
Promise
prowadzący do bezpiecznego sygnału.id
id: string
googletag.secureSignals.PublisherSignalProvider
Dostawca sygnałów wydawcy składa się z 2 części:
- Funkcja kolektora, która zwraca
Promise
prowadzący do bezpiecznego sygnału. networkCode
, który identyfikuje wydawcę powiązanego z sygnałem.
Właściwości | |
---|---|
collector | Funkcja, która zwraca Promise prowadzący do bezpiecznego sygnału. |
network | Kod sieci (widoczny w ścieżce jednostki reklamowej) wydawcy powiązanego z tym bezpiecznym sygnałem. |
- Przykład
JavaScript
// networkCode is provided googletag.secureSignalProviders.push({ networkCode: "123456", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript (starsza wersja)
// 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"); }, });
Właściwości
collectorFunction
collectorFunction: (() => Promise<string>)
Promise
prowadzący do bezpiecznego sygnału.networkCode
networkCode: string
googletag.secureSignals.SecureSignalProvidersArray
Metody | |
---|---|
clear | Usuwa z pamięci podręcznej wszystkie sygnały wszystkich zbieraczy. |
push | Dodaje nowy element secureSignals.SecureSignalProvider do tablicy dostawców sygnałów i rozpoczyna proces generowania sygnałów. |
Metody
clearAllCache
clearAllCache(): void
Wywoływanie tej metody może zmniejszyć prawdopodobieństwo uwzględnienia sygnałów w żądaniach reklamy w przypadku bieżących i przyszłych wyświetleń strony. Z tego powodu należy wywoływać ją tylko wtedy, gdy stan ulega istotnym zmianom, np. w przypadku zdarzeń wskazujących na nowego użytkownika (logowanie się, wylogowywanie się, rejestrowanie się itp.).
push
push(provider: SecureSignalProvider): void
Parametry | |
---|---|
provider: SecureSignalProvider | Obiekt secureSignals.SecureSignalProvider, który ma zostać dodany do tablicy. |