このリファレンスでは、TypeScript 表記を使用して型を記述します。次の表に、例を使用して簡単な説明を示します。
型式 | |
---|---|
string |
プリミティブ文字列型。 |
string[] |
配列型。値は文字列のみです。 |
number | string |
共用体型。値は数値または文字列です。 |
Array<number | string> |
配列型。値は複合(ユニオン)型です。 |
[number, string] |
タプル型。値は 2 要素の配列で、数値、文字列をこの順序で含む必要があります。 |
Slot |
オブジェクト タイプ。値は googletag.Slot のインスタンスです。 |
() => void |
引数が定義されず、戻り値もない関数型。 |
サポートされている型と型式の詳細については、 TypeScript ハンドブック をご覧ください。
型アノテーション
変数、パラメータ名、プロパティ名、関数シグネチャの後のコロンは、型アノテーションを示します。型アノテーションは、コロンの左側の要素が受け入れまたは返すことができる型を記述します。次の表に、このリファレンスで使用される型アノテーションの例を示します。
型アノテーション | |
---|---|
param: string |
param が文字列値を受け入れる、または返すことを示します。この構文は、変数、パラメータ、プロパティ、戻り値の型に使用されます。 |
param?: number | string |
param は省略可能ですが、指定した場合は数値または文字列のいずれかを受け入れることを示します。この構文はパラメータとプロパティに使用されます。 |
...params: Array<() => void> |
params が、関数を受け入れる
休止パラメータ
であることを示します。REST パラメータは、指定された型の無制限の数を受け入れます。 |
型の定義
型 | |
---|---|
|
SingleSize | MultiSize
|
スロットの有効なサイズ設定(1 つまたは複数のサイズ)。 |
|
|
SingleSize[]
|
1 つの有効なサイズのリスト。 |
|
|
"fluid" | ["fluid"]
|
スロットに含めることができる名前付きサイズ。ほとんどの場合、サイズは固定サイズの長方形ですが、他の種類のサイズ指定が必要になる場合もあります。有効な名前付きサイズは次のとおりです。
|
|
|
SingleSizeArray | NamedSize
|
スロットに有効な単一のサイズ。 |
|
|
[number, number]
|
[幅, 高さ] を表す 2 つの数値の配列。 |
|
|
[SingleSizeArray, GeneralSize]
|
ビューポート サイズと広告サイズのマッピング。レスポンシブ広告に使用されます。 |
|
|
SizeMapping[]
|
サイズ マッピングのリスト。 |
|
|
"unhideWindow" | "navBar"
|
サポートされているインタースティシャル広告トリガー。 |
|
|
"disablePersonalization"
|
パブリッシャーのプライバシー保護に対応しています。 |
|
|
"IAB_AUDIENCE_1_1" | "IAB_CONTENT_2_2"
|
パブリッシャー提供のシグナル(PPS)でサポートされている分類。 |
|
|
BidderSignalProvider | PublisherSignalProvider
|
特定のビッダーまたはプロバイダのセキュア シグナルを返すインターフェース。 |
列挙型
列挙型 | |
---|---|
googletag.enums.OutOfPageFormat
|
GPT でサポートされているページ外形式です。
|
googletag.enums.TrafficSource
|
GPT でサポートされているトラフィック ソース。
|
googletag.enums.OutOfPageFormat
-
GPT でサポートされているページ外フォーマットです。
-
- 関連情報
googletag.enums.TrafficSource
-
GPT でサポートされているトラフィック ソース
-
Values ORGANIC
URL の直接入力、サイト内検索、アプリのダウンロード。PURCHASED
所有サイト以外のプロパティからリダイレクトされたトラフィック(獲得またはインセンティブで操作されたアクティビティ)。
googletag
Google パブリッシャー タグが API に使用するグローバル名前空間。
変数の概要 | |
---|---|
apiReady
|
GPT API が読み込まれて呼び出す準備ができていることを示すフラグ。
|
cmd
|
GPT 関連の呼び出しを非同期で実行するためのグローバル コマンド キューへの参照です。
|
pubadsReady
|
PubAdsService が有効で、読み込み済み、完全に稼働していることを示すフラグ。
|
secureSignalProviders
|
セキュア シグナル プロバイダの配列への参照です。
|
関数の概要 | |
---|---|
companionAds
|
CompanionAdsService への参照を返します。
|
defineOutOfPageSlot
|
指定された広告ユニットのパスでページ外広告スロットを作成します。
|
defineSlot
|
指定された広告ユニットのパスとサイズで広告スロットを作成し、広告が含まれるページの div 要素の ID に関連付けます。
|
destroySlots
|
指定されたスロットを破棄し、関連するすべてのオブジェクトとそれらのスロットの参照を GPT から削除します。
|
disablePublisherConsole
|
Google パブリッシャー コンソールを無効にします。
|
display
|
スロットをレンダリングするようスロット サービスに指示します。
|
enableServices
|
ページ上の広告スロットで定義されているすべての GPT サービスを有効にする。
|
getVersion
|
GPT の現在のバージョンを返します。
|
openConsole
|
Google パブリッシャー コンソールを開きます。
|
pubads
|
PubAdsService への参照を返します。
|
setAdIframeTitle
|
これ以降、
PubAdsService で作成されたすべての広告コンテナ iframe のタイトルを設定します。
|
setConfig
|
ページの一般的な設定オプションを設定します。
|
sizeMapping
|
新しい
SizeMappingBuilder を作成します。
|
googletagapiReady
-
apiReady: boolean | undefined
-
GPT API が読み込まれて呼び出す準備ができていることを示すフラグ。このプロパティは、API の準備が整うまで単純に
undefined
になります。
非同期の処理には、googletag.cmd を使用して、GPT の準備が整うまでコールバックをキューに入れることをおすすめします。これらのコールバックは、API の設定後に実行されることが保証されているため、googletag.apiReady をチェックする必要はありません。 -
- 例
-
JavaScript
if (window.googletag && googletag.apiReady) { // GPT API can be called safely. }
JavaScript(従来版)
if (window.googletag && googletag.apiReady) { // GPT API can be called safely. }
TypeScript
if (window.googletag && googletag.apiReady) { // GPT API can be called safely. }
googletagcmd
-
cmd: Array<(this: typeof globalThis) => void> | CommandArray
-
GPT 関連の呼び出しを非同期で実行するためのグローバル コマンドキューへの参照です。
googletag.cmd
変数は、ページ上の GPT タグ構文によって空の JavaScript 配列に初期化されます。cmd.push
は、配列の最後に要素を追加する標準のArray.push
メソッドです。GPT JavaScript が読み込まれると、配列が調べられ、すべての関数が順番に実行されます。次に、このスクリプトはcmd
をCommandArray
オブジェクトに置き換えます。このオブジェクトの push メソッドが、渡された関数引数を実行するように定義されています。このメカニズムにより、GPT はブラウザでページのレンダリングを続行しながら、JavaScript を非同期で取得することで、認識されるレイテンシを短縮できます。 -
- 例
-
JavaScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
JavaScript(従来版)
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()); });
googletagpubadsReady
-
pubadsReady: boolean | undefined
-
PubAdsService
が有効で、読み込み済み、完全に稼働していることを示すフラグ。このプロパティは、enableServices
が呼び出されてPubAdsService
が読み込まれて初期化されるまで、単純にundefined
になります。 -
googletagsecureSignalProviders
-
secureSignalProviders: SecureSignalProvider[] | SecureSignalProvidersArray | undefined
-
セキュア シグナル プロバイダ配列への参照です。
セキュア シグナル プロバイダ配列は、シグナル生成関数の順序を受け入れ、順番に呼び出します。GPT の読み込み後に呼び出すシグナル生成関数をキューに追加するために使用されている標準配列を置き換えることを目的としています。 -
- 例
-
JavaScript
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { return Promise.resolve("signal"); }, });
JavaScript(従来版)
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"); }, });
- 関連情報
googletagcompanionAds
-
companionAds(): CompanionAdsService
-
CompanionAdsService
への参照を返します。 -
-
戻り値 CompanionAdsService
コンパニオン広告サービス。
googletagdefineOutOfPageSlot
-
defineOutOfPageSlot(adUnitPath: string, div?: string | OutOfPageFormat): Slot | null
-
指定された広告ユニットのパスでページ外広告スロットを作成します。
ページ外カスタム広告の場合、div
は広告を格納する div 要素の ID です。詳しくは、ページ外クリエイティブに関する記事をご覧ください。
GPT で管理されるページ外広告の場合、div
はサポートされている OutOfPageFormat です。 -
- 例
-
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(従来版)
// 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);
- 関連情報
-
パラメータ adUnitPath: string
完全な広告ユニットパス(ネットワーク コードと広告ユニットコードを含む)。div?: string | OutOfPageFormat
この広告ユニットまたは OutOfPageFormat を格納する div の ID。 -
戻り値 Slot | null
新しく作成されたスロット。スロットを作成できない場合はnull
。
googletagdefineSlot
-
defineSlot(adUnitPath: string, size: GeneralSize, div?: string): Slot | null
-
指定された広告ユニットのパスとサイズで広告スロットを作成し、広告を配置するページ上の div 要素の ID に関連付けます。
-
- 例
-
JavaScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
JavaScript(従来版)
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
- 関連情報
-
パラメータ adUnitPath: string
広告ユニットの完全なパス(ネットワーク コードとユニットコードを含む)。size: GeneralSize
追加されたスロットの幅と高さ。レスポンシブ サイズのマッピングが指定されていない場合、またはビューポートのサイズがマッピングで指定された最小サイズよりも小さい場合に、広告リクエストで使用されるサイズです。div?: string
この広告ユニットを格納する div の ID。 -
戻り値 Slot | null
新しく作成されたスロット。スロットを作成できない場合はnull
。
googletagdestroySlots
-
destroySlots(slots?: Slot[]): boolean
-
指定されたスロットを破棄し、関連するすべてのオブジェクトとそれらのスロットの参照を GPT から削除します。この API は、パスバック スロットとコンパニオン スロットをサポートしていません。
スロットでこの API を呼び出すと、広告がクリアされ、GPT によって維持されている内部状態からそのスロット オブジェクトが削除されます。スロット オブジェクトでこれ以上関数を呼び出すと、未定義の動作が発生します。ただし、そのスロットへの参照がパブリッシャーのページで保持されている場合、ブラウザはそのスロットに関連付けられたメモリを解放しない場合があります。この API を呼び出すと、そのスロットに関連付けられている div を再利用できるようになります。
特に、スロットを破棄すると、その広告は GPT の長期存続ページビューから削除されるため、この広告に関するロードブロッキングや競合相手の除外の影響は受けません。ページからスロットの div を削除する前にこの関数を呼び出さないと、未定義の動作になります。 -
- 例
-
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(従来版)
// 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();
-
パラメータ slots?: Slot[]
破棄するスロットの配列。配列は省略可能です。指定しない場合、すべてのスロットが破棄されます。 -
戻り値 boolean
スロットが破棄された場合はtrue
、それ以外の場合はfalse
。
googletagdisablePublisherConsole
-
disablePublisherConsole(): void
-
Google パブリッシャー コンソールを無効にします。
-
- 関連情報
googletagdisplay
-
display(divOrSlot: string | Element | Slot): void
-
スロットをレンダリングするようスロット サービスに指示します。各広告スロットは 1 ページに 1 回のみ表示する必要があります。表示する前に、すべてのスロットを定義してサービスを関連付ける必要があります。display の呼び出しは、要素が DOM に存在するまで発生してはいけません。通常は、メソッド呼び出しに指定した div 要素内のスクリプト ブロック内に配置します。
シングル リクエスト アーキテクチャ(SRA)が使用されている場合は、このメソッドが呼び出されたときにフェッチされていないすべての広告スロットが一度に取得されます。広告スロットが表示されないようにするには、div 全体を削除する必要があります。 -
- 例
-
JavaScript
googletag.cmd.push(() => { googletag.display("div-1"); });
JavaScript(従来版)
googletag.cmd.push(function () { googletag.display("div-1"); });
TypeScript
googletag.cmd.push(() => { googletag.display("div-1"); });
- 関連情報
-
パラメータ divOrSlot: string | Element | Slot
広告スロットまたは div 要素を含む div 要素の ID、またはスロット オブジェクトの ID。div 要素を指定する場合は、defineSlot
に渡される ID と一致する「id」属性を指定する必要があります。
googletagenableServices
-
enableServices(): void
-
ページ上の広告スロットで定義されているすべての GPT サービスを有効にします。
-
googletaggetVersion
-
getVersion(): string
-
GPT の現在のバージョンを返します。
-
- 関連情報
-
戻り値 string
現在実行中の GPT バージョンの文字列。
googletagopenConsole
-
openConsole(div?: string): void
-
Google パブリッシャー コンソールを開きます。
-
- 例
-
JavaScript
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
JavaScript(従来版)
// 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();
- 関連情報
-
パラメータ div?: string
広告スロットの div ID。この値は省略可能です。指定した場合、パブリッシャー コンソールは指定された広告スロットの詳細を表示して開きます。
googletagpubads
-
pubads(): PubAdsService
-
PubAdsService
への参照を返します。 -
-
戻り値 PubAdsService
パブリッシャー広告サービス。
googletagsetAdIframeTitle
-
setAdIframeTitle(title: string): void
-
これ以降、
PubAdsService
で作成されたすべての広告コンテナ iframe のタイトルを設定します。 -
- 例
-
JavaScript
googletag.setAdIframeTitle("title");
JavaScript(従来版)
googletag.setAdIframeTitle("title");
TypeScript
googletag.setAdIframeTitle("title");
-
パラメータ title: string
すべての広告コンテナ iframe の新しいタイトル。
googletagsetConfig
-
setConfig(config: PageSettingsConfig): void
-
ページの一般的な設定オプションを設定します。
-
-
パラメータ config: PageSettingsConfig
googletagsizeMapping
-
sizeMapping(): SizeMappingBuilder
-
新しい
SizeMappingBuilder
を作成します。 -
- 関連情報
-
戻り値 SizeMappingBuilder
新しいビルダー。
googletag。CommandArray
コマンド配列は、一連の関数を受け取り、順番に呼び出します。これは、GPT の読み込み後に呼び出す関数をキューに追加するために使用される、標準の配列を置き換えることを目的としています。
メソッドの概要 | |
---|---|
push
|
引数で指定された一連の関数を順番に実行します。
|
push
-
push(...f: Array<(this: typeof globalThis) => void>): number
-
引数で指定された一連の関数を順番に実行します。
-
- 例
-
JavaScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
JavaScript(従来版)
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()); });
-
パラメータ ...f: Array<(this: typeof globalThis) => void>
実行される JavaScript 関数。ランタイム バインディングは常にglobalThis
になります。包含する語彙コンテキストのthis
値を保持するアロー関数を渡すことを検討してください。 -
戻り値 number
これまでに処理されたコマンドの数。これは、Array.push
の戻り値(配列の現在の長さ)と互換性があります。
googletag。CompanionAdsService
拡張
使用することもできます。動画広告でコンパニオン広告を表示するために、このサービスが使用されます。
メソッドの概要 | |
---|---|
addEventListener
|
ページで特定の GPT イベントが発生したときに JavaScript 関数を設定して呼び出せるようにするリスナーを登録します。
|
getSlots
|
このサービスに関連付けられているスロットのリストを取得します。
|
removeEventListener
|
以前に登録されたリスナーを削除します。
|
setRefreshUnfilledSlots
|
埋められなかったコンパニオン スロットを自動的にバックフィルするかどうかを設定します。
|
- 関連情報
setRefreshUnfilledSlots
-
setRefreshUnfilledSlots(value: boolean): void
-
埋められなかったコンパニオン スロットを自動的にバックフィルするかどうかを設定します。
このメソッドは、バックフィルのオン / オフを切り替えるために、ページの実行中に複数回呼び出すことができます。PubAdsService
にも登録されているスロットのみがバックフィルされます。ポリシー上の制限により、この方法では、Ad Exchange 動画の配信時に空のコンパニオン スロットを埋めることはできません。 -
- 例
-
JavaScript
googletag.companionAds().setRefreshUnfilledSlots(true);
JavaScript(従来版)
googletag.companionAds().setRefreshUnfilledSlots(true);
TypeScript
googletag.companionAds().setRefreshUnfilledSlots(true);
-
パラメータ value: boolean
埋められなかったスロットを自動的にバックフィルする場合はtrue
、未変更のスロットはfalse
にします。
googletag。PrivacySettingsConfig
プライバシー設定の構成オブジェクト。
プロパティの概要 | |
---|---|
childDirectedTreatment
|
ページを子ども向けとして扱うかどうかを示します。
|
limitedAds
|
パブリッシャーの規制遵守のニーズに応えるため、制限付き広告モードでの配信を有効にします。
|
nonPersonalizedAds
|
パブリッシャーの規制遵守のニーズに応えるため、非パーソナライズド広告モードでの配信を有効にします。
|
restrictDataProcessing
|
パブリッシャーの規制遵守のニーズに対応するため、配信を制限付き処理モードで実行できるようにします。
|
trafficSource
|
リクエストが購入トラフィックとオーガニック トラフィックのどちらを表すかを示します。
|
underAgeOfConsent
|
広告リクエストを同意年齢に満たないユーザーからのものとして指定するかどうかを示します。
|
- 関連情報
childDirectedTreatment
-
childDirectedTreatment: null | boolean
-
ページを子ども向けとして扱うかどうかを示します。構成を消去するには、
null
に設定します。 -
limitedAds
-
limitedAds: boolean
-
パブリッシャーの規制遵守のニーズに応えるため、制限付き広告モードでの配信を有効にします。
制限付き広告をリクエストするには、次の 2 つの方法で GPT に指示できます。- IAB TCF v2.0 の同意管理プラットフォームからのシグナルを使用して自動的に作成されます。
- 手動で、このフィールドの値を
true
に設定します。
なお、CMP の使用中は、制限付き広告を手動で有効にする必要はありません。 -
- 例
-
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(従来版)
// 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, });
- 関連情報
nonPersonalizedAds
-
nonPersonalizedAds: boolean
-
パブリッシャーの規制遵守のニーズに応えるため、非パーソナライズド広告モードでの配信を有効にします。
-
restrictDataProcessing
-
restrictDataProcessing: boolean
-
パブリッシャーの規制遵守のニーズに応えるため、配信を制限付き処理モードで実行できるようにします。
-
trafficSource
-
trafficSource: TrafficSource
-
リクエストが購入トラフィックとオーガニック トラフィックのどちらを表すかを示します。この値は、アド マネージャーのレポートの [トラフィック ソース] ディメンションに入力されます。設定しない場合、トラフィック ソースはデフォルトで
undefined
になります。 -
- 例
-
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(従来版)
// 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, });
underAgeOfConsent
-
underAgeOfConsent: null | boolean
-
広告リクエストを同意年齢に満たないユーザーからのものとしてマークを付けるかどうかを指定します。構成を消去するには、
null
に設定します。 -
googletag。PubAdsService
拡張
使用します。このサービスは、Google アド マネージャー アカウントから広告を取得して表示するために使用されます。
メソッドの概要 | |
---|---|
addEventListener
|
ページで特定の GPT イベントが発生したときに JavaScript 関数を設定して呼び出せるようにするリスナーを登録します。
|
clear
|
指定したスロットから広告を削除し、空白のコンテンツに置き換えます。
|
clearCategoryExclusions
|
ページレベルの広告カテゴリの除外ラベルをすべて削除します。
|
clearTargeting
|
特定のキーまたはすべてのキーのカスタム ターゲティング パラメータをクリアします。
|
collapseEmptyDivs
|
表示する広告コンテンツがないときにスロット div がページのスペースを占有しないように、折りたたみを有効にします。
|
disableInitialLoad
|
ページ読み込み時に広告のリクエストを無効にしますが、
PubAdsService.refresh 呼び出しによる広告のリクエストは許可します。
|
display
|
指定された広告ユニットのパスとサイズの広告スロットを作成して表示します。
|
enableLazyLoad
|
config オブジェクトの定義に沿って、GPT で遅延読み込みを有効にします。
|
enableSingleRequest
|
複数の広告を同時に取得するシングル リクエスト モードを有効にします。
|
enableVideoAds
|
ページに動画広告があることを GPT に通知します。
|
get
|
指定されたキーに関連付けられている AdSense 属性の値を返します。
|
getAttributeKeys
|
このサービスに設定されている属性キーを返します。
|
getSlots
|
このサービスに関連付けられているスロットのリストを取得します。
|
getTargeting
|
設定されている特定のカスタム サービスレベル ターゲティング パラメータを返します。
|
getTargetingKeys
|
設定されているすべてのカスタム サービスレベル ターゲティング キーのリストを返します。
|
isInitialLoadDisabled
|
広告の最初のリクエストが前回の
PubAdsService.disableInitialLoad 呼び出しによって正常に無効化されたかどうかを返します。
|
refresh
|
ページ上の一部またはすべてのスロットに新しい広告を取得して表示します。
|
removeEventListener
|
以前に登録されたリスナーを削除します。
|
set
|
Publisher Ads サービスのすべての広告スロットに適用される AdSense 属性の値を設定します。
|
setCategoryExclusion
|
指定したラベル名に対してページレベルでの広告カテゴリの除外を設定します。
|
setCentering
|
広告の水平方向中央揃えを有効または無効にします。
|
setForceSafeFrame
|
ページ上のすべての広告を SafeFrame コンテナを使って強制的に表示するかどうかを指定します。
|
setLocation
|
広告申込情報を特定の場所に地域ターゲティングできるように、ウェブサイトから位置情報を渡します。
|
setPrivacySettings
|
構成オブジェクトを使用して、1 つの API からすべてのプライバシー設定を構成できます。
|
setPublisherProvidedId
|
ニュース メディア指定 ID の値を設定します。
|
setSafeFrameConfig
|
SafeFrame についてページレベルの設定を行います。
|
setTargeting
|
指定したキーに対して、パブリッシャー広告サービスのすべての広告スロットに適用されるカスタム ターゲティング パラメータを設定します。
|
setVideoContent
|
ターゲティングやコンテンツの除外を目的として、広告リクエストとともに送信される動画コンテンツ情報を設定します。
|
updateCorrelator
|
広告リクエストとともに送信される相関値を変更して、実質的に新しいページビューを開始します。
|
clear
-
clear(slots?: Slot[]): boolean
-
指定されたスロットから広告を削除し、空白のコンテンツに置き換えます。そのスロットは「未取得」としてマークされます。
特に、スロットをクリアすると、その広告は GPT の存続期間の長いページビューから削除されます。そのため、この広告に関するロードブロッキングや競合相手の除外によって、今後のリクエストに影響が生じることはありません。 -
- 例
-
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(従来版)
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();
-
パラメータ slots?: Slot[]
クリアするスロットの配列。配列は省略可能です。指定しない場合、すべてのスロットがクリアされます。 -
戻り値 boolean
スロットがクリアされた場合はtrue
、それ以外の場合はfalse
を返します。
clearCategoryExclusions
-
clearCategoryExclusions(): PubAdsService
-
ページレベルの広告カテゴリの除外ラベルをすべて削除します。これは、スロットを更新する場合に便利です。
-
- 例
-
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(従来版)
// 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.
- 関連情報
-
戻り値 PubAdsService
メソッドが呼び出されたサービス オブジェクト。
clearTargeting
-
clearTargeting(key?: string): PubAdsService
-
特定のキーまたはすべてのキーのカスタム ターゲティング パラメータをクリアします。
-
- 例
-
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(従来版)
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.
- 関連情報
-
パラメータ key?: string
ターゲティング パラメータのキー。このキーは省略可能です。指定しないと、すべてのターゲティング パラメータがクリアされます。 -
戻り値 PubAdsService
メソッドが呼び出されたサービス オブジェクト。
collapseEmptyDivs
-
collapseEmptyDivs(collapseBeforeAdFetch?: boolean): boolean
-
表示する広告コンテンツがないときにスロット div がページ上のスペースを占有しないように、折りたたみを有効にします。このモードは、サービスを有効にする前に設定する必要があります。
-
パラメータ collapseBeforeAdFetch?: boolean
広告を取得する前でもスロットを折りたたむかどうか。このパラメータは省略可能です。指定しない場合は、デフォルト値としてfalse
が使用されます。 -
戻り値 boolean
div の折りたたみモードが有効になっていた場合はtrue
を返し、サービスが有効になった後にメソッドが呼び出されて折りたたみモードを有効にできない場合はfalse
を返します。
disableInitialLoad
-
disableInitialLoad(): void
-
ページ読み込み時に広告のリクエストを無効にしますが、
PubAdsService.refresh
の呼び出しによる広告のリクエストは許可します。このサービスを有効にする前に設定する必要があります。非同期モードを使用する必要があります。そうしないと、refresh
を使用して広告をリクエストできなくなります。
display
-
display(adUnitPath: string, size: GeneralSize, div?: string | Element, clickUrl?: string): void
-
指定された広告ユニットのパスとサイズで広告スロットを作成して表示します。このメソッドは、シングル リクエスト モードでは機能しません。
注: このメソッドが呼び出されると、広告リクエストの送信時とレスポンスのレンダリング時に一貫性を保つため、スロットとページの状態のスナップショットが作成されます。このメソッドが呼び出された後にスロットやページの状態に加えられた変更(ターゲティング、プライバシー設定、SafeFrame の強制など)は、後続のdisplay()
リクエストやrefresh()
リクエストにのみ適用されます。 -
- 例
-
JavaScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
JavaScript(従来版)
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
- 関連情報
-
パラメータ adUnitPath: string
レンダリングされるスロットの広告ユニットのパス。size: GeneralSize
スロットの幅と高さ。div?: string | Element
スロットを格納する div の ID、または div 要素自体。clickUrl?: string
このスロットで使用するクリック URL。
enableLazyLoad
-
enableLazyLoad(config?: { fetchMarginPercent: number, mobileScaling: number, renderMarginPercent: number }): void
-
config オブジェクトの定義に沿って GPT で遅延読み込みを有効にします。詳細な例については、遅延読み込みのサンプルをご覧ください。
注: SRA での遅延取得は、すべてのスロットが取得のマージンを超えている場合にのみ機能します。 -
- 例
-
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(従来版)
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, });
- 関連情報
-
パラメータ config?: { fetchMarginPercent: number, mobileScaling: number, renderMarginPercent: number }
構成オブジェクトを使用すると、遅延動作をカスタマイズできます。省略した構成では Google がデフォルトの設定を使用し、今後調整される予定です。取得マージンなど、特定の設定を無効にするには、値を-1
に設定します。fetchMarginPercent
現在のビューポートからスロットが広告を取得するために必要な最小距離を、ビューポートのサイズに対する割合で表したもの。値が 0 の場合は「スロットがビューポートに入ったとき」、100 の場合は「広告が 1 つ前にあるとき」になります。renderMarginPercent
現在のビューポートからスロットが広告を表示するための最小距離。これにより、広告をプリフェッチしながら、他のサブリソースのレンダリングとダウンロードを待機できます。この値は、ビューポートの割合としてfetchMarginPercent
と同じように機能します。mobileScaling
モバイル デバイスのマージンに適用される調整因子です。これにより、モバイルとパソコンでさまざまなマージンを持たせることができます。たとえば、値を 2.0 にすると、モバイル デバイスではすべてのマージンが 2 倍になり、取得とレンダリングを行う前のスロットの最小距離が長くなります。
enableSingleRequest
-
enableSingleRequest(): boolean
-
複数の広告を同時に取得するには、シングル リクエスト モードを有効にします。そのためには、サービスを有効にする前に、すべてのパブリッシャー広告スロットを定義して PubAdsService に追加する必要があります。サービスを有効にする前に、シングル リクエスト モードを設定する必要があります。
-
戻り値 boolean
シングル リクエスト モードが有効になっていた場合はtrue
を返し、サービスが有効になった後にメソッドが呼び出されてシングル リクエスト モードを有効にできない場合はfalse
を返します。
enableVideoAds
-
enableVideoAds(): void
-
ページに動画広告があることを GPT に通知します。これにより、ディスプレイ広告と動画広告で競合相手の除外の制約を受けられます。動画コンテンツがわかっている場合は、
PubAdsService.setVideoContent
を呼び出して、ディスプレイ広告でコンテンツの除外を使用できるようにします。 -
get
-
get(key: string): null | string
-
指定されたキーに関連付けられている AdSense 属性の値を返します。
-
- 例
-
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
JavaScript(従来版)
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'.
- 関連情報
-
パラメータ key: string
検索する属性の名前。 -
戻り値 null | string
属性キーの現在の値。キーが存在しない場合はnull
。
getAttributeKeys
-
getAttributeKeys(): string[]
-
このサービスに設定されている属性キーを返します。
-
- 例
-
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(従来版)
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'].
-
戻り値 string[]
このサービスに対して設定されている属性キーの配列。順序が定義されていません。
getTargeting
-
getTargeting(key: string): string[]
-
設定されている特定のカスタム サービスレベル ターゲティング パラメータを返します。
-
- 例
-
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
JavaScript(従来版)
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).
-
パラメータ key: string
検索するターゲティング キー。 -
戻り値 string[]
このキーに関連付けられている値。そのようなキーがない場合は空の配列。
getTargetingKeys
-
getTargetingKeys(): string[]
-
設定されているすべてのカスタム サービスレベル ターゲティング キーのリストを返します。
-
- 例
-
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
JavaScript(従来版)
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'].
-
戻り値 string[]
ターゲティング キーの配列。順序が定義されていません。
isInitialLoadDisabled
-
isInitialLoadDisabled(): boolean
-
広告の最初のリクエストが前回の
PubAdsService.disableInitialLoad
呼び出しによって正常に無効化されたかどうかを返します。 -
-
戻り値 boolean
refresh
-
refresh(slots?: null | Slot[], options?: { changeCorrelator: boolean }): void
-
ページ上の一部またはすべてのスロットに新しい広告を取得して表示します。非同期レンダリング モードでのみ機能します。
すべてのブラウザで適切に動作させるには、refresh
を呼び出す前に広告スロットのdisplay
を呼び出す必要があります。display
の呼び出しを省略すると、更新が予期しない動作をすることがあります。必要に応じて、PubAdsService.disableInitialLoad
メソッドを使用して、display
が広告を取得しないようにできます。
スロットを更新すると、GPT の長期表示ページビューから古い広告が削除されるため、それ以降のリクエストは、その広告に関連するロードブロッキングや競合相手の除外の影響を受けません。 -
- 例
-
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(従来版)
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 });
- 関連情報
-
パラメータ slots?: null | Slot[]
更新するスロット。配列は省略可能です。指定しない場合は、すべてのスロットが更新されます。options?: { changeCorrelator: boolean }
この更新呼び出しに関連付けられた構成オプション。changeCorrelator
広告を取得するために新しい相関値を生成するかどうかを指定します。Google の広告サーバーでは、この reloror 値が短時間(現在は 30 秒間ですが、変更される可能性があります)保持されています。そのため、同じ reloror を持つリクエストをほぼ同時に受信したリクエストは 1 回のページビューと見なされます。デフォルトでは、更新のたびに新しい相関値が生成されます。
注: このオプションは、GPT の長期的ページビューには影響しません。長期的ページビューには、現在ページに表示されている広告が自動的に反映され、有効期限はありません。
set
-
set(key: string, value: string): PubAdsService
-
パブリッシャー広告サービスのすべての広告スロットに適用される AdSense 属性の値を設定します。
同じキーに対してこれを複数回呼び出すと、そのキーに以前設定された値がオーバーライドされます。すべての値は、display
またはrefresh
を呼び出す前に設定する必要があります。 -
- 例
-
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF");
JavaScript(従来版)
googletag.pubads().set("adsense_background_color", "#FFFFFF");
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF");
- 関連情報
-
パラメータ key: string
属性名。value: string
属性値。 -
戻り値 PubAdsService
メソッドが呼び出されたサービス オブジェクト。
setCategoryExclusion
-
setCategoryExclusion(categoryExclusion: string): PubAdsService
-
指定したラベル名をページレベルで広告カテゴリの除外に設定します。
-
- 例
-
JavaScript
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
JavaScript(従来版)
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
TypeScript
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
- 関連情報
-
パラメータ categoryExclusion: string
追加する広告カテゴリの除外ラベル。 -
戻り値 PubAdsService
メソッドが呼び出されたサービス オブジェクト。
setCentering
-
setCentering(centerAds: boolean): void
-
広告の水平方向中央揃えを有効または無効にします。中央揃えはデフォルトで無効になっています。以前の gpt_mobile.js では、センタリングがデフォルトで有効になっています。
このメソッドは、display
またはrefresh
を呼び出す前に呼び出す必要があります。これは、このメソッドの呼び出し後にリクエストされた広告のみがセンタリングされるためです。 -
- 例
-
JavaScript
// Make ads centered. googletag.pubads().setCentering(true);
JavaScript(従来版)
// Make ads centered. googletag.pubads().setCentering(true);
TypeScript
// Make ads centered. googletag.pubads().setCentering(true);
-
パラメータ centerAds: boolean
true
で広告を中央に配置し、false
で左揃えにします。
setForceSafeFrame
-
setForceSafeFrame(forceSafeFrame: boolean): PubAdsService
-
ページ上のすべての広告を SafeFrame コンテナを使って強制的に表示するかどうかを指定します。
この API を使用する際は、次の点に注意してください。- この設定は、それぞれのスロットに対して行われた後続の広告リクエストにのみ適用されます。
- スロットレベルの設定を指定した場合、常にページレベルの設定よりも優先されます。
- スロットレベルまたはページレベルで
true
に設定した場合、Google アド マネージャー管理画面での選択内容にかかわらず、広告は常に SafeFrame コンテナを使用して表示されます。 - ただし、
false
に設定するか未指定のままにした場合は、クリエイティブのタイプと Google アド マネージャー管理画面での選択内容に応じて、SafeFrame コンテナを使って広告が表示されます。 - この API は、iFrame の外に飛び出そうとするクリエイティブや、パブリッシャーのページに直接レンダリングするクリエイティブの動作に影響する可能性があるため、慎重に使用してください。
-
- 例
-
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(従来版)
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");
- 関連情報
-
パラメータ forceSafeFrame: boolean
true
を設定するとページ上のすべての広告が SafeFrame で表示され、false
に設定すると前の設定が false に変わります。以前に指定しなかった場合にfalse
に設定しても、何も変更されません。 -
戻り値 PubAdsService
関数が呼び出されたサービス オブジェクト。
setLocation
-
setLocation(address: string): PubAdsService
-
広告申込情報を特定の場所に地域ターゲティングできるように、ウェブサイトから位置情報を渡します。
-
- 例
-
JavaScript
// Postal code: googletag.pubads().setLocation("10001,US");
JavaScript(従来版)
// Postal code: googletag.pubads().setLocation("10001,US");
TypeScript
// Postal code: googletag.pubads().setLocation("10001,US");
-
パラメータ address: string
自由形式の住所。 -
戻り値 PubAdsService
メソッドが呼び出されたサービス オブジェクト。
setPrivacySettings
-
setPrivacySettings(privacySettings: PrivacySettingsConfig): PubAdsService
-
構成オブジェクトを使用して、1 つの API からすべてのプライバシー設定を構成できます。
-
- 例
-
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(従来版)
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, });
- 関連情報
-
パラメータ privacySettings: PrivacySettingsConfig
プライバシー設定構成を含むオブジェクト。 -
戻り値 PubAdsService
関数が呼び出されたサービス オブジェクト。
setPublisherProvidedId
-
setPublisherProvidedId(ppid: string): PubAdsService
-
パブリッシャー指定の ID の値を設定します。
-
- 例
-
JavaScript
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
JavaScript(従来版)
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
TypeScript
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
- 関連情報
-
パラメータ ppid: string
パブリッシャーから提供される英数字の ID。32 ~ 150 文字で指定してください。 -
戻り値 PubAdsService
メソッドが呼び出されたサービス オブジェクト。
setSafeFrameConfig
-
setSafeFrameConfig(config: SafeFrameConfig): PubAdsService
-
SafeFrame についてページレベルの設定を行います。構成オブジェクト内の認識できないキーは無視されます。認識されたキーに無効な値が渡されると、設定全体は無視されます。
これらのページレベルの設定は、指定した場合、スロットレベルの設定によってオーバーライドされます。 -
- 例
-
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(従来版)
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");
- 関連情報
-
パラメータ config: SafeFrameConfig
構成オブジェクト。 -
戻り値 PubAdsService
メソッドが呼び出されたサービス オブジェクト。
setTargeting
-
setTargeting(key: string, value: string | string[]): PubAdsService
-
指定したキーに対して、パブリッシャー広告サービスのすべての広告スロットに適用されるカスタム ターゲティング パラメータを設定します。同じキーに対してこれを複数回呼び出すと、古い値が上書きされます。これらのキーは Google アド マネージャー アカウントで定義されます。
-
- 例
-
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(従来版)
// 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"]);
- 関連情報
-
パラメータ key: string
ターゲティング パラメータのキー。value: string | string[]
ターゲティング パラメータ値または値の配列。 -
戻り値 PubAdsService
メソッドが呼び出されたサービス オブジェクト。
setVideoContent
-
setVideoContent(videoContentId: string, videoCmsId: string): void
-
ターゲティングやコンテンツの除外を目的として、広告リクエストとともに動画コンテンツ情報を送信するように設定します。このメソッドが呼び出されると、動画広告が自動的に有効になります。
videoContentId
とvideoCmsId
には、Google アド マネージャーのコンテンツ取り込みサービスに提供された値を使用します。 -
- 関連情報
-
パラメータ videoContentId: string
動画コンテンツ ID。videoCmsId: string
動画の CMS ID。
updateCorrelator
-
updateCorrelator(): PubAdsService
-
広告リクエストとともに送信される相関値を変更して、実質的に新しいページビューを開始します。相関関係は、1 回のページビューから発生するすべての広告リクエストで同じで、ページビュー全体で一意です。非同期モードにのみ適用されます。
注: GPT の長期ページビューには影響ありません。このページビューには実際のページ上の広告が自動的に反映され、有効期限はありません。 -
- 例
-
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(従来版)
// 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.
-
戻り値 PubAdsService
関数が呼び出されたサービス オブジェクト。
googletag。ResponseInformation
1 つの広告レスポンスを表すオブジェクト。
プロパティの概要 | |
---|---|
advertiserId
|
広告主の ID。
|
campaignId
|
キャンペーンの ID。
|
creativeId
|
クリエイティブの ID。
|
creativeTemplateId
|
広告のテンプレート ID。
|
lineItemId
|
広告申込情報の ID。
|
advertiserId
-
advertiserId: null | number
-
広告主の ID。
-
campaignId
-
campaignId: null | number
-
キャンペーンの ID。
-
creativeId
-
creativeId: null | number
-
クリエイティブの ID。
-
creativeTemplateId
-
creativeTemplateId: null | number
-
広告のテンプレート ID。
-
lineItemId
-
lineItemId: null | number
-
広告申込情報の ID。
-
googletag。RewardedPayload
リワード広告に関連付けられた報酬を表すオブジェクト。
プロパティの概要 | |
---|---|
amount
|
報酬に含まれるアイテムの数。
|
type
|
特典に含まれるアイテムの種類(「コイン」など)。
|
- 関連情報
amount
-
amount: number
-
報酬に含まれるアイテムの数。
-
type
-
type: string
-
特典に含まれるアイテムの種類(「コイン」など)。
-
googletag。SafeFrameConfig
SafeFrame コンテナの設定オブジェクト。
プロパティの概要 | |
---|---|
allowOverlayExpansion
|
SafeFrame でページ コンテンツに重ねて広告コンテンツを展開できるようにするかどうかを指定します。
|
allowPushExpansion
|
SafeFrame でページ コンテンツをプッシュして広告コンテンツを展開できるようにするかどうかを指定します。
|
sandbox
|
SafeFrame で HTML5 のサンドボックス属性を使用して、ユーザーが操作しなくてもトップレベルのナビゲーションができないようにするかどうかを設定します。
|
useUniqueDomain
|
非推奨。
予約クリエイティブに対して、SafeFrame でランダムなサブドメインを使用するかどうかを指定します。
|
allowOverlayExpansion
-
allowOverlayExpansion: boolean
-
SafeFrame でページ コンテンツに重ねて広告コンテンツを展開できるようにするかどうかを指定します。
-
allowPushExpansion
-
allowPushExpansion: boolean
-
SafeFrame でページ コンテンツをプッシュして広告コンテンツを展開できるようにするかどうかを指定します。
-
sandbox
-
sandbox: boolean
-
SafeFrame で HTML5 の sandbox 属性を使用して、ユーザーが操作しなくてもトップレベルのナビゲーションを行わないようにするかどうかを指定します。有効な値は
true
のみです(強制的にfalse
に設定することはできません)。sandbox 属性を使用すると、プラグイン(Flash など)が無効になります。 -
useUniqueDomain
-
useUniqueDomain: null | boolean
-
SafeFrame で予約クリエイティブに対してランダムなサブドメインを使用するかどうかを指定します。
null
を渡して、保存された値を消去します。
注: この機能はデフォルトで有効になっています。
googletag。Service
すべてのサービスに共通のメソッドを含む基本サービスクラス。
メソッドの概要 | |
---|---|
addEventListener
|
ページで特定の GPT イベントが発生したときに JavaScript 関数を設定して呼び出せるようにするリスナーを登録します。
|
getSlots
|
このサービスに関連付けられているスロットのリストを取得します。
|
removeEventListener
|
以前に登録されたリスナーを削除します。
|
addEventListener
-
addEventListener<K extends keyof EventTypeMap>(eventType: K, listener: (arg: EventTypeMap[K]) => void): Service
-
ページで特定の GPT イベントが発生したときに JavaScript 関数を設定して呼び出せるようにするリスナーを登録します。次のイベントがサポートされています。
リスナーが呼び出されると、適切なイベントタイプのオブジェクトがリスナーに渡されます。 -
- 例
-
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(従来版)
// 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. } });
- 関連情報
-
パラメータ eventType: K
GPT によって生成されたイベントのタイプを表す文字列。イベントタイプでは大文字と小文字が区別されます。listener: (arg: EventTypeMap[K]) => void
単一のイベント オブジェクト引数を取る関数。 -
戻り値 Service
メソッドが呼び出されたサービス オブジェクト。
getSlots
removeEventListener
-
removeEventListener<K extends keyof EventTypeMap>(eventType: K, listener: (event: EventTypeMap[K]) => void): void
-
以前に登録されたリスナーを削除します。
-
- 例
-
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(従来版)
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(); });
-
パラメータ eventType: K
GPT によって生成されたイベントのタイプを表す文字列。イベントタイプでは大文字と小文字が区別されます。listener: (event: EventTypeMap[K]) => void
単一のイベント オブジェクト引数を取る関数。
googletag。SizeMappingBuilder
サイズ マッピング仕様オブジェクトのビルダー。このビルダーは、サイズ指定を簡単に作成するために用意されています。
メソッドの概要 | |
---|---|
addSize
|
単一サイズの配列(ビューポートを表す)から、スロットを表す単一サイズまたはマルチサイズの配列へのマッピングを追加します。
|
build
|
このビルダーに追加されたマッピングからサイズマップ仕様を作成します。
|
- 関連情報
addSize
-
addSize(viewportSize: SingleSizeArray, slotSize: GeneralSize): SizeMappingBuilder
-
単一サイズの配列(ビューポートを表す)から、スロットを表す単一サイズまたはマルチサイズの配列へのマッピングを追加します。
-
- 例
-
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(従来版)
// 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]
-
パラメータ viewportSize: SingleSizeArray
このマッピング エントリのビューポートのサイズ。slotSize: GeneralSize
このマッピング エントリのスロットのサイズ。 -
戻り値 SizeMappingBuilder
このビルダーへの参照。
build
-
build(): null | SizeMappingArray
-
このビルダーに追加されたマッピングからサイズマップの仕様を作成します。
無効なマッピングが指定されている場合、このメソッドはnull
を返します。それ以外の場合は、Slot.defineSizeMapping
に渡す適切な形式で仕様を返します。
注: このメソッドを呼び出した後のビルダーの動作は未定義です。 -
-
戻り値 null | SizeMappingArray
このビルダーで構築された結果。無効なサイズ マッピングが指定されている場合は null になることがあります。
googletag。Slot
Slot は、ページ上の 1 つの広告スロットを表すオブジェクトです。
メソッドの概要 | |
---|---|
addService
|
このスロットに
Service を追加します。
|
clearCategoryExclusions
|
このスロットのスロットレベルの広告カテゴリ除外ラベルをすべてクリアします。
|
clearTargeting
|
このスロットの特定の、またはすべてのカスタム スロットレベルのターゲティング パラメータをクリアします。
|
defineSizeMapping
|
このスロットの最小ビューポート サイズからスロットサイズへのマッピングの配列を設定します。
|
get
|
このスロットに指定されたキーに関連付けられている AdSense 属性の値を返します。
|
getAdUnitPath
|
ネットワーク コードと広告ユニットのパスを含む、広告ユニットのフルパスを返します。
|
getAttributeKeys
|
このスロットに設定されている属性キーのリストを返します。
|
getCategoryExclusions
|
このスロットの広告カテゴリ除外ラベルを返します。
|
getResponseInformation
|
広告レスポンス情報を返します。
|
getSlotElementId
|
スロットが定義されたときに提供されたスロット
div の ID を返します。
|
getTargeting
|
このスロットに設定されている特定のカスタム ターゲティング パラメータを返します。
|
getTargetingKeys
|
このスロットに設定されているすべてのカスタム ターゲティング キーのリストを返します。
|
set
|
この広告スロットの AdSense 属性の値を設定します。
|
setCategoryExclusion
|
このスロットにスロットレベルの広告カテゴリの除外ラベルを設定します。
|
setClickUrl
|
広告をクリックした後にユーザーがリダイレクトされるクリック URL を設定します。
|
setCollapseEmptyDiv
|
スロットに広告がないときにスロット
div を非表示にするかどうかを設定します。
|
setConfig
|
このスロットの一般的な設定オプションを設定します。
|
setForceSafeFrame
|
このスロットの広告を SafeFrame コンテナを使って強制的に表示するかどうかを指定します。
|
setSafeFrameConfig
|
SafeFrame についてスロットレベルの設定を行います。
|
setTargeting
|
このスロットのカスタム ターゲティング パラメータを設定します。
|
updateTargetingFromMap
|
JSON オブジェクトの Key-Value マップから、このスロットのカスタム ターゲティング パラメータを設定します。
|
addService
-
このスロットに
Service
を追加します。 -
- 例
-
JavaScript
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
JavaScript(従来版)
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
TypeScript
googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
- 関連情報
-
パラメータ service: Service
追加するサービス。 -
戻り値 Slot
メソッドが呼び出されたスロット オブジェクト。
clearCategoryExclusions
-
clearCategoryExclusions(): Slot
-
このスロットのスロットレベルの広告カテゴリ除外ラベルをすべてクリアします。
-
- 例
-
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(従来版)
// 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.
-
戻り値 Slot
メソッドが呼び出されたスロット オブジェクト。
clearTargeting
-
clearTargeting(key?: string): Slot
-
このスロットの特定またはすべてのカスタム スロットレベルのターゲティング パラメータをクリアします。
-
- 例
-
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(従来版)
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.
- 関連情報
-
パラメータ key?: string
ターゲティング パラメータのキー。このキーは省略可能です。指定しないと、すべてのターゲティング パラメータがクリアされます。 -
戻り値 Slot
メソッドが呼び出されたスロット オブジェクト。
defineSizeMapping
-
defineSizeMapping(sizeMapping: SizeMappingArray): Slot
-
このスロットの最小ビューポート サイズからスロットサイズへのマッピングの配列を設定します。
-
- 例
-
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(従来版)
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!);
- 関連情報
-
パラメータ sizeMapping: SizeMappingArray
サイズ マッピングの配列。SizeMappingBuilder
を使用して作成できます。各サイズ マッピングは、SingleSizeArray
とGeneralSize
の 2 つの要素の配列です。 -
戻り値 Slot
メソッドが呼び出されたスロット オブジェクト。
get
-
get(key: string): null | string
-
このスロットに指定されたキーに関連付けられている AdSense 属性の値を返します。このスロットによって継承されるサービスレベルの属性を表示するには、
PubAdsService.get
を使用します。 -
- 例
-
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(従来版)
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'.
- 関連情報
-
パラメータ key: string
検索する属性の名前。 -
戻り値 null | string
属性キーの現在の値。キーが存在しない場合はnull
。
getAdUnitPath
-
getAdUnitPath(): string
-
ネットワーク コードと広告ユニットのパスを含む、広告ユニットのフルパスを返します。
-
- 例
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
JavaScript(従来版)
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'.
-
戻り値 string
広告ユニットのパス。
getAttributeKeys
-
getAttributeKeys(): string[]
-
このスロットに設定されている属性キーのリストを返します。このスロットによって継承されたサービスレベル属性のキーを表示するには、
PubAdsService.getAttributeKeys
を使用します。 -
- 例
-
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(従来版)
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'].
-
戻り値 string[]
属性キーの配列。順序が定義されていません。
getCategoryExclusions
-
getCategoryExclusions(): string[]
-
このスロットの広告カテゴリ除外ラベルを返します。
-
- 例
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
JavaScript(従来版)
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'].
-
戻り値 string[]
このスロットの広告カテゴリ除外ラベル。設定されていない場合は空の配列。
getResponseInformation
-
getResponseInformation(): null | ResponseInformation
-
広告レスポンス情報を返します。これは、そのスロットの最後の広告レスポンスに基づきます。スロットに広告がないときにこのメソッドが呼び出されると、
null
が返されます。 -
-
戻り値 null | ResponseInformation
最新の広告レスポンス情報。スロットに広告がない場合はnull
。
getSlotElementId
-
getSlotElementId(): string
-
スロットが定義されたときに提供されたスロット
div
の ID を返します。 -
- 例
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
JavaScript(従来版)
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'.
-
戻り値 string
スロットdiv
の ID。
getTargeting
-
getTargeting(key: string): string[]
-
このスロットに設定されている特定のカスタム ターゲティング パラメータを返します。サービスレベルのターゲティングパラメータは含まれません。
-
- 例
-
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(従来版)
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).
-
パラメータ key: string
検索するターゲティング キー。 -
戻り値 string[]
このキーに関連付けられている値。そのようなキーがない場合は空の配列。
getTargetingKeys
-
getTargetingKeys(): string[]
-
このスロットに設定されているすべてのカスタム ターゲティング キーのリストを返します。サービスレベルのターゲティング キーは含まれません。
-
- 例
-
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(従来版)
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'].
-
戻り値 string[]
ターゲティング キーの配列。順序が定義されていません。
set
-
set(key: string, value: string): Slot
-
この広告スロットの AdSense 属性の値を設定します。これにより、このキーに対してサービスレベルで設定された値がすべてオーバーライドされます。
同じキーに対してこのメソッドを複数回呼び出すと、そのキーに対して以前に設定された値がオーバーライドされます。すべての値は、display
またはrefresh
を呼び出す前に設定する必要があります。 -
- 例
-
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(従来版)
// 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());
- 関連情報
-
パラメータ key: string
属性名。value: string
属性値。 -
戻り値 Slot
メソッドが呼び出されたスロット オブジェクト。
setCategoryExclusion
-
setCategoryExclusion(categoryExclusion: string): Slot
-
このスロットにスロットレベルの広告カテゴリの除外ラベルを設定します。
-
- 例
-
JavaScript
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
JavaScript(従来版)
// 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());
- 関連情報
-
パラメータ categoryExclusion: string
追加する広告カテゴリの除外ラベル。 -
戻り値 Slot
メソッドが呼び出されたスロット オブジェクト。
setClickUrl
-
setClickUrl(value: string): Slot
-
広告をクリックした後にユーザーがリダイレクトされるクリック URL を設定します。
Google アド マネージャー サーバーでは、クリック URL が置き換えられた場合でもクリックが記録されます。配信されるクリエイティブに関連付けられているランディング ページ URL が、指定した値に付加されます。後続の呼び出しでは値が上書きされます。これは SRA 以外のリクエストに対してのみ有効です。 -
- 例
-
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
JavaScript(従来版)
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());
-
パラメータ value: string
設定するクリック URL。 -
戻り値 Slot
メソッドが呼び出されたスロット オブジェクト。
setCollapseEmptyDiv
-
setCollapseEmptyDiv(collapse: boolean, collapseBeforeAdFetch?: boolean): Slot
-
スロットに広告がないときにスロット
div
を非表示にするかどうかを設定します。これはサービスレベルの設定より優先されます。 -
- 例
-
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(従来版)
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.
- 関連情報
-
パラメータ collapse: boolean
広告が返されない場合にスロットを折りたたむかどうか。collapseBeforeAdFetch?: boolean
広告を取得する前でもスロットを折りたたむかどうかを設定します。折りたたみがtrue
でない場合は無視されます。 -
戻り値 Slot
メソッドが呼び出されたスロット オブジェクト。
setConfig
-
setConfig(slotConfig: SlotSettingsConfig): void
-
このスロットの一般的な設定オプションを設定します。
-
-
パラメータ slotConfig: SlotSettingsConfig
構成オブジェクト。
setForceSafeFrame
-
setForceSafeFrame(forceSafeFrame: boolean): Slot
-
このスロットの広告を SafeFrame コンテナを使って強制的に表示するかどうかを指定します。
この API を使用する際は、次の点に注意してください。- この設定は、それぞれのスロットに対して行われた後続の広告リクエストにのみ適用されます。
- スロットレベルの設定を指定した場合、常にページレベルの設定よりも優先されます。
- スロットレベルまたはページレベルで
true
に設定した場合、Google アド マネージャー管理画面での選択内容にかかわらず、広告は常に SafeFrame コンテナを使用して表示されます。 - ただし、
false
に設定するか未指定のままにした場合は、クリエイティブのタイプと Google アド マネージャー管理画面での選択内容に応じて、SafeFrame コンテナを使って広告が表示されます。 - この API は、iFrame の外に飛び出そうとするクリエイティブや、パブリッシャーのページに直接レンダリングするクリエイティブの動作に影響する可能性があるため、慎重に使用してください。
-
- 例
-
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setForceSafeFrame(true) .addService(googletag.pubads());
JavaScript(従来版)
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());
- 関連情報
-
パラメータ forceSafeFrame: boolean
true
を指定すると、このスロットのすべての広告を SafeFrame にレンダリングし、false
を指定すると、ページレベルの設定(存在する場合)をオプトアウトします。ページレベルで指定しない場合、これをfalse
に設定しても何も変更されません。 -
戻り値 Slot
メソッドが呼び出されたスロット オブジェクト。
setSafeFrameConfig
-
setSafeFrameConfig(config: null | SafeFrameConfig): Slot
-
SafeFrame についてスロットレベルの設定を行います。構成オブジェクト内の認識できないキーは無視されます。認識されたキーに無効な値が渡されると、設定全体は無視されます。
これらのスロットレベルの設定を指定すると、ページレベルの設定をオーバーライドします。 -
- 例
-
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(従来版)
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");
- 関連情報
-
パラメータ config: null | SafeFrameConfig
構成オブジェクト。 -
戻り値 Slot
メソッドが呼び出されたスロット オブジェクト。
setTargeting
-
setTargeting(key: string, value: string | string[]): Slot
-
このスロットのカスタム ターゲティング パラメータを設定します。同じキーに対してこのメソッドを複数回呼び出すと、古い値が上書きされます。ここで設定した値により、サービスレベルで設定されたターゲティング パラメータが上書きされます。これらのキーは Google アド マネージャー アカウントで定義されます。
-
- 例
-
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(従来版)
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"]);
- 関連情報
-
パラメータ key: string
ターゲティング パラメータのキー。value: string | string[]
ターゲティング パラメータ値または値の配列。 -
戻り値 Slot
メソッドが呼び出されたスロット オブジェクト。
updateTargetingFromMap
-
updateTargetingFromMap(map: { [adUnitPath: string]: string | string[] }): Slot
-
JSON オブジェクトの Key-Value マップから、このスロットのカスタム ターゲティング パラメータを設定します。これは、オブジェクトのすべてのキー値に対して
Slot.setTargeting
を呼び出すことと同じです。これらのキーは Google アド マネージャー アカウントで定義されます。
注:- 上書きされる場合、最後の値のみが保持されます。
- 値が配列の場合、以前の値はマージされずに上書きされます。
- ここで設定した値により、サービスレベルで設定されたターゲティング パラメータが上書きされます。
-
- 例
-
JavaScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
JavaScript(従来版)
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"], });
-
パラメータ map: { [adUnitPath: string]: string | string[] }
ターゲティング パラメータの Key-Value マップ。 -
戻り値 Slot
メソッドが呼び出されたスロット オブジェクト。
googletag.config.AdExpansionConfig
広告拡張を制御する設定です。
プロパティの概要 | |
---|---|
enabled
|
広告拡張が有効か無効か。
|
- 例
-
JavaScript
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
JavaScript(従来版)
// 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 }, });
enabled
-
enabled: boolean
-
広告拡張が有効か無効か。
この値を設定すると、Google アド マネージャーで設定されたデフォルト値がオーバーライドされます。
googletag.config.ComponentAuctionConfig
デバイス上の広告オークションにおける単一コンポーネントのオークションを表すオブジェクト。
プロパティの概要 | |
---|---|
auctionConfig
|
このコンポーネント オークションのオークション設定オブジェクト。
|
configKey
|
このコンポーネント オークションに関連付けられた設定キー。
|
auctionConfig
-
auctionConfig: null | { auctionSignals: unknown, decisionLogicUrl: string, interestGroupBuyers: string[], perBuyerExperimentGroupIds: { [buyer: string]: number }, perBuyerGroupLimits: { [buyer: string]: number }, perBuyerSignals: { [buyer: string]: unknown }, perBuyerTimeouts: { [buyer: string]: number }, seller: string, sellerExperimentGroupId: number, sellerSignals: unknown, sellerTimeout: number, trustedScoringSignalsUrl: string }
-
このコンポーネント オークションのオークション設定オブジェクト。
この値がnull
に設定されている場合、指定したconfigKey
の既存の設定はすべて削除されます。 -
- 例
-
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(従来版)
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
-
このコンポーネント オークションに関連付けられた設定キー。
この値は空にできず、一意である必要があります。2 つのComponentAuctionConfig
オブジェクトが同じ configKey 値を共有している場合、最後に設定されたものによって以前の構成が上書きされます。 -
googletag.config.InterstitialConfig
1 つのインタースティシャル広告スロットの動作を定義するオブジェクト。
プロパティの概要 | |
---|---|
triggers
|
このインタースティシャル広告のインタースティシャル トリガー設定です。
|
triggers
-
triggers: Partial<Record<InterstitialTrigger, boolean>>
-
このインタースティシャル広告のインタースティシャル トリガーの設定。
インタースティシャル トリガーの値をtrue
に設定すると有効になり、false
で無効になります。この設定は、Google アド マネージャーで設定しているデフォルト値をオーバーライドします。 -
- 例
-
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(従来版)
// Define a GPT managed web interstitial ad slot. var interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL ); // Enable optional interstitial triggers. // Change this value to false to disable. var enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
TypeScript
// Define a GPT managed web interstitial ad slot. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL )!; // Enable optional interstitial triggers. // Change this value to false to disable. const enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
- 関連情報
googletag.config.PageSettingsConfig
ページレベルの設定を行うためのメインの構成インターフェース。
1 回の API 呼び出しで複数の機能を設定できます。
以下のプロパティはすべて例であり、setConfig を使用する実際の機能を反映していません。一連の機能については、以下の PageSettingsConfig タイプのフィールドをご覧ください。
例:
setConfig
呼び出しで指定された対象物のみが変更されます。// Configure feature alpha. googletag.setConfig({ alpha: {...} }); // Configure feature bravo. Feature alpha is unchanged. googletag.setConfig({ bravo: {...} });
- ある対象物のすべての設定は、
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 } });
- 機能のすべての設定は、
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, });
プロパティの概要 | |
---|---|
adExpansion
|
広告拡張を制御する設定です。
|
pps
|
パブリッシャー提供のシグナル(PPS)を管理するための設定です。
|
privacyTreatments
|
パブリッシャーのプライバシーの取り扱いを管理するための設定です。
|
adExpansion
-
adExpansion: null | AdExpansionConfig
-
広告拡張を制御する設定です。
-
pps
-
pps: null | PublisherProvidedSignalsConfig
-
パブリッシャー提供のシグナル(PPS)を管理するための設定です。
-
privacyTreatments
-
privacyTreatments: null | PrivacyTreatmentsConfig
-
パブリッシャーのプライバシーの取り扱いを管理するための設定。
-
googletag.config.PrivacyTreatmentsConfig
パブリッシャーのプライバシーの取り扱いを管理するための設定。
プロパティの概要 | |
---|---|
treatments
|
有効にできる、パブリッシャーのプライバシー保護に関する項目の配列。
|
treatments
-
treatments: "disablePersonalization"[]
-
有効にできるパブリッシャーのプライバシー保護に関する項目の配列。
-
- 例
-
JavaScript
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
JavaScript(従来版)
// 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
パブリッシャー提供のシグナル(PPS)設定オブジェクト。
プロパティの概要 | |
---|---|
taxonomies
|
分類マッピングを含むオブジェクト。
|
- 例
-
JavaScript
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 18-20' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
JavaScript(従来版)
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 18-20' // '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 | 18-20' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
- 関連情報
taxonomies
-
taxonomies: Partial<Record<Taxonomy, TaxonomyData>>
-
分類マッピングを含むオブジェクト。
-
googletag.config.SlotSettingsConfig
スロットレベルの設定を行うためのメインの構成インターフェース。
1 つのスロットに対して 1 回の API 呼び出しで複数の機能を設定できます。
以下のプロパティはすべて例であり、setConfig を使用する実際の機能を反映していません。一連の機能については、以下の SlotSettingsConfig タイプのフィールドをご覧ください。
例:
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: {...} });
- ある対象物のすべての設定は、
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 } });
- 機能のすべての設定は、
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, });
プロパティの概要 | |
---|---|
adExpansion
|
広告拡張を制御する設定です。
|
componentAuction
|
デバイス上の広告オークションに参加するコンポーネント オークションの配列。
|
interstitial
|
インタースティシャル広告スロットの動作を制御する設定。
|
adExpansion
-
adExpansion: AdExpansionConfig
-
広告拡張を制御する設定です。
-
componentAuction
-
componentAuction: ComponentAuctionConfig[]
-
デバイス上の広告オークションに参加する一連のコンポーネント オークション。
-
interstitial
-
interstitial: InterstitialConfig
-
インタースティシャル広告スロットの動作を制御する設定。
-
googletag.config.TaxonomyData
1 つの Taxonomy の値を含むオブジェクト。
プロパティの概要 | |
---|---|
values
|
分類値のリスト。
|
values
-
values: string[]
-
分類値のリスト。
-
googletag.events.Event
すべての GPT イベントの基本インターフェースです。以下のすべての GPT イベントには、以下のフィールドが含まれます。
プロパティの概要 | |
---|---|
serviceName
|
イベントをトリガーしたサービスの名前。
|
slot
|
イベントをトリガーしたスロット。
|
- 関連情報
serviceName
-
serviceName: string
-
イベントをトリガーしたサービスの名前。
-
slot
-
slot: Slot
-
イベントをトリガーしたスロット。
-
googletag.events.EventTypeMap
これは Service.addEventListener
と Service.removeEventListener
の対応するイベント オブジェクト タイプにイベント名をマッピングする疑似タイプです。このドキュメントは、参照および型安全性のみを目的としています。
impressionViewable
-
impressionViewable: ImpressionViewableEvent
-
events.ImpressionViewableEvent
のエイリアス。 -
rewardedSlotClosed
-
rewardedSlotClosed: RewardedSlotClosedEvent
-
events.RewardedSlotClosedEvent
のエイリアス。 -
rewardedSlotGranted
-
rewardedSlotGranted: RewardedSlotGrantedEvent
-
events.RewardedSlotGrantedEvent
のエイリアス。 -
rewardedSlotReady
-
rewardedSlotReady: RewardedSlotReadyEvent
-
events.RewardedSlotReadyEvent
のエイリアス。 -
slotOnload
-
slotOnload: SlotOnloadEvent
-
events.SlotOnloadEvent
のエイリアス。 -
slotRenderEnded
-
slotRenderEnded: SlotRenderEndedEvent
-
events.SlotRenderEndedEvent
のエイリアス。 -
slotRequested
-
slotRequested: SlotRequestedEvent
-
events.SlotRequestedEvent
のエイリアス。 -
slotResponseReceived
-
slotResponseReceived: SlotResponseReceived
-
events.SlotResponseReceived
のエイリアス。 -
slotVisibilityChanged
-
slotVisibilityChanged: SlotVisibilityChangedEvent
-
googletag.events.ImpressionViewableEvent
拡張
このイベントは、アクティブ ビューの条件に沿ってインプレッションが視認可能になると発生します。
プロパティの概要 | |
---|---|
serviceName
|
イベントをトリガーしたサービスの名前。
|
slot
|
イベントをトリガーしたスロット。
|
- 例
-
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(従来版)
// This listener is called when an impression becomes viewable. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", function (event) { var slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when an impression becomes viewable. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", (event) => { const slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
- 関連情報
googletag.events.RewardedSlotClosedEvent
拡張
このイベントは、ユーザーがリワード広告スロットを閉じると発生します。これは、報酬が付与される前か後に発動します。報酬が付与されているかどうかを確認するには、代わりに events.RewardedSlotGrantedEvent
を使用します。
プロパティの概要 | |
---|---|
serviceName
|
イベントをトリガーしたサービスの名前。
|
slot
|
イベントをトリガーしたスロット。
|
- 例
-
JavaScript
// This listener is called when the user closes a rewarded ad slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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(従来版)
// This listener is called when the user closes a rewarded ad slot. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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
// This listener is called when the user closes a rewarded ad slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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
拡張
このイベントは、リワード広告の視聴に対して報酬が付与されると発生します。報酬を付与する条件が満たされる前に広告が閉じられた場合、このイベントは配信されません。
プロパティの概要 | |
---|---|
payload
|
付与された報酬に関する情報を含むオブジェクト。
|
serviceName
|
イベントをトリガーしたサービスの名前。
|
slot
|
イベントをトリガーしたスロット。
|
- 例
-
JavaScript
// This listener is called whenever a reward is granted for a // rewarded ad. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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(従来版)
// This listener is called whenever a reward is granted for a // rewarded ad. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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
// This listener is called whenever a reward is granted for a // rewarded ad. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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. } });
- 関連情報
payload
-
payload: null | RewardedPayload
-
付与された報酬に関する情報を含むオブジェクト。
-
googletag.events.RewardedSlotReadyEvent
拡張
このイベントは、リワード広告を表示できるようになると発生します。パブリッシャーは、広告を表示する前に、そのオプションをユーザーに提示する責任を負います。
プロパティの概要 | |
---|---|
serviceName
|
イベントをトリガーしたサービスの名前。
|
slot
|
イベントをトリガーしたスロット。
|
メソッドの概要 | |
---|---|
makeRewardedVisible
|
リワード広告を表示します。
|
- 例
-
JavaScript
// This listener is called when a rewarded ad slot becomes ready to be // displayed. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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(従来版)
// This listener is called when a rewarded ad slot becomes ready to be // displayed. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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.defineSlot("/1234567/example", [160, 600]); 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. } });
- 関連情報
makeRewardedVisible
-
makeRewardedVisible(): void
-
リワード広告を表示します。ユーザーが広告の表示に同意するまで、このメソッドは呼び出されません。
-
googletag.events.SlotOnloadEvent
拡張
このイベントは、クリエイティブの iframe で読み込みイベントが発生すると発生します。同期レンダリング モードでリッチメディア広告をレンダリングする場合、iframe は使用されないため、SlotOnloadEvent
は呼び出されません。
プロパティの概要 | |
---|---|
serviceName
|
イベントをトリガーしたサービスの名前。
|
slot
|
イベントをトリガーしたスロット。
|
- 例
-
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(従来版)
// This listener is called when a creative iframe load event fires. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", function (event) { var slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when a creative iframe load event fires. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { const slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
- 関連情報
googletag.events.SlotRenderEndedEvent
拡張
このイベントは、クリエイティブ コードがスロットに挿入されると発生します。このイベントはクリエイティブのリソースが取得される前に発生するため、クリエイティブがまだ表示されていない可能性があります。スロットのすべてのクリエイティブ リソースの読み込みが完了したタイミングを把握する必要がある場合は、代わりに events.SlotOnloadEvent
を使用することを検討してください。
プロパティの概要 | |
---|---|
advertiserId
|
レンダリングされた広告の広告主 ID。
|
campaignId
|
レンダリングされた広告のキャンペーン ID。
|
companyIds
|
レンダリングされたバックフィル広告に入札する会社の ID。
|
creativeId
|
レンダリングされた予約広告のクリエイティブ ID。
|
creativeTemplateId
|
レンダリングされた純広告のクリエイティブ テンプレート ID。
|
isBackfill
|
広告がバックフィル広告かどうか。
|
isEmpty
|
スロットに対して広告が返されたかどうか。
|
labelIds
|
レンダリングされた広告のラベル ID。
|
lineItemId
|
レンダリングされた予約広告の広告申込情報 ID。
|
serviceName
|
イベントをトリガーしたサービスの名前。
|
size
|
レンダリングされたクリエイティブのピクセルサイズを示します。
|
slot
|
イベントをトリガーしたスロット。
|
slotContentChanged
|
レンダリングされた広告でスロット コンテンツが変更されたかどうかを示します。
|
sourceAgnosticCreativeId
|
レンダリングされた予約広告またはバックフィル広告のクリエイティブ ID。
|
sourceAgnosticLineItemId
|
レンダリングされた予約広告またはバックフィル広告の広告申込情報 ID。
|
yieldGroupIds
|
レンダリングされたバックフィル広告の収益グループの ID。
|
- 例
-
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("Label IDs:", event.labelIds); 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(従来版)
// 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("Label IDs:", event.labelIds); 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("Label IDs:", event.labelIds); 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. } });
- 関連情報
advertiserId
-
advertiserId: null | number
-
レンダリングされた広告の広告主 ID。空のスロット、バックフィル広告、
PubAdsService
以外のサービスでレンダリングされたクリエイティブの値はnull
です。 -
campaignId
-
campaignId: null | number
-
レンダリングされた広告のキャンペーン ID。空のスロット、バックフィル広告、
PubAdsService
以外のサービスでレンダリングされたクリエイティブの値はnull
です。 -
companyIds
-
companyIds: null | number[]
-
レンダリングされたバックフィル広告に入札した企業の ID。空のスロット、純広告、
PubAdsService
以外のサービスでレンダリングされたクリエイティブの値はnull
です。 -
creativeId
-
creativeId: null | number
-
レンダリングされた予約広告のクリエイティブ ID。空のスロット、バックフィル広告、
PubAdsService
以外のサービスでレンダリングされたクリエイティブの値はnull
です。 -
creativeTemplateId
-
creativeTemplateId: null | number
-
表示された予約広告のクリエイティブ テンプレート ID。空のスロット、バックフィル広告、
PubAdsService
以外のサービスでレンダリングされたクリエイティブの値はnull
です。 -
isBackfill
-
isBackfill: boolean
-
広告がバックフィル広告かどうか。広告がバックフィル広告の場合、値は
true
、それ以外の場合はfalse
です。 -
isEmpty
-
isEmpty: boolean
-
スロットに対して広告が返されたかどうか。広告が返されなかった場合、値は
true
、それ以外の場合はfalse
になります。 -
labelIds
-
labelIds: null | number[]
-
レンダリングされた広告のラベル ID。空のスロット、バックフィル広告、
PubAdsService
以外のサービスでレンダリングされたクリエイティブの値はnull
です。 -
lineItemId
-
lineItemId: null | number
-
レンダリングされた予約広告の広告申込情報 ID。空のスロット、バックフィル広告、
PubAdsService
以外のサービスでレンダリングされたクリエイティブの値はnull
です。 -
size
-
size: null | string | number[]
-
レンダリングされたクリエイティブのピクセルサイズを示します。例:
[728, 90]
。空の広告スロットの値はnull
です。 -
slotContentChanged
-
slotContentChanged: boolean
-
レンダリングされた広告でスロット コンテンツが変更されたかどうかを示します。コンテンツが変更された場合、値は
true
、それ以外の場合はfalse
です。 -
sourceAgnosticCreativeId
-
sourceAgnosticCreativeId: null | number
-
レンダリングされた予約広告またはバックフィル広告のクリエイティブ ID。広告が予約または広告申込情報のバックフィルではない場合、またはクリエイティブが
PubAdsService
以外のサービスによってレンダリングされる場合、値はnull
です。 -
sourceAgnosticLineItemId
-
sourceAgnosticLineItemId: null | number
-
レンダリングされた予約広告またはバックフィル広告の広告申込情報 ID。広告が予約または広告申込情報のバックフィルではない場合、またはクリエイティブが
PubAdsService
以外のサービスによってレンダリングされる場合、値はnull
です。 -
yieldGroupIds
-
yieldGroupIds: null | number[]
-
レンダリングされたバックフィル広告の収益グループの ID。空のスロット、純広告、
PubAdsService
以外のサービスでレンダリングされたクリエイティブの値はnull
です。 -
googletag.events.SlotRequestedEvent
拡張
このイベントは、特定のスロットで広告がリクエストされると発生します。
プロパティの概要 | |
---|---|
serviceName
|
イベントをトリガーしたサービスの名前。
|
slot
|
イベントをトリガーしたスロット。
|
- 例
-
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(従来版)
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", function (event) { var slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", (event) => { const slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
- 関連情報
googletag.events.SlotResponseReceived
拡張
このイベントは、特定のスロットで広告レスポンスを受信すると発生します。
プロパティの概要 | |
---|---|
serviceName
|
イベントをトリガーしたサービスの名前。
|
slot
|
イベントをトリガーしたスロット。
|
- 例
-
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(従来版)
// This listener is called when an ad response has been received // for a slot. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", function (event) { var slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when an ad response has been received // for a slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", (event) => { const slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
- 関連情報
googletag.events.SlotVisibilityChangedEvent
拡張
このイベントは、広告スロットの領域に対して画面上の割合が変わると発生します。イベントはスロットリングされ、200 ミリ秒に 1 回を超える頻度で発生しません。
プロパティの概要 | |
---|---|
inViewPercentage
|
広告の領域のうち、視認可能な割合。
|
serviceName
|
イベントをトリガーしたサービスの名前。
|
slot
|
イベントをトリガーしたスロット。
|
- 例
-
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(従来版)
// 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. } });
- 関連情報
inViewPercentage
-
inViewPercentage: number
-
広告の領域のうち、視認可能な割合。値は 0 ~ 100 の数字です。
-
googletag.secureSignals.BidderSignalProvider
特定のビッダーのセキュア シグナルを返します。
ビッダーのセキュア シグナル プロバイダは、次の 2 つの部分で構成されます。
- セキュア シグナルに解決される
Promise
を返すコレクタ関数。 - シグナルに関連付けられているビッダーを識別する
id
。
secureSignals.PublisherSignalProvider
を使用します。
プロパティの概要 | |
---|---|
collectorFunction
|
|
id
|
このセキュア シグナルに関連付けられているコレクタの一意の識別子(Google アド マネージャーに登録されているもの)。
|
- 例
-
JavaScript
// id is provided googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript(従来版)
// 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"); }, });
- 関連情報
collectorFunction
-
collectorFunction: () => Promise<string>
-
id
-
id: string
-
このセキュア シグナルに関連付けられているコレクタの一意の識別子(Google アド マネージャーに登録されているもの)。
-
googletag.secureSignals.PublisherSignalProvider
特定のパブリッシャーのセキュア シグナルを返します。
パブリッシャー シグナル プロバイダは、次の 2 つの要素で構成されます。
- セキュア シグナルに解決される
Promise
を返すコレクタ関数。 - シグナルに関連付けられているパブリッシャーを識別する
networkCode
。
secureSignals.BidderSignalProvider
を使用します。
プロパティの概要 | |
---|---|
collectorFunction
|
|
networkCode
|
このセキュア シグナルに関連付けられているパブリッシャーのネットワーク コード(広告ユニットのパスに表示)。
|
- 例
-
JavaScript
// networkCode is provided googletag.secureSignalProviders.push({ networkCode: "123456", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript(従来版)
// 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"); }, });
- 関連情報
collectorFunction
-
collectorFunction: () => Promise<string>
-
networkCode
-
networkCode: string
-
このセキュア シグナルに関連付けられているパブリッシャーのネットワーク コード(広告ユニットのパスに表示)。
-
googletag.secureSignals.SecureSignalProvidersArray
セキュア シグナルを管理するためのインターフェース。
メソッドの概要 | |
---|---|
clearAllCache
|
キャッシュされたすべてのシグナルをローカル ストレージから削除します。
|
push
|
新しい
secureSignals.SecureSignalProvider をシグナル プロバイダ配列に追加し、シグナル生成プロセスを開始します。
|
clearAllCache
-
clearAllCache(): void
-
キャッシュされたすべてのシグナルをローカル ストレージから削除します。
-
push
-
push(provider: SecureSignalProvider): void
-
新しい
secureSignals.SecureSignalProvider
をシグナル プロバイダ配列に追加し、シグナル生成プロセスを開始します。 -
-
パラメータ provider: SecureSignalProvider
配列に追加するsecureSignals.SecureSignalProvider
オブジェクト。