জিপিটি রেফারেন্স

এই রেফারেন্সে টাইপ বর্ণনা করার জন্য টাইপস্ক্রিপ্ট নোটেশন ব্যবহার করা হয়েছে। নিচের সারণিতে উদাহরণসহ একটি সংক্ষিপ্ত ব্যাখ্যা দেওয়া হয়েছে।

টাইপ এক্সপ্রেশন
string আদিম স্ট্রিং টাইপ।
string[] একটি অ্যারে টাইপ, যেখানে ভ্যালুগুলো শুধুমাত্র স্ট্রিং হতে পারে।
number | string একটি ইউনিয়ন টাইপ, যেখানে ভ্যালুটি একটি সংখ্যা বা স্ট্রিং হতে পারে।
Array<number | string> একটি অ্যারে টাইপ, যেখানে ভ্যালুগুলো একটি কমপ্লেক্স (ইউনিয়ন) টাইপের হয়।
[number, string] একটি টাপল টাইপ, যেখানে ভ্যালুটি হলো দুটি উপাদানের একটি অ্যারে, যাতে অবশ্যই ক্রমানুসারে একটি সংখ্যা এবং একটি স্ট্রিং থাকতে হবে।
Slot একটি অবজেক্ট টাইপ, যেখানে ভ্যালুটি হলো googletag.Slot এর একটি ইনস্ট্যান্স।
() => void এমন এক ধরনের ফাংশন যার কোনো সংজ্ঞায়িত আর্গুমেন্ট এবং রিটার্ন ভ্যালু নেই।

সমর্থিত টাইপ এবং টাইপ এক্সপ্রেশন সম্পর্কে আরও জানতে, টাইপস্ক্রিপ্ট হ্যান্ডবুক দেখুন।

টাইপ টীকা

ভেরিয়েবল, প্যারামিটার নাম, প্রপার্টি নাম বা ফাংশন সিগনেচারের পরে একটি কোলন (:) একটি টাইপ অ্যানোটেশন নির্দেশ করে। টাইপ অ্যানোটেশন বর্ণনা করে যে কোলনের বাম দিকের উপাদানটি কোন ধরনের ডেটা গ্রহণ বা ফেরত দিতে পারে। নিচের সারণিতে এই রেফারেন্সে আপনি দেখতে পারেন এমন কিছু টাইপ অ্যানোটেশনের উদাহরণ দেখানো হলো।

টাইপ টীকা
param: string এটি নির্দেশ করে যে param একটি স্ট্রিং ভ্যালু গ্রহণ বা রিটার্ন করে। এই সিনট্যাক্সটি ভেরিয়েবল, প্যারামিটার, প্রোপার্টি এবং রিটার্ন টাইপের জন্য ব্যবহৃত হয়।
param?: number | string এটি নির্দেশ করে যে param ঐচ্ছিক, কিন্তু নির্দিষ্ট করা হলে এটি একটি সংখ্যা বা স্ট্রিং গ্রহণ করে। এই সিনট্যাক্সটি প্যারামিটার এবং প্রপার্টির জন্য ব্যবহৃত হয়।
...params: Array<() => void> এটি নির্দেশ করে যে params একটি রেস্ট প্যারামিটার যা ফাংশন গ্রহণ করে। রেস্ট প্যারামিটারগুলো নির্দিষ্ট টাইপের অসীম সংখ্যক ভ্যালু গ্রহণ করতে পারে।

googletag

গুগল পাবলিশার ট্যাগ তার এপিআই-এর জন্য যে গ্লোবাল নেমস্পেসটি ব্যবহার করে।
নেমস্পেস
config
পৃষ্ঠা-স্তরের সেটিংসের জন্য প্রধান কনফিগারেশন ইন্টারফেস।
enums
এটি সেই নেমস্পেস যা GPT এনাম টাইপগুলোর জন্য ব্যবহার করে।
events
এটি সেই নেমস্পেস যা GPT ইভেন্টগুলির জন্য ব্যবহার করে।
secure Signals
এটি সেই নেমস্পেস যা GPT নিরাপদ সংকেত ব্যবস্থাপনার জন্য ব্যবহার করে।
ইন্টারফেস
Command Array
কমান্ড অ্যারে একাধিক ফাংশন গ্রহণ করে এবং সেগুলোকে ক্রমানুসারে কল করে।
Companion Ads Service
সহযোগী বিজ্ঞাপন পরিষেবা।
Privacy Settings Config
গোপনীয়তা সেটিংসের জন্য কনফিগারেশন অবজেক্ট।
Pub Ads Service
প্রকাশক বিজ্ঞাপন পরিষেবা।
Response Information
একটি বস্তু যা একটিমাত্র বিজ্ঞাপন প্রতিক্রিয়ার প্রতিনিধিত্ব করে।
Rewarded Payload
একটি পুরস্কারপ্রাপ্ত বিজ্ঞাপনের সাথে যুক্ত পুরস্কারের প্রতিনিধিত্বকারী বস্তু।
Service
বেস সার্ভিস ক্লাস, যেটিতে সকল সার্ভিসের জন্য সাধারণ মেথডগুলো রয়েছে।
Size Mapping Builder
আকার ম্যাপিং স্পেসিফিকেশন অবজেক্টের বিল্ডার।
Slot
স্লট হলো এমন একটি অবজেক্ট যা একটি পৃষ্ঠার একটিমাত্র বিজ্ঞাপন স্লটকে প্রতিনিধিত্ব করে।
প্রকার উপনাম
Fluid Size
সাইজ স্ট্রিং যেখানে বিজ্ঞাপন কন্টেইনারটি তার প্যারেন্ট ডিভের ১০০% প্রস্থ নেয় এবং তারপর ক্রিয়েটিভ কন্টেন্টের সাথে মানানসই করার জন্য এর উচ্চতা পরিবর্তন করে।
General Size
একটি স্লটের জন্য বৈধ আকারের কনফিগারেশন, যা এক বা একাধিক আকার হতে পারে।
Multi Size
একক বৈধ আকারগুলির একটি তালিকা।
Named Size
একটি স্লটের যে নির্দিষ্ট আকারগুলো থাকতে পারে।
Single Size
একটি স্লটের জন্য একটিমাত্র বৈধ আকার।
Single Size Array
[প্রস্থ, উচ্চতা] নির্দেশকারী দুটি সংখ্যার অ্যারে।
Size Mapping
ভিউপোর্ট সাইজের সাথে বিজ্ঞাপনের আকারের একটি ম্যাপিং।
Size Mapping Array
আকার ম্যাপিংগুলির একটি তালিকা।
ভেরিয়েবল
api Ready
এই ফ্ল্যাগটি নির্দেশ করে যে GPT API লোড হয়েছে এবং কল করার জন্য প্রস্তুত।
cmd
GPT-সম্পর্কিত কলগুলির অ্যাসিঙ্ক্রোনাস সম্পাদনের জন্য গ্লোবাল কমান্ড কিউ-এর রেফারেন্স।
pubads Ready
ফ্ল্যাগ যা নির্দেশ করে যে PubAdsService সক্রিয়, লোড এবং সম্পূর্ণরূপে কার্যকর রয়েছে।
secure Signal Providers
নিরাপদ সংকেত প্রদানকারী অ্যারের উল্লেখ।
কার্যাবলী
companion Ads
CompanionAdsService- এর একটি রেফারেন্স ফেরত দেয়।
define Out Of Page Slot
প্রদত্ত অ্যাড ইউনিট পাথ ব্যবহার করে পৃষ্ঠার বাইরে একটি বিজ্ঞাপন স্লট তৈরি করে।
define Slot
প্রদত্ত অ্যাড ইউনিট পাথ ও সাইজ ব্যবহার করে একটি অ্যাড স্লট তৈরি করে এবং এটিকে পেজের সেই div এলিমেন্টের ID-এর সাথে যুক্ত করে, যেটিতে বিজ্ঞাপনটি থাকবে।
destroy Slots
প্রদত্ত স্লটগুলো ধ্বংস করে এবং GPT থেকে সেই স্লটগুলোর সমস্ত সম্পর্কিত অবজেক্ট ও রেফারেন্স মুছে ফেলে।
disable Publisher Console
গুগল পাবলিশার কনসোল নিষ্ক্রিয় করে।
display
স্লট পরিষেবাগুলিকে স্লটটি রেন্ডার করার নির্দেশ দেয়।
enable Services
পৃষ্ঠার বিজ্ঞাপন স্লটগুলির জন্য সংজ্ঞায়িত সমস্ত GPT পরিষেবা সক্রিয় করে।
get Config
setConfig দ্বারা সেট করা পেজটির সাধারণ কনফিগারেশন অপশনগুলোর একটি স্থির অনুলিপি পাওয়া যায়।
get Version
GPT-এর বর্তমান সংস্করণটি ফেরত দেয়।
open Console
গুগল পাবলিশার কনসোল খোলে।
pubads
PubAdsService- এর একটি রেফারেন্স ফেরত দেয়।
set Ad Iframe Title
এখন থেকে PubAdsService দ্বারা তৈরি সমস্ত বিজ্ঞাপন কন্টেইনার আইফ্রেমের শিরোনাম নির্ধারণ করে।
set Config
পৃষ্ঠাটির জন্য সাধারণ কনফিগারেশন বিকল্পসমূহ নির্ধারণ করে।
size Mapping
একটি নতুন SizeMappingBuilder তৈরি করে।

প্রকার উপনাম


তরলের আকার

FluidSize : "fluid"
সাইজ স্ট্রিং যেখানে বিজ্ঞাপন কন্টেইনারটি তার প্যারেন্ট ডিভের ১০০% প্রস্থ নেয় এবং তারপর ক্রিয়েটিভ কন্টেন্টের সাথে মানানসই করার জন্য এর উচ্চতা পরিবর্তন করে। এটি একটি পৃষ্ঠার সাধারণ ব্লক এলিমেন্টগুলোর আচরণের মতোই। নেটিভ বিজ্ঞাপনের জন্য ব্যবহৃত হয় ( সম্পর্কিত নিবন্ধ দেখুন)।

সাধারণ আকার

GeneralSize : SingleSize | MultiSize
একটি স্লটের জন্য বৈধ আকারের কনফিগারেশন, যা এক বা একাধিক আকার হতে পারে।

মাল্টিসাইজ

MultiSize : SingleSize []
একক বৈধ আকারগুলির একটি তালিকা।

নামযুক্ত আকার

NamedSize : FluidSize | [ FluidSize ]
একটি স্লটের জন্য নির্দিষ্ট কিছু মাপ থাকতে পারে। বেশিরভাগ ক্ষেত্রে মাপটি একটি নির্দিষ্ট আকারের আয়তক্ষেত্র হয়, কিন্তু কিছু ক্ষেত্রে আমাদের অন্য ধরনের মাপের প্রয়োজন হয়। শুধুমাত্র নিম্নলিখিত মাপগুলোই বৈধ নামযুক্ত মাপ হিসেবে গণ্য হবে:
  • ফ্লুইড : বিজ্ঞাপন কন্টেইনারটি তার প্যারেন্ট ডিভের ১০০% প্রস্থ নেয় এবং তারপর ক্রিয়েটিভ কন্টেন্টের সাথে মানানসই করার জন্য এর উচ্চতা পরিবর্তন করে। এটি একটি পৃষ্ঠার সাধারণ ব্লক এলিমেন্টগুলোর আচরণের মতোই কাজ করে। নেটিভ বিজ্ঞাপনের জন্য ব্যবহৃত হয় ( সম্পর্কিত নিবন্ধ দেখুন)। উল্লেখ্য যে, একটি স্লটের আকারকে ফ্লুইড হিসেবে ঘোষণা করার জন্য fluid এবং ['fluid'] উভয়ই গ্রহণযোগ্য রূপ।

একক আকার

SingleSize : SingleSizeArray | NamedSize
একটি স্লটের জন্য একটিমাত্র বৈধ আকার।

একক আকারের অ্যারে

SingleSizeArray : [ number , number ]
[প্রস্থ, উচ্চতা] নির্দেশকারী দুটি সংখ্যার অ্যারে।

সাইজম্যাপিং

SizeMapping : [ SingleSizeArray , GeneralSize ]
ভিউপোর্ট সাইজের সাথে বিজ্ঞাপনের আকারের একটি ম্যাপিং। রেসপন্সিভ বিজ্ঞাপনের জন্য ব্যবহৃত হয়।

সাইজম্যাপিংঅ্যারে

SizeMappingArray : SizeMapping []
আকার ম্যাপিংগুলির একটি তালিকা।

ভেরিয়েবল


Const apiReady

apiReady : boolean | undefined
এই ফ্ল্যাগটি নির্দেশ করে যে GPT API লোড হয়েছে এবং কল করার জন্য প্রস্তুত। API প্রস্তুত না হওয়া পর্যন্ত এই প্রপার্টিটি undefined থাকবে।

উল্লেখ্য যে, অ্যাসিঙ্ক (async) পরিচালনার জন্য প্রস্তাবিত উপায় হলো, GPT প্রস্তুত হলে কলব্যাকগুলো কিউ (queue) করার জন্য googletag.cmd ব্যবহার করা। এই কলব্যাকগুলোকে googletag.apiReady চেক করতে হয় না, কারণ API সেট আপ হয়ে গেলেই এগুলো নিশ্চিতভাবে এক্সিকিউট হয়।

Const সিএমডি

cmd : ( ( this : typeof globalThis ) => void ) [] | CommandArray
GPT-সম্পর্কিত কলগুলির অ্যাসিঙ্ক্রোনাস সম্পাদনের জন্য গ্লোবাল কমান্ড কিউ-এর রেফারেন্স।

পৃষ্ঠার GPT ট্যাগ সিনট্যাক্স দ্বারা googletag.cmd ভেরিয়েবলটি একটি খালি জাভাস্ক্রিপ্ট অ্যারে দিয়ে ইনিশিয়ালাইজ করা হয়, এবং cmd.push হলো স্ট্যান্ডার্ড Array.push মেথড যা অ্যারের শেষে একটি এলিমেন্ট যোগ করে। যখন GPT জাভাস্ক্রিপ্ট লোড হয়, তখন এটি অ্যারের মধ্যে অনুসন্ধান করে এবং ক্রমানুসারে সমস্ত ফাংশন এক্সিকিউট করে। এরপর স্ক্রিপ্টটি cmd একটি CommandArray অবজেক্ট দিয়ে প্রতিস্থাপন করে, যার push মেথডটি এতে পাস করা ফাংশন আর্গুমেন্টটি এক্সিকিউট করার জন্য সংজ্ঞায়িত করা থাকে। এই প্রক্রিয়াটি GPT-কে অ্যাসিঙ্ক্রোনাসভাবে জাভাস্ক্রিপ্ট ফেচ করার মাধ্যমে অনুভূত ল্যাটেন্সি কমাতে সাহায্য করে, এবং একই সাথে ব্রাউজারকে পৃষ্ঠাটি রেন্ডার করা চালিয়ে যাওয়ার সুযোগ দেয়।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.cmd.push(() => {
  googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads());
});

জাভাস্ক্রিপ্ট (পুরানো)

googletag.cmd.push(function () {
  googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads());
});

টাইপস্ক্রিপ্ট

googletag.cmd.push(() => {
  googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads());
});

Const pubadsReady

pubadsReady : boolean | undefined
একটি ফ্ল্যাগ যা নির্দেশ করে যে PubAdsService সক্রিয়, লোড এবং সম্পূর্ণরূপে কার্যকর। enableServices কল করা না হওয়া পর্যন্ত এবং PubAdsService লোড ও ইনিশিয়ালাইজ না হওয়া পর্যন্ত এই প্রপার্টিটি কেবল undefined থাকবে।

নিরাপদ সংকেত প্রদানকারী

secureSignalProviders : SecureSignalProvider [] | SecureSignalProvidersArray | undefined
নিরাপদ সংকেত প্রদানকারী অ্যারের উল্লেখ।

সুরক্ষিত সিগন্যাল প্রোভাইডার অ্যারেটি সিগন্যাল-উৎপাদনকারী ফাংশনগুলোর একটি ক্রম গ্রহণ করে এবং সেগুলোকে ক্রমানুসারে আহ্বান করে। এটি এমন একটি স্ট্যান্ডার্ড অ্যারের প্রতিস্থাপন হিসেবে তৈরি করা হয়েছে, যা GPT লোড হওয়ার পর আহ্বান করার জন্য সিগন্যাল-উৎপাদনকারী ফাংশনগুলোকে কিউতে যুক্ত করতে ব্যবহৃত হয়।
উদাহরণ

জাভাস্ক্রিপ্ট

window.googletag = window.googletag || { cmd: [] };
googletag.secureSignalProviders = googletag.secureSignalProviders || [];
googletag.secureSignalProviders.push({
  id: "collector123",
  collectorFunction: () => {
    return Promise.resolve("signal");
  },
});

জাভাস্ক্রিপ্ট (পুরানো)

window.googletag = window.googletag || { cmd: [] };
googletag.secureSignalProviders = googletag.secureSignalProviders || [];
googletag.secureSignalProviders.push({
  id: "collector123",
  collectorFunction: function () {
    return Promise.resolve("signal");
  },
});

টাইপস্ক্রিপ্ট

window.googletag = window.googletag || { cmd: [] };
googletag.secureSignalProviders = googletag.secureSignalProviders || [];
googletag.secureSignalProviders.push({
  id: "collector123",
  collectorFunction: () => {
    return Promise.resolve("signal");
  },
});
আরও দেখুন

কার্যাবলী


সঙ্গী বিজ্ঞাপন

companionAds ( ) : CompanionAdsService
CompanionAdsService- এর একটি রেফারেন্স ফেরত দেয়।
ফেরত
CompanionAdsService কম্প্যানিয়ন অ্যাডস পরিষেবা।

defineOutOfPageSlot

defineOutOfPageSlot ( adUnitPath : string , div ?: string | OutOfPageFormat ) : Slot | null
প্রদত্ত অ্যাড ইউনিট পাথ ব্যবহার করে পৃষ্ঠার বাইরে একটি বিজ্ঞাপন স্লট তৈরি করে।

কাস্টম আউট-অফ-পেজ বিজ্ঞাপনের ক্ষেত্রে, div হলো সেই div এলিমেন্টের আইডি যা বিজ্ঞাপনটি ধারণ করবে। আরও বিস্তারিত জানতে আউট-অফ-পেজ ক্রিয়েটিভ সম্পর্কিত আর্টিকেলটি দেখুন।

GPT দ্বারা পরিচালিত পৃষ্ঠার বাইরের বিজ্ঞাপনের জন্য, div একটি সমর্থিত OutOfPageFormat
উদাহরণ

জাভাস্ক্রিপ্ট

// 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);

জাভাস্ক্রিপ্ট (পুরানো)

// 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);

টাইপস্ক্রিপ্ট

// 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 নেটওয়ার্ক কোড এবং অ্যাড ইউনিট কোড সহ সম্পূর্ণ অ্যাড ইউনিট পাথ
Optional div : string | OutOfPageFormat যে div-টি এই বিজ্ঞাপন ইউনিট বা OutOfPageFormat ধারণ করবে তার ID।
ফেরত
Slot | null নতুন তৈরি করা স্লট, অথবা স্লট তৈরি করা না গেলে null

ডিফাইনস্লট

defineSlot ( adUnitPath : string , size : GeneralSize , div ?: string ) : Slot | null
প্রদত্ত অ্যাড ইউনিট পাথ ও সাইজ ব্যবহার করে একটি অ্যাড স্লট তৈরি করে এবং এটিকে পেজের সেই div এলিমেন্টের ID-এর সাথে যুক্ত করে, যেটিতে বিজ্ঞাপনটি থাকবে।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.defineSlot("/1234567/sports", [728, 90], "div-1");

জাভাস্ক্রিপ্ট (পুরানো)

googletag.defineSlot("/1234567/sports", [728, 90], "div-1");

টাইপস্ক্রিপ্ট

googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
আরও দেখুন
প্যারামিটার
adUnitPath : string নেটওয়ার্ক কোড এবং ইউনিট কোড সহ সম্পূর্ণ অ্যাড ইউনিট পাথ
size : GeneralSize যুক্ত করা স্লটটির প্রস্থ এবং উচ্চতা। যদি কোনো রেসপন্সিভ সাইজ ম্যাপিং প্রদান করা না হয় অথবা ভিউপোর্টের আকার ম্যাপিং-এ প্রদত্ত ক্ষুদ্রতম আকারের চেয়ে ছোট হয়, তাহলে বিজ্ঞাপন অনুরোধে এই আকারটিই ব্যবহৃত হয়।
Optional div : string যে div-টিতে এই বিজ্ঞাপন ইউনিটটি থাকবে, তার ID।
ফেরত
Slot | null নতুন তৈরি করা স্লট, অথবা স্লট তৈরি করা না গেলে null

স্লট ধ্বংস করুন

destroySlots ( slots ?: Slot [] ) : boolean
প্রদত্ত স্লটগুলো ধ্বংস করে এবং GPT থেকে সেই স্লটগুলোর সমস্ত সম্পর্কিত অবজেক্ট ও রেফারেন্স মুছে ফেলে। এই API পাসব্যাক স্লট এবং কম্প্যানিয়ন স্লট সমর্থন করে না।

কোনো স্লটে এই API কল করলে বিজ্ঞাপনটি মুছে যায় এবং GPT দ্বারা পরিচালিত অভ্যন্তরীণ অবস্থা থেকে স্লট অবজেক্টটি অপসারিত হয়। স্লট অবজেক্টে এর চেয়ে বেশি কোনো ফাংশন কল করলে অনির্ধারিত আচরণ দেখা দেবে। উল্লেখ্য যে, পাবলিশার পেজ যদি সেই স্লটের একটি রেফারেন্স বজায় রাখে, তবে ব্রাউজারটি হয়তো এর সাথে যুক্ত মেমরি মুক্ত নাও করতে পারে। এই API কল করলে সেই স্লটের সাথে যুক্ত div-টি পুনঃব্যবহারের জন্য উপলব্ধ হয়।

বিশেষত, একটি স্লট ধ্বংস করলে বিজ্ঞাপনটি GPT-এর দীর্ঘস্থায়ী পেজভিউ থেকে মুছে যায়, ফলে ভবিষ্যতের অনুরোধগুলো এই বিজ্ঞাপন-সম্পর্কিত বাধা বা প্রতিযোগিতামূলক বর্জন দ্বারা প্রভাবিত হবে না। পৃষ্ঠা থেকে একটি স্লটের div সরানোর আগে এই ফাংশনটি কল করতে ব্যর্থ হলে অনির্ধারিত আচরণ দেখা দেবে।
উদাহরণ

জাভাস্ক্রিপ্ট

// 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();

জাভাস্ক্রিপ্ট (পুরানো)

// 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();

টাইপস্ক্রিপ্ট

// 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();
প্যারামিটার
Optional slots : Slot [] ধ্বংস করার জন্য স্লটগুলোর অ্যারে। অ্যারেটি ঐচ্ছিক; এটি অনির্দিষ্ট থাকলে সমস্ত স্লট ধ্বংস হয়ে যাবে।
ফেরত
boolean স্লটগুলো ধ্বংস হয়ে গেলে true , অন্যথায় false

disablePublisherConsole

disablePublisherConsole ( ) : void
গুগল পাবলিশার কনসোল নিষ্ক্রিয় করে।
আরও দেখুন

প্রদর্শন

display ( divOrSlot : string | Element | Slot ) : void
স্লট সার্ভিসকে স্লটটি রেন্ডার করার নির্দেশ দেয়। প্রতিটি বিজ্ঞাপন স্লট প্রতি পৃষ্ঠায় শুধুমাত্র একবারই প্রদর্শিত হওয়া উচিত। প্রদর্শিত হওয়ার আগে সমস্ত স্লট অবশ্যই সংজ্ঞায়িত থাকতে হবে এবং সেগুলোর সাথে একটি সার্ভিস যুক্ত থাকতে হবে। এলিমেন্টটি DOM-এ উপস্থিত না হওয়া পর্যন্ত ডিসপ্লে কলটি করা যাবে না। এটি করার সাধারণ উপায় হলো, মেথড কলে উল্লেখিত div এলিমেন্টের ভেতরের একটি স্ক্রিপ্ট ব্লকে এটিকে স্থাপন করা।

যদি সিঙ্গেল রিকোয়েস্ট আর্কিটেকচার (SRA) ব্যবহার করা হয়, তাহলে এই মেথডটি কল করার সময়কার সমস্ত আনফেচড অ্যাড স্লট একবারে ফেচ করা হবে। কোনো অ্যাড স্লটকে প্রদর্শিত না করার জন্য, সম্পূর্ণ div-টি মুছে ফেলতে হবে।
আরও দেখুন
প্যারামিটার
divOrSlot : string | Element | Slot হয় বিজ্ঞাপন স্লট ধারণকারী div এলিমেন্টের আইডি, অথবা div এলিমেন্টটি, অথবা স্লট অবজেক্টটি। যদি একটি div এলিমেন্ট প্রদান করা হয়, তবে সেটিতে অবশ্যই একটি 'id' অ্যাট্রিবিউট থাকতে হবে যা defineSlot- এ পাঠানো আইডির সাথে মেলে।

সক্ষম পরিষেবা

enableServices ( ) : void
পৃষ্ঠার বিজ্ঞাপন স্লটগুলির জন্য সংজ্ঞায়িত সমস্ত GPT পরিষেবা সক্রিয় করে।

getConfig

getConfig ( keys : string | string [] ) : Readonly < Pick < PageSettingsConfig , "adsenseAttributes" | "disableInitialLoad" | "targeting" > >
setConfig দ্বারা সেট করা পেজটির সাধারণ কনফিগারেশন অপশনগুলোর একটি স্থির অনুলিপি পাওয়া যায়।

এই মেথডটি setConfig() এর সকল প্রপার্টি সমর্থন করে না। সমর্থিত প্রপার্টিগুলো হলো:
উদাহরণ

জাভাস্ক্রিপ্ট

// Get the value of the `targeting` setting.
const targetingConfig = googletag.getConfig("targeting");

// Get the value of the `adsenseAttributes` and `disableInitialLoad` settings.
const config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);

জাভাস্ক্রিপ্ট (পুরানো)

// Get the value of the `targeting` setting.
var targetingConfig = googletag.getConfig("targeting");

// Get the value of the `adsenseAttributes` and `disableInitialLoad` settings.
var config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);

টাইপস্ক্রিপ্ট

// Get the value of the `targeting` setting.
const targetingConfig = googletag.getConfig("targeting");

// Get the value of the `adsenseAttributes` and `disableInitialLoad` settings.
const config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
প্যারামিটার
keys : string | string [] কনফিগারেশন অপশনগুলোর চাবিগুলো পেতে হবে।
ফেরত
Readonly < Pick < PageSettingsConfig , "adsenseAttributes" | "disableInitialLoad" | "targeting" > > পৃষ্ঠাটির কনফিগারেশন বিকল্পগুলির একটি স্থির অনুলিপি।

সংস্করণ পান

getVersion ( ) : string
GPT-এর বর্তমান সংস্করণটি ফেরত দেয়।
আরও দেখুন
ফেরত
string বর্তমানে কার্যকর GPT সংস্করণ স্ট্রিং।

ওপেনকনসোল

openConsole ( div ?: string ) : void
গুগল পাবলিশার কনসোল খোলে।
উদাহরণ

জাভাস্ক্রিপ্ট

// Calling with div ID.
googletag.openConsole("div-1");

// Calling without div ID.
googletag.openConsole();

জাভাস্ক্রিপ্ট (পুরানো)

// Calling with div ID.
googletag.openConsole("div-1");

// Calling without div ID.
googletag.openConsole();

টাইপস্ক্রিপ্ট

// Calling with div ID.
googletag.openConsole("div-1");

// Calling without div ID.
googletag.openConsole();
আরও দেখুন
প্যারামিটার
Optional div : string একটি বিজ্ঞাপন স্লটের ডিভ আইডি। এই মানটি ঐচ্ছিক। এটি প্রদান করা হলে, পাবলিশার কনসোলটি নির্দিষ্ট বিজ্ঞাপন স্লটটির বিবরণসহ খোলার চেষ্টা করবে।

পাবাড

pubads ( ) : PubAdsService
PubAdsService- এর একটি রেফারেন্স ফেরত দেয়।
ফেরত
PubAdsService প্রকাশক বিজ্ঞাপন পরিষেবা।

setAdIframeTitle

setAdIframeTitle ( title : string ) : void
এখন থেকে PubAdsService দ্বারা তৈরি সমস্ত বিজ্ঞাপন কন্টেইনার আইফ্রেমের শিরোনাম নির্ধারণ করে।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setAdIframeTitle("title");

জাভাস্ক্রিপ্ট (পুরানো)

googletag.setAdIframeTitle("title");

টাইপস্ক্রিপ্ট

googletag.setAdIframeTitle("title");
প্যারামিটার
title : string সকল বিজ্ঞাপন কন্টেইনার আইফ্রেমের নতুন শিরোনাম।

setConfig

setConfig ( config : PageSettingsConfig ) : void
পৃষ্ঠাটির জন্য সাধারণ কনফিগারেশন বিকল্পসমূহ নির্ধারণ করে।
প্যারামিটার
config : PageSettingsConfig

আকার ম্যাপিং

sizeMapping ( ) : SizeMappingBuilder
একটি নতুন SizeMappingBuilder তৈরি করে।
আরও দেখুন
ফেরত
SizeMappingBuilder একজন নতুন নির্মাতা।

googletag.CommandArray

কমান্ড অ্যারে একাধিক ফাংশন গ্রহণ করে এবং সেগুলোকে ক্রমানুসারে কল করে। GPT লোড হওয়ার পর কল করার জন্য ফাংশনগুলোকে কিউতে যুক্ত করতে ব্যবহৃত একটি স্ট্যান্ডার্ড অ্যারের পরিবর্তে এটি তৈরি করা হয়েছে।
পদ্ধতি
push
আর্গুমেন্টগুলিতে নির্দিষ্ট করা ফাংশনগুলির ক্রমানুসারে সম্পাদন করে।

পদ্ধতি


ধাক্কা

push ( ... f : ( ( this : typeof globalThis ) => void ) [] ) : number
আর্গুমেন্টগুলিতে নির্দিষ্ট করা ফাংশনগুলির ক্রমানুসারে সম্পাদন করে।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.cmd.push(() => {
  googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads());
});

জাভাস্ক্রিপ্ট (পুরানো)

googletag.cmd.push(function () {
  googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads());
});

টাইপস্ক্রিপ্ট

googletag.cmd.push(() => {
  googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads());
});
প্যারামিটার
Rest ... f : ( ( this : typeof globalThis ) => void ) [] কার্যকর করার জন্য একটি জাভাস্ক্রিপ্ট ফাংশন। রানটাইম বাইন্ডিং সর্বদা globalThis হবে। পরিবেষ্টনকারী লেক্সিকাল কনটেক্সটের ' this মানটি ধরে রাখতে একটি অ্যারো ফাংশন পাস করার কথা বিবেচনা করুন।
ফেরত
number এখন পর্যন্ত প্রক্রিয়াকৃত কমান্ডের সংখ্যা। এটি Array.push এর রিটার্ন মানের (অ্যারের বর্তমান দৈর্ঘ্য) সাথে সামঞ্জস্যপূর্ণ।

googletag.CompanionAdsService

Service প্রসারিত করে
সহযোগী বিজ্ঞাপন পরিষেবা। ভিডিও বিজ্ঞাপনগুলো সহযোগী বিজ্ঞাপন দেখানোর জন্য এই পরিষেবাটি ব্যবহার করে।
পদ্ধতি
add Event Listener
একটি লিসেনার রেজিস্টার করে, যা আপনাকে পেজে কোনো নির্দিষ্ট GPT ইভেন্ট ঘটলে একটি জাভাস্ক্রিপ্ট ফাংশন সেট আপ ও কল করার সুযোগ দেয়।
get Slots
এই পরিষেবার সাথে যুক্ত স্লটগুলির তালিকা নিন।
remove Event Listener
পূর্বে নিবন্ধিত একটি লিসেনার অপসারণ করে।
set Refresh Unfilled Slots
অপূর্ণ সঙ্গী স্থানগুলো স্বয়ংক্রিয়ভাবে পূরণ করা হবে কিনা তা নির্ধারণ করে।
আরও দেখুন

পদ্ধতি


setRefreshUnfilledSlots

setRefreshUnfilledSlots ( value : boolean ) : void
অপূর্ণ সঙ্গী স্থানগুলো স্বয়ংক্রিয়ভাবে পূরণ করা হবে কিনা তা নির্ধারণ করে।

পৃষ্ঠাটির জীবনকালে ব্যাকফিল চালু ও বন্ধ করার জন্য এই পদ্ধতিটি একাধিকবার কল করা যেতে পারে। শুধুমাত্র সেই স্লটগুলোই ব্যাকফিল করা হবে যেগুলো PubAdsService-এর সাথেও নিবন্ধিত। নীতিগত সীমাবদ্ধতার কারণে, যখন কোনো Ad Exchange ভিডিও পরিবেশন করা হয়, তখন খালি সহযোগী স্লটগুলো পূরণ করার জন্য এই পদ্ধতিটি ডিজাইন করা হয়নি।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.companionAds().setRefreshUnfilledSlots(true);

জাভাস্ক্রিপ্ট (পুরানো)

googletag.companionAds().setRefreshUnfilledSlots(true);

টাইপস্ক্রিপ্ট

googletag.companionAds().setRefreshUnfilledSlots(true);
প্যারামিটার
value : boolean খালি স্থানগুলি স্বয়ংক্রিয়ভাবে পূরণ করতে true , অপরিবর্তিত রাখতে false

googletag.PrivacySettingsConfig

গোপনীয়তা সেটিংসের জন্য কনফিগারেশন অবজেক্ট।
বৈশিষ্ট্য
child Directed Treatment ?
পৃষ্ঠাটিকে চাইল্ড-ডিরেক্টেড হিসেবে গণ্য করা হবে কিনা তা নির্দেশ করে।
limited Ads ?
প্রকাশকের নিয়ন্ত্রক সম্মতি সংক্রান্ত চাহিদা পূরণে সহায়তার জন্য সীমিত বিজ্ঞাপন মোডে পরিষেবা চালানো সক্ষম করে।
non Personalized Ads ?
প্রকাশকদের নিয়ন্ত্রক সম্মতি সংক্রান্ত চাহিদা পূরণে সহায়তার জন্য, এটি নন-পার্সোনালাইজড বিজ্ঞাপন মোডে বিজ্ঞাপন পরিবেশন চালাতে সক্ষম করে।
restrict Data Processing ?
প্রকাশকদের নিয়ন্ত্রক সম্মতি সংক্রান্ত চাহিদা পূরণে সহায়তার জন্য, এটি পরিবেশন প্রক্রিয়াকে সীমিত প্রক্রিয়াকরণ মোডে চালানোর সুযোগ দেয়।
tag For Age Treatment ?
বয়স-সীমাবদ্ধ ব্যবস্থা, যা নির্দেশ করে বিজ্ঞাপনের অনুরোধটি শিশু, কিশোর, নাকি অনির্দিষ্ট হিসেবে বিবেচিত হবে।
traffic Source ?
অনুরোধগুলো ক্রয়কৃত নাকি অর্গানিক ট্র্যাফিক, তা নির্দেশ করে।
under Age Of Consent ?
সম্মতির বয়সের কম বয়সী ব্যবহারকারীদের কাছ থেকে আসা বিজ্ঞাপনের অনুরোধগুলোকে চিহ্নিত করা হবে কিনা তা নির্দেশ করে।
আরও দেখুন

বৈশিষ্ট্য


Optional শিশু-নির্দেশিত চিকিৎসা

childDirectedTreatment ?: boolean
পৃষ্ঠাটিকে চাইল্ড-ডিরেক্টেড হিসেবে গণ্য করা হবে কিনা তা নির্দেশ করে। কনফিগারেশনটি মুছে ফেলতে এটিকে null এ সেট করুন।

Optional সীমিত বিজ্ঞাপন

limitedAds ?: boolean
প্রকাশকের নিয়ন্ত্রক সম্মতি সংক্রান্ত চাহিদা পূরণে সহায়তার জন্য সীমিত বিজ্ঞাপন মোডে পরিষেবা চালানো সক্ষম করে।

আপনি দুইভাবে GPT-কে সীমিত বিজ্ঞাপন অনুরোধ করার নির্দেশ দিতে পারেন:
  • আইএবি টিসিএফ ভি২.০ সম্মতি ব্যবস্থাপনা প্ল্যাটফর্ম থেকে প্রাপ্ত সংকেত ব্যবহার করে স্বয়ংক্রিয়ভাবে।
  • ম্যানুয়ালি, এই ফিল্ডের মান ' true সেট করে।
সীমিত বিজ্ঞাপন ম্যানুয়ালি কনফিগার করা শুধুমাত্র তখনই সম্ভব যখন GPT সীমিত বিজ্ঞাপনের URL থেকে লোড করা হয়। যখন GPT স্ট্যান্ডার্ড URL থেকে লোড করা থাকে, তখন এই সেটিংটি পরিবর্তন করার চেষ্টা করলে একটি পাবলিশার কনসোল সতর্কতা তৈরি হবে।

মনে রাখবেন যে, যখন কোনো সিএমপি (CMP) ব্যবহৃত হচ্ছে, তখন সীমিত বিজ্ঞাপন ম্যানুয়ালি চালু করার প্রয়োজন নেই।
উদাহরণ

জাভাস্ক্রিপ্ট

// Manually enable limited ads serving.
// GPT must be loaded from the limited ads URL to configure this setting.
googletag.pubads().setPrivacySettings({
  limitedAds: true,
});

জাভাস্ক্রিপ্ট (পুরানো)

// Manually enable limited ads serving.
// GPT must be loaded from the limited ads URL to configure this setting.
googletag.pubads().setPrivacySettings({
  limitedAds: true,
});

টাইপস্ক্রিপ্ট

// Manually enable limited ads serving.
// GPT must be loaded from the limited ads URL to configure this setting.
googletag.pubads().setPrivacySettings({
  limitedAds: true,
});
আরও দেখুন

Optional অ-ব্যক্তিগতকৃত বিজ্ঞাপন

nonPersonalizedAds ?: boolean
প্রকাশকদের নিয়ন্ত্রক সম্মতি সংক্রান্ত চাহিদা পূরণে সহায়তার জন্য, এটি নন-পার্সোনালাইজড বিজ্ঞাপন মোডে বিজ্ঞাপন পরিবেশন চালাতে সক্ষম করে।

Optional ডেটা প্রক্রিয়াকরণ সীমাবদ্ধ করুন

restrictDataProcessing ?: boolean
প্রকাশকদের নিয়ন্ত্রক সম্মতি সংক্রান্ত চাহিদা পূরণে সহায়তার জন্য, এটি পরিবেশন প্রক্রিয়াকে সীমিত প্রক্রিয়াকরণ মোডে চালানোর সুযোগ দেয়।

Optional ট্যাগ বয়স চিকিৎসা

tagForAgeTreatment ?: TagForAgeTreatment
বয়স-সীমাবদ্ধ ব্যবস্থা, যা নির্দেশ করে বিজ্ঞাপনের অনুরোধটি শিশু, কিশোর, নাকি অনির্দিষ্ট হিসেবে বিবেচিত হবে।

আপনার আইনি এবং নিয়ন্ত্রক প্রয়োজনীয়তার উপর ভিত্তি করে আপনার ব্যবহারকারীদের জন্য বয়স সংক্রান্ত সেটিংস নির্ধারণ করতে আপনার নিজস্ব আইনি পরামর্শদাতার সাথে পরামর্শ করুন। এই সেটিং সম্পর্কে আরও তথ্যের জন্য, এই সহায়তা কেন্দ্রের নিবন্ধটি পর্যালোচনা করুন।

এই প্রপার্টিটি সেট করার মাধ্যমে, আপনি প্রত্যয়ন করছেন যে এই বিজ্ঞপ্তিটি সঠিক এবং আপনি সাইটের মালিকের পক্ষ থেকে কাজ করার জন্য অনুমোদিত। আপনি বুঝতে পারছেন যে এই সেটিংটির অপব্যবহারের ফলে আপনার গুগল অ্যাকাউন্টটি বন্ধ করে দেওয়া হতে পারে।
উদাহরণ

জাভাস্ক্রিপ্ট

// Enable teen privacy treatment.
googletag.pubads().setPrivacySettings({
  tagForAgeTreatment: googletag.enums.TagForAgeTreatment.TEEN,
});

// Clear age treatment configuration.
googletag.pubads().setPrivacySettings({
  tagForAgeTreatment: googletag.enums.TagForAgeTreatment.UNSPECIFIED,
});

জাভাস্ক্রিপ্ট (পুরানো)

// Enable teen privacy treatment.
googletag.pubads().setPrivacySettings({
  tagForAgeTreatment: googletag.enums.TagForAgeTreatment.TEEN,
});

// Clear age treatment configuration.
googletag.pubads().setPrivacySettings({
  tagForAgeTreatment: googletag.enums.TagForAgeTreatment.UNSPECIFIED,
});

টাইপস্ক্রিপ্ট

// Enable teen privacy treatment.
googletag.pubads().setPrivacySettings({
  tagForAgeTreatment: googletag.enums.TagForAgeTreatment.TEEN,
});

// Clear age treatment configuration.
googletag.pubads().setPrivacySettings({
  tagForAgeTreatment: googletag.enums.TagForAgeTreatment.UNSPECIFIED,
});

Optional ট্র্যাফিক উৎস

trafficSource ?: TrafficSource
অনুরোধগুলি ক্রয়কৃত নাকি অর্গানিক ট্র্যাফিক, তা নির্দেশ করে। এই মানটি অ্যাড ম্যানেজার রিপোর্টিং-এর ট্র্যাফিক সোর্স ডাইমেনশনে যুক্ত হয়। যদি এটি সেট করা না থাকে, তাহলে রিপোর্টিং-এ ট্র্যাফিক সোর্স ডিফল্টরূপে undefined থাকে।
উদাহরণ

জাভাস্ক্রিপ্ট

// 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,
});

জাভাস্ক্রিপ্ট (পুরানো)

// 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,
});

টাইপস্ক্রিপ্ট

// Indicate requests represent organic traffic.
googletag.pubads().setPrivacySettings({
  trafficSource: googletag.enums.TrafficSource.ORGANIC,
});

// Indicate requests represent purchased traffic.
googletag.pubads().setPrivacySettings({
  trafficSource: googletag.enums.TrafficSource.PURCHASED,
});

Optional অপ্রাপ্তবয়স্ক সম্মতি

underAgeOfConsent ?: boolean
সম্মতির বয়সের কম বয়সী ব্যবহারকারীদের কাছ থেকে আসা বিজ্ঞাপনের অনুরোধগুলোকে চিহ্নিত করা হবে কিনা তা নির্দেশ করে। কনফিগারেশনটি মুছে ফেলতে এটিকে null এ সেট করুন।

googletag.PubAdsService

Service প্রসারিত করে
পাবলিশার অ্যাডস সার্ভিস। এই সার্ভিসটি আপনার গুগল অ্যাড ম্যানেজার অ্যাকাউন্ট থেকে বিজ্ঞাপন সংগ্রহ করে দেখানোর জন্য ব্যবহৃত হয়।
পদ্ধতি
add Event Listener
একটি লিসেনার রেজিস্টার করে, যা আপনাকে পেজে কোনো নির্দিষ্ট GPT ইভেন্ট ঘটলে একটি জাভাস্ক্রিপ্ট ফাংশন সেট আপ ও কল করার সুযোগ দেয়।
clear
প্রদত্ত স্লটগুলো থেকে বিজ্ঞাপন সরিয়ে সেগুলোর জায়গায় ফাঁকা বিষয়বস্তু প্রদর্শন করে।
clear Category Exclusions
অপ্রচলিত। পৃষ্ঠা-স্তরের সমস্ত বিজ্ঞাপন বিভাগ বর্জন লেবেল মুছে দেয়।
clear Targeting
অপ্রচলিত। একটি নির্দিষ্ট কী অথবা সমস্ত কী-এর জন্য কাস্টম টার্গেটিং প্যারামিটার মুছে ফেলে।
collapse Empty Divs
অপ্রচলিত। এটি স্লট ডিভগুলোকে সংকুচিত করার সুবিধা দেয়, যাতে প্রদর্শনের জন্য কোনো বিজ্ঞাপন না থাকলে সেগুলো পেজে কোনো জায়গা দখল না করে।
disable Initial Load
অপ্রচলিত। এটি পেজ লোড হওয়ার সময় বিজ্ঞাপনের অনুরোধ নিষ্ক্রিয় করে, কিন্তু PubAdsService.refresh কলের মাধ্যমে বিজ্ঞাপনের অনুরোধ করার সুযোগ দেয়।
display
প্রদত্ত অ্যাড ইউনিট পাথ ও সাইজ অনুযায়ী একটি অ্যাড স্লট তৈরি করে প্রদর্শন করে।
enable Lazy Load
অপ্রচলিত। কনফিগ অবজেক্ট দ্বারা সংজ্ঞায়িত GPT-তে লেজি লোডিং সক্ষম করে।
enable Single Request
অপ্রচলিত। একই সময়ে একাধিক বিজ্ঞাপন আনার জন্য একক অনুরোধ মোড সক্ষম করে।
enable Video Ads
অপ্রচলিত। এটি GPT-কে সংকেত দেয় যে পেজটিতে ভিডিও বিজ্ঞাপন প্রদর্শিত হবে।
get
অপ্রচলিত। প্রদত্ত কী-এর সাথে যুক্ত AdSense অ্যাট্রিবিউটের মান ফেরত দেয়।
get Attribute Keys
অপ্রচলিত। এই সার্ভিসে সেট করা অ্যাট্রিবিউট কীগুলো ফেরত দেয়।
get Slots
এই পরিষেবার সাথে যুক্ত স্লটগুলির তালিকা নিন।
get Targeting
অপ্রচলিত। সেট করা একটি নির্দিষ্ট কাস্টম সার্ভিস-লেভেল টার্গেটিং প্যারামিটার ফেরত দেয়।
get Targeting Keys
অপ্রচলিত। সেট করা হয়েছে এমন সমস্ত কাস্টম সার্ভিস-লেভেল টার্গেটিং কী-এর তালিকা ফেরত দেয়।
is Initial Load Disabled
অপ্রচলিত। পূর্ববর্তী PubAdsService.disableInitialLoad কলের মাধ্যমে বিজ্ঞাপনের প্রাথমিক অনুরোধগুলি সফলভাবে নিষ্ক্রিয় করা হয়েছিল কিনা তা ফেরত দেয়।
refresh
পৃষ্ঠার নির্দিষ্ট বা সমস্ত স্লটের জন্য নতুন বিজ্ঞাপন খুঁজে বের করে প্রদর্শন করে।
remove Event Listener
পূর্বে নিবন্ধিত একটি লিসেনার অপসারণ করে।
set
অপ্রচলিত। এটি অ্যাডসেন্স অ্যাট্রিবিউটের এমন মান নির্ধারণ করে যা পাবলিশার অ্যাডস পরিষেবার অধীনে থাকা সমস্ত বিজ্ঞাপন স্লটে প্রযোজ্য।
set Category Exclusion
অপ্রচলিত। প্রদত্ত লেবেল নামের জন্য পৃষ্ঠা-স্তরের বিজ্ঞাপন বিভাগ বর্জন নির্ধারণ করে।
set Centering
অপ্রচলিত। বিজ্ঞাপনের আনুভূমিক কেন্দ্রীকরণ সক্ষম ও অক্ষম করে।
set Force Safe Frame
অপ্রচলিত। এটি নির্ধারণ করে যে পৃষ্ঠার সমস্ত বিজ্ঞাপন একটি SafeFrame কন্টেইনার ব্যবহার করে রেন্ডার করতে বাধ্য করা হবে কিনা।
set Location
অপ্রচলিত। ওয়েবসাইট থেকে অবস্থানের তথ্য প্রেরণ করে, যাতে আপনি লাইন আইটেমগুলোকে নির্দিষ্ট অবস্থানে জিও-টার্গেট করতে পারেন।
set Privacy Settings
একটি কনফিগ অবজেক্ট ব্যবহার করে একটিমাত্র এপিআই থেকে সকল গোপনীয়তা সেটিংস কনফিগার করার সুযোগ দেয়।
set Publisher Provided Id
প্রকাশক-প্রদত্ত আইডির জন্য মান নির্ধারণ করে।
set Safe Frame Config
অপ্রচলিত। সেফফ্রেম কনফিগারেশনের জন্য পৃষ্ঠা-স্তরের পছন্দসমূহ নির্ধারণ করে।
set Targeting
অপ্রচলিত। একটি নির্দিষ্ট কী-এর জন্য কাস্টম টার্গেটিং প্যারামিটার সেট করে যা পাবলিশার অ্যাডস সার্ভিসের সমস্ত অ্যাড স্লটে প্রযোজ্য হয়।
set Video Content
অপ্রচলিত। টার্গেটিং এবং কন্টেন্ট বর্জনের উদ্দেশ্যে বিজ্ঞাপন অনুরোধের সাথে পাঠানোর জন্য ভিডিও কন্টেন্টের তথ্য নির্ধারণ করে।
update Correlator
বিজ্ঞাপনের অনুরোধের সাথে পাঠানো কোরিলেটরটি পরিবর্তন করে, যার ফলে কার্যকরভাবে একটি নতুন পেজ ভিউ শুরু হয়।

পদ্ধতি


পরিষ্কার

clear ( slots ?: Slot [] ) : boolean
প্রদত্ত স্লটগুলো থেকে বিজ্ঞাপন সরিয়ে সেগুলোর জায়গায় খালি কন্টেন্ট যুক্ত করে। স্লটগুলোকে 'আনফেচড' হিসেবে চিহ্নিত করা হবে।

বিশেষত, একটি স্লট খালি করলে বিজ্ঞাপনটি GPT-এর দীর্ঘস্থায়ী পেজভিউ থেকে মুছে যায়, ফলে ভবিষ্যতের অনুরোধগুলো এই বিজ্ঞাপন-সম্পর্কিত কোনো বাধা বা প্রতিযোগিতামূলক বর্জনের দ্বারা প্রভাবিত হবে না।
উদাহরণ

জাভাস্ক্রিপ্ট

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();

জাভাস্ক্রিপ্ট (পুরানো)

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();

টাইপস্ক্রিপ্ট

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();
প্যারামিটার
Optional slots : Slot [] যে স্লটগুলো খালি করতে হবে তার অ্যারে। অ্যারেটি ঐচ্ছিক; এটি নির্দিষ্ট না করা হলে সমস্ত স্লট খালি হয়ে যাবে।
ফেরত
boolean স্লটগুলি খালি করা হলে true , অন্যথায় false রিটার্ন করে।

clearCategoryExclusions

clearCategoryExclusions ( ) : PubAdsService
পৃষ্ঠা-স্তরের সমস্ত বিজ্ঞাপন বিভাগ বর্জন লেবেল মুছে দেয়। স্লটটি রিফ্রেশ করতে চাইলে এটি কার্যকর।
উদাহরণ

জাভাস্ক্রিপ্ট

// Set category exclusion to exclude ads with 'AirlineAd' labels.
googletag.setConfig({
  categoryExclusion: ["AirlineAd"],
});

// Make ad requests. No ad with 'AirlineAd' label will be returned.

// Clear category exclusions so all ads can be returned.
googletag.setConfig({
  categoryExclusion: null,
});

// Make ad requests. Any ad can be returned.

জাভাস্ক্রিপ্ট (পুরানো)

// Set category exclusion to exclude ads with 'AirlineAd' labels.
googletag.setConfig({
  categoryExclusion: ["AirlineAd"],
});

// Make ad requests. No ad with 'AirlineAd' label will be returned.

// Clear category exclusions so all ads can be returned.
googletag.setConfig({
  categoryExclusion: null,
});

// Make ad requests. Any ad can be returned.

টাইপস্ক্রিপ্ট

// Set category exclusion to exclude ads with 'AirlineAd' labels.
googletag.setConfig({
  categoryExclusion: ["AirlineAd"],
});

// Make ad requests. No ad with 'AirlineAd' label will be returned.

// Clear category exclusions so all ads can be returned.
googletag.setConfig({
  categoryExclusion: null,
});

// Make ad requests. Any ad can be returned.
আরও দেখুন
ফেরত
PubAdsService সার্ভিস অবজেক্টটি, যার উপর মেথডটি কল করা হয়েছিল।

ক্লিয়ারটার্গেটিং

clearTargeting ( key ?: string ) : PubAdsService
একটি নির্দিষ্ট কী অথবা সমস্ত কী-এর জন্য কাস্টম টার্গেটিং প্যারামিটার মুছে ফেলে।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  targeting: {
    interests: "sports",
    colors: "blue",
    fruits: "apple",
  },
});

googletag.setConfig({
  targeting: {
    interests: null,
  },
});
// Targeting 'colors' and 'fruits' are still present, while 'interests'
// was cleared.

googletag.setConfig({
  targeting: null,
});
// All targeting has been cleared.

জাভাস্ক্রিপ্ট (পুরানো)

googletag.setConfig({
  targeting: {
    interests: "sports",
    colors: "blue",
    fruits: "apple",
  },
});

googletag.setConfig({
  targeting: {
    interests: null,
  },
});
// Targeting 'colors' and 'fruits' are still present, while 'interests'
// was cleared.

googletag.setConfig({
  targeting: null,
});
// All targeting has been cleared.

টাইপস্ক্রিপ্ট

googletag.setConfig({
  targeting: {
    interests: "sports",
    colors: "blue",
    fruits: "apple",
  },
});

googletag.setConfig({
  targeting: {
    interests: null,
  },
});
// Targeting 'colors' and 'fruits' are still present, while 'interests'
// was cleared.

googletag.setConfig({
  targeting: null,
});
// All targeting has been cleared.
আরও দেখুন
প্যারামিটার
Optional key : string টার্গেটিং প্যারামিটার কী। কী-টি ঐচ্ছিক; এটি নির্দিষ্ট না করা হলে সমস্ত টার্গেটিং প্যারামিটার মুছে যাবে।
ফেরত
PubAdsService সার্ভিস অবজেক্টটি, যার উপর মেথডটি কল করা হয়েছিল।

collapseEmptyDivs

collapseEmptyDivs ( collapseBeforeAdFetch ?: boolean ) : boolean
যখন প্রদর্শনের জন্য কোনো বিজ্ঞাপন থাকে না, তখন স্লট ডিভগুলোকে সংকুচিত করার সুবিধা দেয়, যাতে সেগুলো পেজে কোনো জায়গা দখল না করে। সার্ভিসটি চালু করার আগে এই মোডটি অবশ্যই সেট করতে হবে।
আরও দেখুন
প্যারামিটার
Optional collapseBeforeAdFetch : boolean বিজ্ঞাপনগুলি আনার আগেই স্লটগুলি সংকুচিত করা হবে কিনা। এই প্যারামিটারটি ঐচ্ছিক; প্রদান করা না হলে, ডিফল্ট মান হিসাবে false ব্যবহৃত হবে।
ফেরত
boolean যদি div কলাপস মোড সক্রিয় করা থাকে তবে true রিটার্ন করে এবং যদি সার্ভিসটি সক্রিয় হওয়ার পরে মেথডটি কল করার কারণে কলাপস মোড সক্রিয় করা অসম্ভব হয় তবে false রিটার্ন করে।

প্রাথমিক লোড নিষ্ক্রিয় করুন

disableInitialLoad ( ) : void
পেজ লোড হওয়ার সময় বিজ্ঞাপনের অনুরোধ নিষ্ক্রিয় করে, কিন্তু PubAdsService.refresh কল ব্যবহার করে বিজ্ঞাপনের অনুরোধ করার সুযোগ দেয়। সার্ভিসটি চালু করার আগে এটি সেট করতে হবে। অবশ্যই অ্যাসিঙ্ক মোড ব্যবহার করতে হবে; অন্যথায় refresh ব্যবহার করে বিজ্ঞাপনের অনুরোধ করা অসম্ভব হবে।
আরও দেখুন

প্রদর্শন

display ( adUnitPath : string , size : GeneralSize , div ?: string | Element , clickUrl ?: string ) : void
প্রদত্ত অ্যাড ইউনিট পাথ ও সাইজ অনুযায়ী একটি অ্যাড স্লট তৈরি করে প্রদর্শন করে।

এই পদ্ধতিটি হলো googletag.defineSlot কল করার ঠিক পরেই googletag.display কল করার একটি সংক্ষিপ্ত সমতুল্য পদ্ধতি।

এই পদ্ধতির আচরণ নির্ভর করে সিঙ্গেল রিকোয়েস্ট আর্কিটেকচার (SRA) সক্রিয় আছে কিনা তার উপর:
  • SRA সক্রিয় করা হয়েছে: এই কলটি করার মুহূর্ত পর্যন্ত সংজ্ঞায়িত সমস্ত বিজ্ঞাপন স্লট একসাথে ব্যাচ করে অনুরোধ করা হবে।
  • SRA নিষ্ক্রিয় (ডিফল্ট): বিজ্ঞাপনের স্লটটির জন্য আলাদাভাবে অনুরোধ করতে হবে।
দ্রষ্টব্য: যখন এই মেথডটি কল করা হয়, তখন বিজ্ঞাপনের অনুরোধ পাঠানো এবং প্রতিক্রিয়া রেন্ডার করার সময় সামঞ্জস্য নিশ্চিত করার জন্য স্লট এবং পেজের অবস্থার একটি স্ন্যাপশট তৈরি করা হয়। এই মেথডটি কল করার পরে স্লট বা পেজের অবস্থায় করা যেকোনো পরিবর্তন (টার্গেটিং, প্রাইভেসি সেটিংস, ফোর্স সেফফ্রেম ইত্যাদি সহ) শুধুমাত্র পরবর্তী display() বা refresh() অনুরোধগুলিতেই প্রযোজ্য হবে।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.pubads().display("/1234567/sports", [728, 90], "div-1");

জাভাস্ক্রিপ্ট (পুরানো)

googletag.pubads().display("/1234567/sports", [728, 90], "div-1");

টাইপস্ক্রিপ্ট

googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
আরও দেখুন
প্যারামিটার
adUnitPath : string যে স্লটটি রেন্ডার করা হবে তার বিজ্ঞাপন ইউনিটের পাথ
size : GeneralSize স্লটটির প্রস্থ ও উচ্চতা।
Optional div : string | Element হয় স্লট ধারণকারী div-টির ID, অথবা div এলিমেন্টটি নিজেই।
Optional clickUrl : string এই স্লটে ব্যবহার করার জন্য ক্লিক ইউআরএল।

enableLazyLoad

enableLazyLoad ( config ?: {
  fetchMarginPercent ?: number ;
  mobileScaling ?: number ;
  renderMarginPercent ?: number ;
} ) : void
কনফিগ অবজেক্ট দ্বারা সংজ্ঞায়িত GPT-তে লেজি লোডিং সক্ষম করে। আরও বিস্তারিত উদাহরণের জন্য, লেজি লোডিং নমুনাটি দেখুন।

দ্রষ্টব্য: SRA-তে লেজি ফেচিং শুধুমাত্র তখনই কাজ করে, যখন সমস্ত স্লট ফেচিং মার্জিনের বাইরে থাকে।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  lazyLoad: {
    // Fetch slots within 5 viewports.
    fetchMarginPercent: 500,
    // Render slots within 2 viewports.
    renderMarginPercent: 200,
    // Double the above values on mobile.
    mobileScaling: 2.0,
  },
});

জাভাস্ক্রিপ্ট (পুরানো)

googletag.setConfig({
  lazyLoad: {
    // Fetch slots within 5 viewports.
    fetchMarginPercent: 500,
    // Render slots within 2 viewports.
    renderMarginPercent: 200,
    // Double the above values on mobile.
    mobileScaling: 2.0,
  },
});

টাইপস্ক্রিপ্ট

googletag.setConfig({
  lazyLoad: {
    // Fetch slots within 5 viewports.
    fetchMarginPercent: 500,
    // Render slots within 2 viewports.
    renderMarginPercent: 200,
    // Double the above values on mobile.
    mobileScaling: 2.0,
  },
});
আরও দেখুন
প্যারামিটার
Optional config : {
  fetchMarginPercent ?: number ;
  mobileScaling ?: number ;
  renderMarginPercent ?: number ;
}
কনফিগারেশন অবজেক্ট লেজি আচরণের কাস্টমাইজেশনের সুযোগ দেয়। কোনো কনফিগারেশন বাদ দেওয়া হলে, Google দ্বারা নির্ধারিত একটি ডিফল্ট ব্যবহৃত হবে যা সময়ের সাথে সাথে পরিমার্জন করা হবে। কোনো নির্দিষ্ট সেটিং, যেমন ফেচিং মার্জিন, নিষ্ক্রিয় করতে এর মান -1 এ সেট করুন।
  • fetchMarginPercent

    বর্তমান ভিউপোর্ট থেকে একটি স্লটের ন্যূনতম দূরত্ব, যা ভিউপোর্টের আকারের শতাংশ হিসাবে প্রকাশ করা হয়, যার পরে আমরা বিজ্ঞাপনটি ফেচ করি। ০ মানের অর্থ হলো "যখন স্লটটি ভিউপোর্টে প্রবেশ করে", ১০০ এর অর্থ হলো "যখন বিজ্ঞাপনটি ১টি ভিউপোর্ট দূরে থাকে", ইত্যাদি।
  • renderMarginPercent

    একটি বিজ্ঞাপন রেন্ডার করার আগে, বর্তমান ভিউপোর্ট থেকে একটি স্লটের ন্যূনতম দূরত্ব কত হওয়া উচিত। এর ফলে বিজ্ঞাপনটি প্রিফেচ করা গেলেও, অন্যান্য সাবরিসোর্স রেন্ডার ও ডাউনলোড করার জন্য অপেক্ষা করা যায়। এই মানটি ভিউপোর্টের শতাংশ হিসাবে fetchMarginPercent মতোই কাজ করে।
  • mobileScaling

    মোবাইল ডিভাইসের মার্জিনে প্রয়োগ করা একটি মাল্টিপ্লায়ার। এর ফলে মোবাইল এবং ডেস্কটপের জন্য মার্জিনে ভিন্নতা আনা যায়। উদাহরণস্বরূপ, ২.০ মানটি মোবাইল ডিভাইসের সমস্ত মার্জিনকে ২ দিয়ে গুণ করবে, যার ফলে ডেটা ফেচ ও রেন্ডার করার আগে একটি স্লটের সর্বনিম্ন দূরত্ব বেড়ে যাবে।

একক অনুরোধ সক্ষম করুন

enableSingleRequest ( ) : boolean
একই সময়ে একাধিক বিজ্ঞাপন আনার জন্য সিঙ্গেল রিকোয়েস্ট মোড চালু করে। এর জন্য সার্ভিসটি চালু করার আগে সমস্ত পাবলিশার অ্যাডস স্লট সংজ্ঞায়িত করে PubAdsService-এ যোগ করতে হবে। সার্ভিসটি চালু করার আগেই সিঙ্গেল রিকোয়েস্ট মোড সেট করতে হবে।
আরও দেখুন
ফেরত
boolean যদি সিঙ্গেল রিকোয়েস্ট মোড সক্রিয় করা থাকে তবে true রিটার্ন করে এবং যদি সার্ভিসটি সক্রিয় করার পরে মেথডটি কল করার কারণে সিঙ্গেল রিকোয়েস্ট মোড সক্রিয় করা অসম্ভব হয় তবে false রিটার্ন করে।

ভিডিও বিজ্ঞাপন সক্ষম করুন

enableVideoAds ( ) : void
পেজটিতে ভিডিও বিজ্ঞাপন থাকবে, এই মর্মে GPT-কে সংকেত দেওয়া হয়। এটি ডিসপ্লে এবং ভিডিও বিজ্ঞাপনের ক্ষেত্রে প্রতিযোগিতামূলক বর্জন সীমাবদ্ধতা সক্ষম করে। যদি ভিডিও কন্টেন্টটি জানা থাকে, তাহলে ডিসপ্লে বিজ্ঞাপনের জন্য কন্টেন্ট বর্জন ব্যবহার করতে PubAdsService.setVideoContent কল করুন।

পেতে

get ( key : string ) : string
প্রদত্ত কী-এর সাথে যুক্ত AdSense অ্যাট্রিবিউটের মান ফেরত দেয়।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
  },
});

const adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes;
const pageUrl = adsenseConfig?.page_url || null;
// Returns 'http://www.example.com'.

জাভাস্ক্রিপ্ট (পুরানো)

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
  },
});

var adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes;
var pageUrl =
  (adsenseConfig === null || adsenseConfig === void 0 ? void 0 : adsenseConfig.page_url) || null;
// Returns 'http://www.example.com'.

টাইপস্ক্রিপ্ট

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
  },
});

const adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes;
const pageUrl = adsenseConfig?.page_url || null;
// Returns 'http://www.example.com'.
আরও দেখুন
প্যারামিটার
key : string যে অ্যাট্রিবিউটটি খুঁজতে হবে তার নাম।
ফেরত
string অ্যাট্রিবিউট কী-এর বর্তমান মান, অথবা কী-টি উপস্থিত না থাকলে null

অ্যাট্রিবিউট কীগুলি পান

getAttributeKeys ( ) : string []
এই সার্ভিসে সেট করা অ্যাট্রিবিউট কীগুলো ফেরত দেয়।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
    document_language: "en",
  },
});

const adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes;
const adsenseAttributes = Object.keys(adsenseConfig || {});
// Returns ['page_url', 'document_language'].

জাভাস্ক্রিপ্ট (পুরানো)

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
    document_language: "en",
  },
});

var adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes;
var adsenseAttributes = Object.keys(adsenseConfig || {});
// Returns ['page_url', 'document_language'].

টাইপস্ক্রিপ্ট

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
    document_language: "en",
  },
});

const adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes;
const adsenseAttributes = Object.keys(adsenseConfig || {});
// Returns ['page_url', 'document_language'].
ফেরত
string [] এই পরিষেবাতে সেট করা অ্যাট্রিবিউট কীগুলির অ্যারে। ক্রম অনির্ধারিত।

টার্গেটিং পান

getTargeting ( key : string ) : string []
সেট করা একটি নির্দিষ্ট কাস্টম সার্ভিস-লেভেল টার্গেটিং প্যারামিটার ফেরত দেয়।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  targeting: {
    interests: "sports",
  },
});

const targetingConfig = googletag.getConfig("targeting").targeting;

// Get targeting for a specific key.
const targeting = targetingConfig?.["interests"] || [];
// Returns ['sports'].

const ageTargeting = targetingConfig?.["age"] || [];
// Returns [] (empty array).

জাভাস্ক্রিপ্ট (পুরানো)

googletag.setConfig({
  targeting: {
    interests: "sports",
  },
});

var targetingConfig = googletag.getConfig("targeting").targeting;

// Get targeting for a specific key.
var targeting =
  (targetingConfig === null || targetingConfig === void 0
    ? void 0
    : targetingConfig["interests"]) || [];
// Returns ['sports'].

var ageTargeting =
  (targetingConfig === null || targetingConfig === void 0 ? void 0 : targetingConfig["age"]) || [];
// Returns [] (empty array).

টাইপস্ক্রিপ্ট

googletag.setConfig({
  targeting: {
    interests: "sports",
  },
});

const targetingConfig = googletag.getConfig("targeting").targeting;

// Get targeting for a specific key.
const targeting = targetingConfig?.["interests"] || [];
// Returns ['sports'].

const ageTargeting = targetingConfig?.["age"] || [];
// Returns [] (empty array).
প্যারামিটার
key : string লক্ষ্য নির্ধারণের মূল চাবিকাঠি যা খুঁজে দেখতে হবে।
ফেরত
string [] এই কী-এর সাথে সংশ্লিষ্ট মানগুলি, অথবা এই ধরনের কোনো কী না থাকলে একটি খালি অ্যারে।

টার্গেটিং কীগুলি পান

getTargetingKeys ( ) : string []
সেট করা সমস্ত কাস্টম সার্ভিস-লেভেল টার্গেটিং কী-গুলির তালিকা ফেরত দেয়।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  targeting: {
    interests: "sports",
    colors: "blue",
  },
});

const targetingConfig = googletag.getConfig("targeting").targeting;
const keys = Object.keys(targetingConfig || {});
// Returns ['interests', 'colors'].

জাভাস্ক্রিপ্ট (পুরানো)

googletag.setConfig({
  targeting: {
    interests: "sports",
    colors: "blue",
  },
});

var targetingConfig = googletag.getConfig("targeting").targeting;
var keys = Object.keys(targetingConfig || {});
// Returns ['interests', 'colors'].

টাইপস্ক্রিপ্ট

googletag.setConfig({
  targeting: {
    interests: "sports",
    colors: "blue",
  },
});

const targetingConfig = googletag.getConfig("targeting").targeting;
const keys = Object.keys(targetingConfig || {});
// Returns ['interests', 'colors'].
ফেরত
string [] টার্গেটিং কী-গুলোর অ্যারে। এদের ক্রম অনির্ধারিত।

প্রাথমিক লোড অক্ষম করা হয়েছে

isInitialLoadDisabled ( ) : boolean
পূর্ববর্তী PubAdsService.disableInitialLoad কলের মাধ্যমে বিজ্ঞাপনের প্রাথমিক অনুরোধগুলি সফলভাবে নিষ্ক্রিয় করা হয়েছে কিনা তা ফেরত দেয়।
ফেরত
boolean পূর্ববর্তী PubAdsService.disableInitialLoad কলটি সফল হলে true , অন্যথায় false রিটার্ন করে।

রিফ্রেশ

refresh ( slots ?: Slot [] , options ?: {
  changeCorrelator : boolean ;
} ) : void
পৃষ্ঠার নির্দিষ্ট বা সমস্ত স্লটের জন্য নতুন বিজ্ঞাপন সংগ্রহ করে প্রদর্শন করে। এটি শুধুমাত্র অ্যাসিঙ্ক্রোনাস রেন্ডারিং মোডে কাজ করে।

সকল ব্রাউজারে সঠিক আচরণের জন্য, refresh কল করার আগে অবশ্যই অ্যাড স্লটটি display করতে হবে। যদি display কলটি বাদ দেওয়া হয়, তাহলে রিফ্রেশ অপ্রত্যাশিতভাবে কাজ করতে পারে। চাইলে, display অ্যাড ফেচ করা থেকে বিরত রাখতে PubAdsService.disableInitialLoad মেথডটি ব্যবহার করা যেতে পারে।

একটি স্লট রিফ্রেশ করলে GPT-এর দীর্ঘস্থায়ী পেজভিউ থেকে পুরানো বিজ্ঞাপনটি মুছে যায়, ফলে ভবিষ্যতের অনুরোধগুলো সেই বিজ্ঞাপন-সম্পর্কিত বাধা বা প্রতিযোগিতামূলক বর্জনের দ্বারা প্রভাবিত হবে না।
উদাহরণ

জাভাস্ক্রিপ্ট

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 });

জাভাস্ক্রিপ্ট (পুরানো)

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 });

টাইপস্ক্রিপ্ট

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 });
আরও দেখুন
প্যারামিটার
Optional slots : Slot [] যে স্লটগুলো রিফ্রেশ করা হবে। অ্যারে ঐচ্ছিক; এটি অনির্দিষ্ট থাকলে সমস্ত স্লট রিফ্রেশ করা হবে।
Optional options : {
  changeCorrelator : boolean ;
}
এই রিফ্রেশ কলের সাথে সংশ্লিষ্ট কনফিগারেশন বিকল্পসমূহ।
  • changeCorrelator

    বিজ্ঞাপন আনার জন্য একটি নতুন কোরিলেটর তৈরি করা হবে কি না, তা নির্দিষ্ট করে। আমাদের বিজ্ঞাপন সার্ভারগুলো এই কোরিলেটর মানটি অল্প সময়ের জন্য (বর্তমানে ৩০ সেকেন্ডের জন্য, তবে এটি পরিবর্তন সাপেক্ষ) বজায় রাখে, যাতে কাছাকাছি সময়ে প্রাপ্ত একই কোরিলেটরযুক্ত অনুরোধগুলোকে একটি একক পেজ ভিউ হিসেবে বিবেচনা করা হয়। ডিফল্টরূপে, প্রতিটি রিফ্রেশের জন্য একটি নতুন কোরিলেটর তৈরি করা হয়।

    দ্রষ্টব্য: এই বিকল্পটি GPT-এর দীর্ঘস্থায়ী পেজভিউ- এর উপর কোনো প্রভাব ফেলে না, যা স্বয়ংক্রিয়ভাবে পৃষ্ঠায় বর্তমানে থাকা বিজ্ঞাপনগুলি প্রদর্শন করে এবং যার কোনো মেয়াদ শেষ হওয়ার সময় নেই।

সেট

set ( key : string , value : string ) : PubAdsService
পাবলিশার অ্যাডস পরিষেবার অধীনে থাকা সমস্ত বিজ্ঞাপন স্লটের জন্য প্রযোজ্য অ্যাডসেন্স অ্যাট্রিবিউটগুলির মান নির্ধারণ করে।

একই কী-এর জন্য এটি একাধিকবার কল করলে, সেই কী-এর জন্য পূর্বে সেট করা মানগুলি ওভাররাইড হয়ে যাবে। display বা refresh কল করার আগে সমস্ত মান অবশ্যই সেট করতে হবে।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
  },
});

জাভাস্ক্রিপ্ট (পুরানো)

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
  },
});

টাইপস্ক্রিপ্ট

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
  },
});
আরও দেখুন
প্যারামিটার
key : string অ্যাট্রিবিউটটির নাম।
value : string বৈশিষ্ট্যের মান।
ফেরত
PubAdsService সার্ভিস অবজেক্টটি, যার উপর মেথডটি কল করা হয়েছিল।

setCategoryExclusion

setCategoryExclusion ( categoryExclusion : string ) : PubAdsService
প্রদত্ত লেবেল নামের জন্য পৃষ্ঠা-স্তরের বিজ্ঞাপন বিভাগ বর্জন নির্ধারণ করে।
উদাহরণ

জাভাস্ক্রিপ্ট

// Label = AirlineAd.
googletag.setConfig({
  categoryExclusion: ["AirlineAd"],
});

জাভাস্ক্রিপ্ট (পুরানো)

// Label = AirlineAd.
googletag.setConfig({
  categoryExclusion: ["AirlineAd"],
});

টাইপস্ক্রিপ্ট

// Label = AirlineAd.
googletag.setConfig({
  categoryExclusion: ["AirlineAd"],
});
আরও দেখুন
প্যারামিটার
categoryExclusion : string বিজ্ঞাপনের বিভাগ বর্জনের লেবেলটি যোগ করতে হবে।
ফেরত
PubAdsService সার্ভিস অবজেক্টটি, যার উপর মেথডটি কল করা হয়েছিল।

সেটসেন্টারিং

setCentering ( centerAds : boolean ) : void
বিজ্ঞাপনের আনুভূমিক কেন্দ্রীকরণ সক্ষম বা অক্ষম করে। ডিফল্টরূপে কেন্দ্রীকরণ অক্ষম থাকে। পুরোনো gpt_mobile.js-এ, কেন্দ্রীকরণ ডিফল্টরূপে সক্ষম থাকে।

display বা refresh কল করার আগে এই মেথডটি কল করা উচিত, কারণ শুধুমাত্র এই মেথডটি কল করার পরে অনুরোধ করা বিজ্ঞাপনগুলোই কেন্দ্রে প্রদর্শিত হবে।
উদাহরণ

জাভাস্ক্রিপ্ট

// Make ads centered.
googletag.setConfig({
  centering: true,
});

জাভাস্ক্রিপ্ট (পুরানো)

// Make ads centered.
googletag.setConfig({
  centering: true,
});

টাইপস্ক্রিপ্ট

// Make ads centered.
googletag.setConfig({
  centering: true,
});
প্যারামিটার
centerAds : boolean বিজ্ঞাপনগুলিকে কেন্দ্রে রাখতে true , বামে রাখতে false

setForceSafeFrame

setForceSafeFrame ( forceSafeFrame : boolean ) : PubAdsService
পৃষ্ঠার সমস্ত বিজ্ঞাপন একটি SafeFrame কন্টেইনার ব্যবহার করে রেন্ডার করতে বাধ্য করা হবে কিনা তা কনফিগার করে।

এই এপিআইটি ব্যবহার করার সময় অনুগ্রহ করে নিম্নলিখিত বিষয়গুলি মনে রাখবেন:
  • এই সেটিংটি শুধুমাত্র সংশ্লিষ্ট স্লটগুলোর জন্য করা পরবর্তী বিজ্ঞাপন অনুরোধগুলোর ক্ষেত্রেই কার্যকর হবে।
  • স্লট লেভেল সেটিং, যদি নির্দিষ্ট করা থাকে, তবে তা সর্বদা পেজ লেভেল সেটিংকে অগ্রাহ্য করবে।
  • যদি এটিকে ' true সেট করা হয় (স্লট-লেভেলে বা পেজ লেভেলে), তাহলে Google Ad Manager UI-তে নেওয়া সিদ্ধান্ত নির্বিশেষে বিজ্ঞাপনটি সর্বদা একটি SafeFrame কন্টেইনার ব্যবহার করে রেন্ডার করা হবে।
  • তবে, যদি এটিকে false সেট করা হয় বা অনির্দিষ্ট রাখা হয়, তাহলে ক্রিয়েটিভের ধরন এবং Google Ad Manager UI-তে করা নির্বাচনের উপর নির্ভর করে বিজ্ঞাপনটি একটি SafeFrame কন্টেইনার ব্যবহার করে রেন্ডার করা হবে।
  • এই এপিআইটি সতর্কতার সাথে ব্যবহার করা উচিত, কারণ এটি এমন ক্রিয়েটিভগুলোর আচরণকে প্রভাবিত করতে পারে যেগুলো তাদের আইফ্রেম (iFrame) থেকে বেরিয়ে আসার চেষ্টা করে অথবা সরাসরি পাবলিশারের পেজে রেন্ডার হওয়ার উপর নির্ভর করে।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  safeFrame: {
    forceSafeFrame: true,
  },
});

// The following slot will be opted-out of the page-level force
// SafeFrame instruction.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setConfig({
    safeFrame: {
      forceSafeFrame: 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");

জাভাস্ক্রিপ্ট (পুরানো)

googletag.setConfig({
  safeFrame: {
    forceSafeFrame: true,
  },
});

// The following slot will be opted-out of the page-level force
// SafeFrame instruction.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setConfig({
    safeFrame: {
      forceSafeFrame: 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");

টাইপস্ক্রিপ্ট

googletag.setConfig({
  safeFrame: {
    forceSafeFrame: true,
  },
});

// The following slot will be opted-out of the page-level force
// SafeFrame instruction.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")!
  .setConfig({
    safeFrame: {
      forceSafeFrame: 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 এবং পূর্ববর্তী সেটিংটি 'false'-এ পরিবর্তন করতে ' false সেট করুন। আগে অনির্দিষ্ট থাকলে এটিকে false সেট করলে কোনো পরিবর্তন হবে না।
ফেরত
PubAdsService সার্ভিস অবজেক্টটি, যার উপর মেথডটি কল করা হয়েছিল।

অবস্থান নির্ধারণ করুন

setLocation ( address : string ) : PubAdsService
ওয়েবসাইট থেকে অবস্থানের তথ্য প্রেরণ করে, যাতে আপনি নির্দিষ্ট স্থানে আইটেমগুলোকে জিও-টার্গেট করতে পারেন।
উদাহরণ

জাভাস্ক্রিপ্ট

// Postal code:
googletag.setConfig({
  location: "10001,US",
});

জাভাস্ক্রিপ্ট (পুরানো)

// Postal code:
googletag.setConfig({
  location: "10001,US",
});

টাইপস্ক্রিপ্ট

// Postal code:
googletag.setConfig({
  location: "10001,US",
});
প্যারামিটার
address : string মুক্ত শৈলীর ঠিকানা।
ফেরত
PubAdsService সার্ভিস অবজেক্টটি, যার উপর মেথডটি কল করা হয়েছিল।

গোপনীয়তা সেটিংস সেট করুন

setPrivacySettings ( privacySettings : PrivacySettingsConfig ) : PubAdsService
একটি কনফিগ অবজেক্ট ব্যবহার করে একটিমাত্র এপিআই থেকে সকল গোপনীয়তা সেটিংস কনফিগার করার সুযোগ দেয়।
উদাহরণ

জাভাস্ক্রিপ্ট

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,
});

জাভাস্ক্রিপ্ট (পুরানো)

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,
});

টাইপস্ক্রিপ্ট

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 ( ppid : string ) : PubAdsService
প্রকাশক-প্রদত্ত আইডির জন্য মান নির্ধারণ করে।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");

জাভাস্ক্রিপ্ট (পুরানো)

googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");

টাইপস্ক্রিপ্ট

googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
আরও দেখুন
প্যারামিটার
ppid : string প্রকাশক কর্তৃক প্রদত্ত একটি আলফানিউমেরিক আইডি। এটি অবশ্যই ৩২ থেকে ১৫০ অক্ষরের মধ্যে হতে হবে।
ফেরত
PubAdsService সার্ভিস অবজেক্টটি, যার উপর মেথডটি কল করা হয়েছিল।

setSafeFrameConfig

setSafeFrameConfig ( config : SafeFrameConfig ) : PubAdsService
SafeFrame কনফিগারেশনের জন্য পৃষ্ঠা-স্তরের পছন্দসমূহ নির্ধারণ করে। কনফিগারেশন অবজেক্টে থাকা যেকোনো অপরিচিত কী উপেক্ষা করা হবে। কোনো স্বীকৃত কী-এর জন্য অবৈধ মান দেওয়া হলে সম্পূর্ণ কনফিগারেশনটি উপেক্ষা করা হবে।

যদি নির্দিষ্ট করা থাকে, তবে এই পৃষ্ঠা-স্তরের পছন্দগুলি স্লট-স্তরের পছন্দ দ্বারা বাতিল হয়ে যাবে।
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  safeFrame: {
    forceSafeFrame: true,
    allowOverlayExpansion: true,
    allowPushExpansion: true,
    sandbox: true,
  },
});

googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setConfig({
    safeFrame: {
      allowOverlayExpansion: false,
    },
  })
  .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");

জাভাস্ক্রিপ্ট (পুরানো)

googletag.setConfig({
  safeFrame: {
    forceSafeFrame: true,
    allowOverlayExpansion: true,
    allowPushExpansion: true,
    sandbox: true,
  },
});

googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setConfig({
    safeFrame: {
      allowOverlayExpansion: false,
    },
  })
  .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");

টাইপস্ক্রিপ্ট

googletag.setConfig({
  safeFrame: {
    forceSafeFrame: true,
    allowOverlayExpansion: true,
    allowPushExpansion: true,
    sandbox: true,
  },
});

googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")!
  .setConfig({
    safeFrame: {
      allowOverlayExpansion: false,
    },
  })
  .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 ( key : string , value : string | string [] ) : PubAdsService
একটি নির্দিষ্ট কী-এর জন্য কাস্টম টার্গেটিং প্যারামিটার সেট করে, যা পাবলিশার অ্যাডস সার্ভিসের সমস্ত অ্যাড স্লটে প্রযোজ্য হয়। একই কী-এর জন্য এটি একাধিকবার কল করলে পুরোনো মানগুলো ওভাররাইট হয়ে যাবে। এই কী-গুলো আপনার গুগল অ্যাড ম্যানেজার অ্যাকাউন্টে সংজ্ঞায়িত করা থাকে।
উদাহরণ

জাভাস্ক্রিপ্ট

// Example with a single value for a key.
googletag.setConfig({
  targeting: {
    interests: "sports",
  },
});

// Example with multiple values for a key inside in an array.
googletag.setConfig({
  targeting: {
    interests: ["sports", "music"],
  },
});

জাভাস্ক্রিপ্ট (পুরানো)

// Example with a single value for a key.
googletag.setConfig({
  targeting: {
    interests: "sports",
  },
});

// Example with multiple values for a key inside in an array.
googletag.setConfig({
  targeting: {
    interests: ["sports", "music"],
  },
});

টাইপস্ক্রিপ্ট

// Example with a single value for a key.
googletag.setConfig({
  targeting: {
    interests: "sports",
  },
});

// Example with multiple values for a key inside in an array.
googletag.setConfig({
  targeting: {
    interests: ["sports", "music"],
  },
});
আরও দেখুন
প্যারামিটার
key : string টার্গেটিং প্যারামিটার কী।
value : string | string [] প্যারামিটার মান বা মানসমূহের অ্যারে লক্ষ্য করা।
ফেরত
PubAdsService সার্ভিস অবজেক্টটি, যার উপর মেথডটি কল করা হয়েছিল।

ভিডিও কন্টেন্ট সেট করুন

setVideoContent ( videoContentId : string , videoCmsId : string ) : void
টার্গেটিং এবং কন্টেন্ট বর্জনের উদ্দেশ্যে বিজ্ঞাপন অনুরোধের সাথে পাঠানোর জন্য ভিডিও কন্টেন্টের তথ্য নির্ধারণ করে। এই মেথডটি কল করা হলে ভিডিও বিজ্ঞাপন স্বয়ংক্রিয়ভাবে চালু হয়ে যাবে। videoContentId এবং videoCmsId এর জন্য, Google Ad Manager কন্টেন্ট ইনজেশন সার্ভিসে দেওয়া মানগুলো ব্যবহার করুন।
আরও দেখুন
প্যারামিটার
videoContentId : string ভিডিও কন্টেন্ট আইডি।
videoCmsId : string ভিডিও সিএমএস আইডি।

আপডেটকোরিলেটর

updateCorrelator ( ) : PubAdsService
বিজ্ঞাপনের অনুরোধের সাথে পাঠানো কোরিলেটর পরিবর্তন করে, যা কার্যকরভাবে একটি নতুন পেজ ভিউ শুরু করে। একটি পেজ ভিউ থেকে আসা সমস্ত বিজ্ঞাপনের অনুরোধের জন্য কোরিলেটরটি একই থাকে, এবং বিভিন্ন পেজ ভিউয়ের ক্ষেত্রে এটি স্বতন্ত্র হয়। এটি শুধুমাত্র অ্যাসিঙ্ক মোডের জন্য প্রযোজ্য।

Note: this has no effect on GPT's long-lived pageview , which automatically reflects the ads actually on the page and has no expiration time.
উদাহরণ

জাভাস্ক্রিপ্ট

// Assume that the correlator is currently 12345. All ad requests made
// by this page will currently use that value.

// Replace the current correlator with a new correlator.
googletag.pubads().updateCorrelator();

// The correlator will now be a new randomly selected value, different
// from 12345. All subsequent ad requests made by this page will use
// the new value.

JavaScript (legacy)

// Assume that the correlator is currently 12345. All ad requests made
// by this page will currently use that value.

// Replace the current correlator with a new correlator.
googletag.pubads().updateCorrelator();

// The correlator will now be a new randomly selected value, different
// from 12345. All subsequent ad requests made by this page will use
// the new value.

টাইপস্ক্রিপ্ট

// 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 The service object on which the function was called.

googletag.ResponseInformation

An object representing a single ad response.
বৈশিষ্ট্য
advertiser Id
The ID of the advertiser.
campaign Id
The ID of the campaign.
creative Id
The ID of the creative.
creative Template Id
The template ID of the ad.
line Item Id
The ID of the line item.
আরও দেখুন

বৈশিষ্ট্য


advertiserId

advertiserId : number
The ID of the advertiser.

campaignId

campaignId : number
The ID of the campaign.

creativeId

creativeId : number
The ID of the creative.

creativeTemplateId

creativeTemplateId : number
The template ID of the ad.

lineItemId

lineItemId : number
The ID of the line item.

googletag.RewardedPayload

An object representing the reward associated with a rewarded ad
বৈশিষ্ট্য
amount
The number of items included in the reward.
type
The type of item included in the reward (for example, "coin").
আরও দেখুন

বৈশিষ্ট্য


পরিমাণ

amount : number
The number of items included in the reward.

প্রকার

type : string
The type of item included in the reward (for example, "coin").

googletag.Service

Base service class that contains methods common for all services.
পদ্ধতি
add Event Listener
Registers a listener that allows you to set up and call a JavaScript function when a specific GPT event happens on the page.
get Slots
Get the list of slots associated with this service.
remove Event Listener
Removes a previously registered listener.

পদ্ধতি


addEventListener

addEventListener < K extends keyof EventTypeMap > ( eventType : K , listener : ( ( arg : EventTypeMap [ K ] ) => void ) ) : Service
Registers a listener that allows you to set up and call a JavaScript function when a specific GPT event happens on the page. The following events are supported: An object of the appropriate event type is passed to the listener when it is called.
উদাহরণ

জাভাস্ক্রিপ্ট

// 1. Adding an event listener for the PubAdsService.
googletag.pubads().addEventListener("slotOnload", (event) => {
  console.log("Slot has been loaded:");
  console.log(event);
});

// 2. Adding an event listener with slot specific logic.
// Listeners operate at service level, which means that you cannot add
// a listener for an event for a specific slot only. You can, however,
// programmatically filter a listener to respond only to a certain ad
// slot, using this pattern:
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", (event) => {
  if (event.slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// 1. Adding an event listener for the PubAdsService.
googletag.pubads().addEventListener("slotOnload", function (event) {
  console.log("Slot has been loaded:");
  console.log(event);
});

// 2. Adding an event listener with slot specific logic.
// Listeners operate at service level, which means that you cannot add
// a listener for an event for a specific slot only. You can, however,
// programmatically filter a listener to respond only to a certain ad
// slot, using this pattern:
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", function (event) {
  if (event.slot === targetSlot) {
    // Slot specific logic.
  }
});

টাইপস্ক্রিপ্ট

// 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 A string representing the type of event generated by GPT. Event types are case sensitive.
listener : ( ( arg : EventTypeMap [ K ] ) => void ) Function that takes a single event object argument.
ফেরত
Service The service object on which the method was called.

getSlots

getSlots ( ) : Slot []
Get the list of slots associated with this service.
ফেরত
Slot [] Slots in the order in which they were added to the service.

removeEventListener

removeEventListener < K extends keyof EventTypeMap > ( eventType : K , listener : ( ( event : EventTypeMap [ K ] ) => void ) ) : void
Removes a previously registered listener.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.cmd.push(() => {
  // Define a new ad slot.
  googletag.defineSlot("/6355419/Travel", [728, 90], "div-for-slot").addService(googletag.pubads());

  // Define a new function that removes itself via removeEventListener
  // after the impressionViewable event fires.
  const onViewableListener = (event) => {
    googletag.pubads().removeEventListener("impressionViewable", onViewableListener);
    setTimeout(() => {
      googletag.pubads().refresh([event.slot]);
    }, 30000);
  };

  // Add onViewableListener as a listener for impressionViewable events.
  googletag.pubads().addEventListener("impressionViewable", onViewableListener);
  googletag.enableServices();
});

JavaScript (legacy)

googletag.cmd.push(function () {
  // Define a new ad slot.
  googletag.defineSlot("/6355419/Travel", [728, 90], "div-for-slot").addService(googletag.pubads());

  // Define a new function that removes itself via removeEventListener
  // after the impressionViewable event fires.
  var onViewableListener = function (event) {
    googletag.pubads().removeEventListener("impressionViewable", onViewableListener);
    setTimeout(function () {
      googletag.pubads().refresh([event.slot]);
    }, 30000);
  };

  // Add onViewableListener as a listener for impressionViewable events.
  googletag.pubads().addEventListener("impressionViewable", onViewableListener);
  googletag.enableServices();
});

টাইপস্ক্রিপ্ট

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 A string representing the type of event generated by GPT. Event types are case sensitive.
listener : ( ( event : EventTypeMap [ K ] ) => void ) Function that takes a single event object argument.

googletag.SizeMappingBuilder

Builder for size mapping specification objects. This builder is provided to help easily construct size specifications.
পদ্ধতি
add Size
Adds a mapping from a single-size array (representing the viewport) to a single- or multi-size array representing the slot.
build
Builds a size map specification from the mappings added to this builder.
আরও দেখুন

পদ্ধতি


addSize

addSize ( viewportSize : SingleSizeArray , slotSize : GeneralSize ) : SizeMappingBuilder
Adds a mapping from a single-size array (representing the viewport) to a single- or multi-size array representing the slot.
উদাহরণ

জাভাস্ক্রিপ্ট

// 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 &lt; 640x480
  .build();

// Mapping 2
googletag
  .sizeMapping()
  .addSize([1024, 768], [970, 250])
  .addSize([980, 690], [])
  .addSize([640, 480], [120, 60])
  .addSize([0, 0], [])
  .build();

// Mapping 2 will not show any ads for the following viewport sizes:
// [1024, 768] > size >= [980, 690] and
// [640, 480] > size >= [0, 0]

JavaScript (legacy)

// Mapping 1
googletag
  .sizeMapping()
  .addSize([1024, 768], [970, 250])
  .addSize([980, 690], [728, 90])
  .addSize([640, 480], "fluid")
  .addSize([0, 0], [88, 31]) // All viewports &lt; 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]

টাইপস্ক্রিপ্ট

// 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 &lt; 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 The size of the viewport for this mapping entry.
slotSize : GeneralSize The sizes of the slot for this mapping entry.
ফেরত
SizeMappingBuilder A reference to this builder.

নির্মাণ করুন

build ( ) : SizeMappingArray
Builds a size map specification from the mappings added to this builder.

If any invalid mappings have been supplied, this method will return null . Otherwise it returns a specification in the correct format to pass to Slot.defineSizeMapping .

Note: the behavior of the builder after calling this method is undefined.
ফেরত
SizeMappingArray The result built by this builder. Can be null if invalid size mappings were supplied.

googletag.Slot

Slot is an object representing a single ad slot on a page.
পদ্ধতি
add Service
Adds a Service to this slot.
clear Category Exclusions
Deprecated. Clears all slot-level ad category exclusion labels for this slot.
clear Targeting
Deprecated. Clears specific or all custom slot-level targeting parameters for this slot.
define Size Mapping
Sets an array of mappings from a minimum viewport size to slot size for this slot.
get
Deprecated. Returns the value for the AdSense attribute associated with the given key for this slot.
get Ad Unit Path
Returns the full path of the ad unit, with the network code and ad unit path.
get Attribute Keys
Deprecated. Returns the list of attribute keys set on this slot.
get Category Exclusions
Deprecated. Returns the ad category exclusion labels for this slot.
get Config
Gets a frozen copy of the general configuration options for the slot set by setConfig .
get Response Information
Returns the ad response information.
get Slot Element Id
Returns the ID of the slot div provided when the slot was defined.
get Targeting
Deprecated. Returns a specific custom targeting parameter set on this slot.
get Targeting Keys
Deprecated. Returns the list of all custom targeting keys set on this slot.
set
Deprecated. Sets a value for an AdSense attribute on this ad slot.
set Category Exclusion
Deprecated. Sets a slot-level ad category exclusion label on this slot.
set Click Url
Deprecated. Sets the click URL to which users will be redirected after clicking on the ad.
set Collapse Empty Div
Deprecated. Sets whether the slot div should be hidden when there is no ad in the slot.
set Config
Sets general configuration options for this slot.
set Force Safe Frame
Deprecated. Configures whether ads in this slot should be forced to be rendered using a SafeFrame container.
set Safe Frame Config
Deprecated. Sets the slot-level preferences for SafeFrame configuration.
set Targeting
Deprecated. Sets a custom targeting parameter for this slot.
update Targeting From Map
Deprecated. Sets custom targeting parameters for this slot, from a key:value map in a JSON object.

পদ্ধতি


addService

addService ( service : Service ) : Slot
Adds a Service to this slot.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());

JavaScript (legacy)

googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());

টাইপস্ক্রিপ্ট

googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
আরও দেখুন
প্যারামিটার
service : Service The service to be added.
ফেরত
Slot The slot object on which the method was called.

clearCategoryExclusions

clearCategoryExclusions ( ) : Slot
Clears all slot-level ad category exclusion labels for this slot.
উদাহরণ

জাভাস্ক্রিপ্ট

// Set category exclusion to exclude ads with 'AirlineAd' labels.
const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    categoryExclusion: ["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.setConfig({
  categoryExclusion: null,
});

// Make an ad request. Any ad can be returned for the slot.

JavaScript (legacy)

// Set category exclusion to exclude ads with 'AirlineAd' labels.
var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    categoryExclusion: ["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.setConfig({
  categoryExclusion: null,
});

// Make an ad request. Any ad can be returned for the slot.

টাইপস্ক্রিপ্ট

// Set category exclusion to exclude ads with 'AirlineAd' labels.
const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    categoryExclusion: ["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.setConfig({
  categoryExclusion: null,
});

// Make an ad request. Any ad can be returned for the slot.
ফেরত
Slot The slot object on which the method was called.

clearTargeting

clearTargeting ( key ?: string ) : Slot
Clears specific or all custom slot-level targeting parameters for this slot.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    targeting: {
      allow_expandable: "true",
      interests: ["sports", "music"],
      color: "red",
    },
  })
  .addService(googletag.pubads());

slot.setConfig({
  targeting: {
    color: null,
  },
});
// Targeting 'allow_expandable' and 'interests' are still present,
// while 'color' was cleared.

slot.setConfig({
  targeting: null,
});
// All targeting has been cleared.

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    targeting: {
      allow_expandable: "true",
      interests: ["sports", "music"],
      color: "red",
    },
  })
  .addService(googletag.pubads());

slot.setConfig({
  targeting: {
    color: null,
  },
});
// Targeting 'allow_expandable' and 'interests' are still present,
// while 'color' was cleared.

slot.setConfig({
  targeting: null,
});
// All targeting has been cleared.

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    targeting: {
      allow_expandable: "true",
      interests: ["sports", "music"],
      color: "red",
    },
  })
  .addService(googletag.pubads());

slot.setConfig({
  targeting: {
    color: null,
  },
});
// Targeting 'allow_expandable' and 'interests' are still present,
// while 'color' was cleared.

slot.setConfig({
  targeting: null,
});
// All targeting has been cleared.
আরও দেখুন
প্যারামিটার
Optional key : string Targeting parameter key. The key is optional; all targeting parameters will be cleared if it is unspecified.
ফেরত
Slot The slot object on which the method was called.

defineSizeMapping

defineSizeMapping ( sizeMapping : SizeMappingArray ) : Slot
Sets an array of mappings from a minimum viewport size to slot size for this slot.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

const mapping = googletag
  .sizeMapping()
  .addSize([100, 100], [88, 31])
  .addSize(
    [320, 400],
    [
      [320, 50],
      [300, 50],
    ],
  )
  .build();

slot.defineSizeMapping(mapping);

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

var mapping = googletag
  .sizeMapping()
  .addSize([100, 100], [88, 31])
  .addSize(
    [320, 400],
    [
      [320, 50],
      [300, 50],
    ],
  )
  .build();

slot.defineSizeMapping(mapping);

টাইপস্ক্রিপ্ট

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 Array of size mappings. You can use SizeMappingBuilder to create it. Each size mapping is an array of two elements: SingleSizeArray and GeneralSize .
ফেরত
Slot The slot object on which the method was called.

পেতে

get ( key : string ) : string
Returns the value for the AdSense attribute associated with the given key for this slot. To see service-level attributes inherited by this slot, use PubAdsService.get .
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
    },
  })
  .addService(googletag.pubads());

const adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes;
const pageUrl = adsenseConfig?.page_url || null;
// Returns 'http://www.example.com'.

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
    },
  })
  .addService(googletag.pubads());

var adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes;
var pageUrl =
  (adsenseConfig === null || adsenseConfig === void 0 ? void 0 : adsenseConfig.page_url) || null;
// Returns 'http://www.example.com'.

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
    },
  })
  .addService(googletag.pubads());

const adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes;
const pageUrl = adsenseConfig?.page_url || null;
// Returns 'http://www.example.com'.
আরও দেখুন
প্যারামিটার
key : string Name of the attribute to look for.
ফেরত
string Current value for the attribute key, or null if the key is not present.

getAdUnitPath

getAdUnitPath ( ) : string
Returns the full path of the ad unit, with the network code and ad unit path.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

slot.getAdUnitPath();
// Returns '/1234567/sports'.

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

slot.getAdUnitPath();
// Returns '/1234567/sports'.

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

slot.getAdUnitPath();
// Returns '/1234567/sports'.
ফেরত
string Ad unit path.

getAttributeKeys

getAttributeKeys ( ) : string []
Returns the list of attribute keys set on this slot. To see the keys of service-level attributes inherited by this slot, use PubAdsService.getAttributeKeys .
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
      document_language: "en",
    },
  })
  .addService(googletag.pubads());

const adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes;
const adsenseAttributes = Object.keys(adsenseConfig || {});
// Returns ['page_url', 'document_language'].

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
      document_language: "en",
    },
  })
  .addService(googletag.pubads());

var adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes;
var adsenseAttributes = Object.keys(adsenseConfig || {});
// Returns ['page_url', 'document_language'].

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
      document_language: "en",
    },
  })
  .addService(googletag.pubads());

const adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes;
const adsenseAttributes = Object.keys(adsenseConfig || {});
// Returns ['page_url', 'document_language'].
ফেরত
string [] Array of attribute keys. Ordering is undefined.

getCategoryExclusions

getCategoryExclusions ( ) : string []
Returns the ad category exclusion labels for this slot.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    categoryExclusion: ["AirlineAd", "TrainAd"],
  })
  .addService(googletag.pubads());

const exclusions = slot.getConfig("categoryExclusion")?.categoryExclusion || [];
// Returns ['AirlineAd', 'TrainAd'].

JavaScript (legacy)

var _a;
var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    categoryExclusion: ["AirlineAd", "TrainAd"],
  })
  .addService(googletag.pubads());

var exclusions =
  ((_a = slot.getConfig("categoryExclusion")) === null || _a === void 0
    ? void 0
    : _a.categoryExclusion) || [];
// Returns ['AirlineAd', 'TrainAd'].

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    categoryExclusion: ["AirlineAd", "TrainAd"],
  })
  .addService(googletag.pubads());

const exclusions = slot.getConfig("categoryExclusion")?.categoryExclusion || [];
// Returns ['AirlineAd', 'TrainAd'].
ফেরত
string [] The ad category exclusion labels for this slot, or an empty array if none have been set.

getConfig

getConfig ( keys : string | string [] ) : Readonly < Pick < SlotSettingsConfig , "adsenseAttributes" | "targeting" | "categoryExclusion" > >
Gets a frozen copy of the general configuration options for the slot set by setConfig .

Not all setConfig() properties are supported by this method. Supported properties are:
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div");

// Get the value of the `targeting` setting.
const targetingConfig = slot.getConfig("targeting");

// Get the value of the `adsenseAttributes` and `categoryExclusion` settings.
const config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);

JavaScript (legacy)

var slot = googletag.defineSlot("/1234567/sports", [160, 600], "div");

// Get the value of the `targeting` setting.
var targetingConfig = slot.getConfig("targeting");

// Get the value of the `adsenseAttributes` and `categoryExclusion` settings.
var config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);

টাইপস্ক্রিপ্ট

const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!;

// Get the value of the `targeting` setting.
const targetingConfig = slot.getConfig("targeting");

// Get the value of the `adsenseAttributes` and `categoryExclusion` settings.
const config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
প্যারামিটার
keys : string | string [] The keys of the configuration options to get.
ফেরত
Readonly < Pick < SlotSettingsConfig , "adsenseAttributes" | "targeting" | "categoryExclusion" > > A frozen copy of the configuration options for the slot.

getResponseInformation

getResponseInformation ( ) : ResponseInformation
Returns the ad response information. This is based on the last ad response for the slot. If this is called when the slot has no ad, null will be returned.
ফেরত
ResponseInformation The latest ad response information, or null if the slot has no ad.

getSlotElementId

getSlotElementId ( ) : string
Returns the ID of the slot div provided when the slot was defined.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

slot.getSlotElementId();
// Returns 'div'.

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

slot.getSlotElementId();
// Returns 'div'.

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

slot.getSlotElementId();
// Returns 'div'.
ফেরত
string Slot div ID.

getTargeting

getTargeting ( key : string ) : string []
Returns a specific custom targeting parameter set on this slot. Service-level targeting parameters are not included.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    targeting: {
      allow_expandable: "true",
    },
  })
  .addService(googletag.pubads());

const targetingConfig = slot.getConfig("targeting").targeting;

// Get targeting for a specific key.
const targeting = targetingConfig?.["allow_expandable"] || [];
// Returns ['true'].

const ageTargeting = targetingConfig?.["age"] || [];
// Returns [] (empty array).

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    targeting: {
      allow_expandable: "true",
    },
  })
  .addService(googletag.pubads());

var targetingConfig = slot.getConfig("targeting").targeting;

// Get targeting for a specific key.
var targeting =
  (targetingConfig === null || targetingConfig === void 0
    ? void 0
    : targetingConfig["allow_expandable"]) || [];
// Returns ['true'].

var ageTargeting =
  (targetingConfig === null || targetingConfig === void 0 ? void 0 : targetingConfig["age"]) || [];
// Returns [] (empty array).

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    targeting: {
      allow_expandable: "true",
    },
  })
  .addService(googletag.pubads());

const targetingConfig = slot.getConfig("targeting").targeting;

// Get targeting for a specific key.
const targeting = targetingConfig?.["allow_expandable"] || [];
// Returns ['true'].

const ageTargeting = targetingConfig?.["age"] || [];
// Returns [] (empty array).
প্যারামিটার
key : string The targeting key to look for.
ফেরত
string [] The values associated with this key, or an empty array if there is no such key.

getTargetingKeys

getTargetingKeys ( ) : string []
Returns the list of all custom targeting keys set on this slot. Service-level targeting keys are not included.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    targeting: {
      allow_expandable: "true",
      interests: ["sports", "music"],
    },
  })
  .addService(googletag.pubads());

const targetingConfig = slot.getConfig("targeting").targeting;
const keys = Object.keys(targetingConfig || {});
// Returns ['interests', 'allow_expandable'].

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    targeting: {
      allow_expandable: "true",
      interests: ["sports", "music"],
    },
  })
  .addService(googletag.pubads());

var targetingConfig = slot.getConfig("targeting").targeting;
var keys = Object.keys(targetingConfig || {});
// Returns ['interests', 'allow_expandable'].

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    targeting: {
      allow_expandable: "true",
      interests: ["sports", "music"],
    },
  })
  .addService(googletag.pubads());

const targetingConfig = slot.getConfig("targeting").targeting;
const keys = Object.keys(targetingConfig || {});
// Returns ['interests', 'allow_expandable'].
ফেরত
string [] Array of targeting keys. Ordering is undefined.

সেট

set ( key : string , value : string ) : Slot
Sets a value for an AdSense attribute on this ad slot. This will override any values set at the service level for this key.

Calling this method more than once for the same key will override previously set values for that key. All values must be set before calling display or refresh .
উদাহরণ

জাভাস্ক্রিপ্ট

// Setting an attribute on a single ad slot.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
    },
  })
  .addService(googletag.pubads());

JavaScript (legacy)

// Setting an attribute on a single ad slot.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
    },
  })
  .addService(googletag.pubads());

টাইপস্ক্রিপ্ট

// Setting an attribute on a single ad slot.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
    },
  })
  .addService(googletag.pubads());
আরও দেখুন
প্যারামিটার
key : string The name of the attribute.
value : string Attribute value.
ফেরত
Slot The slot object on which the method was called.

setCategoryExclusion

setCategoryExclusion ( categoryExclusion : string ) : Slot
Sets a slot-level ad category exclusion label on this slot.
উদাহরণ

জাভাস্ক্রিপ্ট

// Label = AirlineAd.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    categoryExclusion: ["AirlineAd"],
  })
  .addService(googletag.pubads());

JavaScript (legacy)

// Label = AirlineAd.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    categoryExclusion: ["AirlineAd"],
  })
  .addService(googletag.pubads());

টাইপস্ক্রিপ্ট

// Label = AirlineAd.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    categoryExclusion: ["AirlineAd"],
  })
  .addService(googletag.pubads());
আরও দেখুন
প্যারামিটার
categoryExclusion : string The ad category exclusion label to add.
ফেরত
Slot The slot object on which the method was called.

setClickUrl

setClickUrl ( value : string ) : Slot
Sets the click URL to which users will be redirected after clicking on the ad.

The Google Ad Manager servers still record a click even if the click URL is replaced. Any landing page URL associated with the creative that is served is appended to the provided value. Subsequent calls overwrite the value. This works only for non-SRA requests.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    clickUrl: "http://www.example.com?original_click_url=",
  })
  .addService(googletag.pubads());

JavaScript (legacy)

googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    clickUrl: "http://www.example.com?original_click_url=",
  })
  .addService(googletag.pubads());

টাইপস্ক্রিপ্ট

googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    clickUrl: "http://www.example.com?original_click_url=",
  })
  .addService(googletag.pubads());
প্যারামিটার
value : string The click URL to set.
ফেরত
Slot The slot object on which the method was called.

setCollapseEmptyDiv

setCollapseEmptyDiv ( collapse : boolean , collapseBeforeAdFetch ?: boolean ) : Slot
Sets whether the slot div should be hidden when there is no ad in the slot. This overrides the service-level settings.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot1 = googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setConfig({
    collapseDiv: "BEFORE_FETCH",
  })
  .addService(googletag.pubads());
// The above will cause the div for this slot to be collapsed
// when the page is loaded, before ads are requested.

const slot2 = googletag
  .defineSlot("/1234567/sports", [160, 600], "div-2")
  .setConfig({
    collapseDiv: "ON_NO_FILL",
  })
  .addService(googletag.pubads());
// The above will cause the div for this slot to be collapsed
// only after GPT detects that no ads are available for the slot.

JavaScript (legacy)

var slot1 = googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setConfig({
    collapseDiv: "BEFORE_FETCH",
  })
  .addService(googletag.pubads());
// The above will cause the div for this slot to be collapsed
// when the page is loaded, before ads are requested.

var slot2 = googletag
  .defineSlot("/1234567/sports", [160, 600], "div-2")
  .setConfig({
    collapseDiv: "ON_NO_FILL",
  })
  .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.

টাইপস্ক্রিপ্ট

const slot1 = googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")!
  .setConfig({
    collapseDiv: "BEFORE_FETCH",
  })
  .addService(googletag.pubads());
// The above will cause the div for this slot to be collapsed
// when the page is loaded, before ads are requested.

const slot2 = googletag
  .defineSlot("/1234567/sports", [160, 600], "div-2")!
  .setConfig({
    collapseDiv: "ON_NO_FILL",
  })
  .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 Whether to collapse the slot if no ad is returned.
Optional collapseBeforeAdFetch : boolean Whether to collapse the slot even before an ad is fetched. Ignored if collapse is not true .
ফেরত
Slot The slot object on which the method was called.

setConfig

setConfig ( slotConfig : SlotSettingsConfig ) : Slot
Sets general configuration options for this slot.
প্যারামিটার
slotConfig : SlotSettingsConfig The configuration object.
ফেরত
Slot The slot object on which the method was called.

setForceSafeFrame

setForceSafeFrame ( forceSafeFrame : boolean ) : Slot
Configures whether ads in this slot should be forced to be rendered using a SafeFrame container.

Please keep the following things in mind while using this API:
  • This setting will only take effect for subsequent ad requests made for the respective slots.
  • The slot level setting, if specified, will always override the page level setting.
  • If set to true (at slot-level or page level), the ad will always be rendered using a SafeFrame container independent of the choice made in the Google Ad Manager UI.
  • However, if set to false or left unspecified, the ad will be rendered using a SafeFrame container depending on the type of creative and the selection made in the Google Ad Manager UI.
  • This API should be used with caution as it could impact the behaviour of creatives that attempt to break out of their iFrames or rely on them being rendered directly in a publishers page.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setForceSafeFrame(true)
  .addService(googletag.pubads());

JavaScript (legacy)

googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setForceSafeFrame(true)
  .addService(googletag.pubads());

টাইপস্ক্রিপ্ট

googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setForceSafeFrame(true)
  .addService(googletag.pubads());
আরও দেখুন
প্যারামিটার
forceSafeFrame : boolean true to force all ads in this slot to be rendered in SafeFrames and false to opt-out of a page-level setting (if present). Setting this to false when not specified at the page-level won't change anything.
ফেরত
Slot The slot object on which the method was called.

setSafeFrameConfig

setSafeFrameConfig ( config : SafeFrameConfig ) : Slot
Sets the slot-level preferences for SafeFrame configuration. Any unrecognized keys in the config object will be ignored. The entire config will be ignored if an invalid value is passed for a recognized key.

These slot-level preferences, if specified, will override any page-level preferences.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.pubads().setForceSafeFrame(true);

// The following slot will have a sandboxed safeframe that only
// disallows top-level navigation.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setSafeFrameConfig({ sandbox: true })
  .addService(googletag.pubads());

// The following slot will inherit page-level settings.
googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads());

googletag.display("div-1");
googletag.display("div-2");

JavaScript (legacy)

googletag.pubads().setForceSafeFrame(true);

// The following slot will have a sandboxed safeframe that only
// disallows top-level navigation.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setSafeFrameConfig({ sandbox: true })
  .addService(googletag.pubads());

// The following slot will inherit page-level settings.
googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads());

googletag.display("div-1");
googletag.display("div-2");

টাইপস্ক্রিপ্ট

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 : SafeFrameConfig The configuration object.
ফেরত
Slot The slot object on which the method was called.

setTargeting

setTargeting ( key : string , value : string | string [] ) : Slot
Sets a custom targeting parameter for this slot. Calling this method multiple times for the same key will overwrite old values. Values set here will overwrite targeting parameters set at the service-level. These keys are defined in your Google Ad Manager account.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div");
slot.addService(googletag.pubads());

// Example with a single value for a key.
slot.setConfig({
  targeting: {
    allow_expandable: "true",
  },
});

// Example with multiple values for a key inside in an array.
slot.setConfig({
  targeting: {
    interests: ["sports", "music"],
  },
});

JavaScript (legacy)

var slot = googletag.defineSlot("/1234567/sports", [160, 600], "div");
slot.addService(googletag.pubads());

// Example with a single value for a key.
slot.setConfig({
  targeting: {
    allow_expandable: "true",
  },
});

// Example with multiple values for a key inside in an array.
slot.setConfig({
  targeting: {
    interests: ["sports", "music"],
  },
});

টাইপস্ক্রিপ্ট

const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!;
slot.addService(googletag.pubads());

// Example with a single value for a key.
slot.setConfig({
  targeting: {
    allow_expandable: "true",
  },
});

// Example with multiple values for a key inside in an array.
slot.setConfig({
  targeting: {
    interests: ["sports", "music"],
  },
});
আরও দেখুন
প্যারামিটার
key : string Targeting parameter key.
value : string | string [] Targeting parameter value or array of values.
ফেরত
Slot The slot object on which the method was called.

updateTargetingFromMap

updateTargetingFromMap ( map : {
  [ adUnitPath : string ] : string | string [] ;
} ) : Slot
Sets custom targeting parameters for this slot, from a key:value map in a JSON object. This is the same as calling Slot.setTargeting for all the key values of the object. These keys are defined in your Google Ad Manager account.

নোট:
  • In case of overwriting, only the last value will be kept.
  • If the value is an array, any previous value will be overwritten, not merged.
  • Values set here will overwrite targeting parameters set at the service-level.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div");

slot.updateTargetingFromMap({
  color: "red",
  interests: ["sports", "music", "movies"],
});

JavaScript (legacy)

var slot = googletag.defineSlot("/1234567/sports", [160, 600], "div");

slot.updateTargetingFromMap({
  color: "red",
  interests: ["sports", "music", "movies"],
});

টাইপস্ক্রিপ্ট

const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!;

slot.updateTargetingFromMap({
  color: "red",
  interests: ["sports", "music", "movies"],
});
প্যারামিটার
map : {
  [ adUnitPath : string ] : string | string [] ;
}
Targeting parameter key:value map.
ফেরত
Slot The slot object on which the method was called.

googletag.config

Main configuration interface for page-level settings.
ইন্টারফেস
Ad Expansion Config
Settings to control ad expansion.
Ad Sense Attributes Config
Settings to control the behavior of AdSense ads.
Auto Refresh Config
Auto refresh configuration settings.
Continue Button Config
Settings to configure the continue button behavior.
Interstitial Config
An object which defines the behavior of a single interstitial ad slot.
Lazy Load Config
Settings to control the use of lazy loading in GPT.
Page Settings Config
Main configuration interface for page-level settings.
Privacy Treatments Config
Settings to control publisher privacy treatments.
Publisher Provided Signals Config
Publisher provided signals (PPS) configuration object.
Safe Frame Config
Settings to control SafeFrame in GPT.
Slot Settings Config
Main configuration interface for slot-level settings.
Taxonomy Data
An object containing the values for a single Taxonomy .
Video Ads Config
Settings to configure video ad related settings.
Type Aliases
Collapse Div Behavior
Supported values for controlling the collapsing behavior of ad slots.
Interstitial Trigger
Supported interstitial ad triggers.
Privacy Treatment
Supported publisher privacy treatments.
Taxonomy
Supported taxonomies for publisher provided signals (PPS) .

Type Aliases


CollapseDivBehavior

CollapseDivBehavior : "DISABLED" | "BEFORE_FETCH" | "ON_NO_FILL"
Supported values for controlling the collapsing behavior of ad slots.
আরও দেখুন

InterstitialTrigger

InterstitialTrigger : "unhideWindow" | "navBar" | "inactivity" | "endOfArticle" | "continueReading" | "backward"
Supported interstitial ad triggers.

Note : Beginning June 15, 2026, the backward trigger will no longer be supported and enabling it will have no effect. See the GPT release notes for more information.

PrivacyTreatment

PrivacyTreatment : "disablePersonalization"
Supported publisher privacy treatments.

শ্রেণিবিন্যাস

Taxonomy : "IAB_AUDIENCE_1_1" | "IAB_CONTENT_2_2"
Supported taxonomies for publisher provided signals (PPS) .
আরও দেখুন

googletag.config.AdExpansionConfig

Settings to control ad expansion.
বৈশিষ্ট্য
enabled ?
Whether ad expansion is enabled or disabled.
উদাহরণ

জাভাস্ক্রিপ্ট

// Enable ad slot expansion across the entire page.
googletag.setConfig({
  adExpansion: { enabled: true },
});

JavaScript (legacy)

// Enable ad slot expansion across the entire page.
googletag.setConfig({
  adExpansion: { enabled: true },
});

টাইপস্ক্রিপ্ট

// Enable ad slot expansion across the entire page.
googletag.setConfig({
  adExpansion: { enabled: true },
});

বৈশিষ্ট্য


Optional enabled

enabled ?: boolean
Whether ad expansion is enabled or disabled.

Setting this value overrides the default configured in Google Ad Manager.
আরও দেখুন

googletag.config.AdSenseAttributesConfig

Settings to control the behavior of AdSense ads.

These attributes can be used to override server-side settings on a per-request basis.
বৈশিষ্ট্য
adsense _ad _format ?
AdSense ad format.
adsense _channel _ids ?
AdSense channel IDs.
adsense _test _mode ?
Whether or not test mode is enabled.
document _language ?
Language of the page on which ads are displayed.
page _url ?
URL of the page on which ads are displayed.
আরও দেখুন

বৈশিষ্ট্য


Optional adsense_ad_format

adsense_ad_format ?: "120x240_as" | "120x600_as" | "125x125_as" | "160x600_as" | "180x150_as" | "200x200_as" | "234x60_as" | "250x250_as" | "300x250_as" | "336x280_as" | "468x60_as" | "728x90_as"
AdSense ad format.

Optional adsense_channel_ids

adsense_channel_ids ?: string
AdSense channel IDs.

Allowed values are channel IDs separated by '+'.

Example: 271828183+314159265
আরও দেখুন

Optional adsense_test_mode

adsense_test_mode ?: "on"
Whether or not test mode is enabled.

When set to on , ads are marked as test-only, and won't be included in counting or billing. This setting must be unset for production, non-test traffic.

Optional document_language

document_language ?: string
Language of the page on which ads are displayed.

Allowed values are valid ISO 639-1 language codes.

Example: en
আরও দেখুন

Optional page_url

page_url ?: string
URL of the page on which ads are displayed.

Allowed values are valid URLs.

Example: http://www.example.com

googletag.config.AutoRefreshConfig

Auto refresh configuration settings.
বৈশিষ্ট্য
heavy Ads ?
Whether GPT will automatically refresh an ad slot if Chrome's Heavy Ad Intervention triggers on the slot's ad iframe.

বৈশিষ্ট্য


Optional heavyAds

heavyAds ?: boolean
Whether GPT will automatically refresh an ad slot if Chrome's Heavy Ad Intervention triggers on the slot's ad iframe. Defaults to true .
উদাহরণ

জাভাস্ক্রিপ্ট

// Set the auto refresh configuration, disabling auto refresh on heavy
// ad intervention.
googletag.setConfig({ autoRefresh: { heavyAds: false } });

// Clear the auto refresh configuration, restoring to default behavior.
googletag.setConfig({ autoRefresh: null });

JavaScript (legacy)

// Set the auto refresh configuration, disabling auto refresh on heavy
// ad intervention.
googletag.setConfig({ autoRefresh: { heavyAds: false } });

// Clear the auto refresh configuration, restoring to default behavior.
googletag.setConfig({ autoRefresh: null });

টাইপস্ক্রিপ্ট

// Set the auto refresh configuration, disabling auto refresh on heavy
// ad intervention.
googletag.setConfig({ autoRefresh: { heavyAds: false } });

// Clear the auto refresh configuration, restoring to default behavior.
googletag.setConfig({ autoRefresh: null });
আরও দেখুন

googletag.config.ContinueButtonConfig

Settings to configure the continue button behavior.
বৈশিষ্ট্য
background Color ?
The background color of the button.
font ?
The font family of the button text.
font Color ?
The text color of the button.
freq Cap Interval Minutes ?
The frequency capping interval in minutes.
target Id ?
The ID of the HTML element on which to render/trigger the continue button.
আরও দেখুন

বৈশিষ্ট্য


Optional backgroundColor

backgroundColor ?: string
The background color of the button.

Example: 'blue' , '#94B1FF'

Optional font

font ?: string
The font family of the button text.

Example: 'Arial'

Optional fontColor

fontColor ?: string
The text color of the button.

Example: 'white' , '#B73B87'

Optional freqCapIntervalMinutes

freqCapIntervalMinutes ?: number
The frequency capping interval in minutes.

Must be an integer greater than or equal to 1.

Optional targetId

targetId ?: string
The ID of the HTML element on which to render/trigger the continue button.

googletag.config.InterstitialConfig

An object which defines the behavior of a single interstitial ad slot.
বৈশিষ্ট্য
require Storage Access ?
Whether local storage consent is required to display this interstitial ad.
triggers ?
The interstitial trigger configuration for this interstitial ad.

বৈশিষ্ট্য


Optional requireStorageAccess

requireStorageAccess ?: boolean
Whether local storage consent is required to display this interstitial ad.

GPT uses local storage to enforce a frequency cap for interstitial ads. However, users who have not provided local storage consent are still eligible to be served interstitial ads. Setting this property to true opts out of the default behavior, and ensures interstitial ads are only shown to users who have provided local storage consent.
উদাহরণ

জাভাস্ক্রিপ্ট

// Opt out of showing interstitials to users
// without local storage consent.
const interstitialSlot = googletag.defineOutOfPageSlot(
  "/1234567/sports",
  googletag.enums.OutOfPageFormat.INTERSTITIAL,
);

interstitialSlot.setConfig({
  interstitial: {
    requireStorageAccess: true, // defaults to false
  },
});

JavaScript (legacy)

// Opt out of showing interstitials to users
// without local storage consent.
var interstitialSlot = googletag.defineOutOfPageSlot(
  "/1234567/sports",
  googletag.enums.OutOfPageFormat.INTERSTITIAL,
);

interstitialSlot.setConfig({
  interstitial: {
    requireStorageAccess: true, // defaults to false
  },
});

টাইপস্ক্রিপ্ট

// Opt out of showing interstitials to users
// without local storage consent.
const interstitialSlot = googletag.defineOutOfPageSlot(
  "/1234567/sports",
  googletag.enums.OutOfPageFormat.INTERSTITIAL,
)!;

interstitialSlot.setConfig({
  interstitial: {
    requireStorageAccess: true, // defaults to false
  },
});
আরও দেখুন

Optional triggers

triggers ?: Partial < Record < InterstitialTrigger , boolean > >
The interstitial trigger configuration for this interstitial ad.

Setting the value of an interstitial trigger to true will enable it and false will disable it. This will override the default values configured in Google Ad Manager .
উদাহরণ

জাভাস্ক্রিপ্ট

// Define a GPT managed web interstitial ad slot.
const interstitialSlot = googletag.defineOutOfPageSlot(
  "/1234567/sports",
  googletag.enums.OutOfPageFormat.INTERSTITIAL,
);

// Enable optional interstitial triggers.
// Change this value to false to disable.
const enableTriggers = true;

interstitialSlot.setConfig({
  interstitial: {
    triggers: {
      navBar: enableTriggers,
      unhideWindow: enableTriggers,
    },
  },
});

JavaScript (legacy)

// Define a GPT managed web interstitial ad slot.
var interstitialSlot = googletag.defineOutOfPageSlot(
  "/1234567/sports",
  googletag.enums.OutOfPageFormat.INTERSTITIAL,
);

// Enable optional interstitial triggers.
// Change this value to false to disable.
var enableTriggers = true;

interstitialSlot.setConfig({
  interstitial: {
    triggers: {
      navBar: enableTriggers,
      unhideWindow: enableTriggers,
    },
  },
});

টাইপস্ক্রিপ্ট

// Define a GPT managed web interstitial ad slot.
const interstitialSlot = googletag.defineOutOfPageSlot(
  "/1234567/sports",
  googletag.enums.OutOfPageFormat.INTERSTITIAL,
)!;

// Enable optional interstitial triggers.
// Change this value to false to disable.
const enableTriggers = true;

interstitialSlot.setConfig({
  interstitial: {
    triggers: {
      navBar: enableTriggers,
      unhideWindow: enableTriggers,
    },
  },
});
আরও দেখুন

googletag.config.LazyLoadConfig

Settings to control the use of lazy loading in GPT.
বৈশিষ্ট্য
fetch Margin Percent ?
The minimum distance from the current viewport a slot must be before we request an ad, expressed as a percentage of viewport size.
mobile Scaling ?
A multiplier applied to margins on mobile devices.
render Margin Percent ?
The minimum distance from the current viewport a slot must be before we render an ad, expressed as a percentage of viewport size.
আরও দেখুন

বৈশিষ্ট্য


Optional fetchMarginPercent

fetchMarginPercent ?: number
The minimum distance from the current viewport a slot must be before we request an ad, expressed as a percentage of viewport size.

Used in conjunction with renderMarginPercent , this setting allows for prefetching an ad, but waiting to render and download other subresources. As such, this value should always be greater than or equal to renderMarginPercent .

A value of 0 means "when the slot enters the viewport", 100 means "when the ad is 1 viewport away", and so on.

Optional mobileScaling

mobileScaling ?: number
A multiplier applied to margins on mobile devices. This multiplier is applied to both fetchMarginPercent and renderMarginPercent .

This allows for different margins on mobile vs. desktop, where viewport sizes and scroll speeds may be different. For example, a value of 2.0 will multiply all margins by 2 on mobile devices, increasing the minimum distance a slot can be from the viewport before fetching and rendering.

Optional renderMarginPercent

renderMarginPercent ?: number
The minimum distance from the current viewport a slot must be before we render an ad, expressed as a percentage of viewport size.

Used in conjunction with fetchMarginPercent , this setting allows for prefetching an ad, but waiting to render and download other subresources. As such, this value should always be less than or equal to fetchMarginPercent .

A value of 0 means "when the slot enters the viewport", 100 means "when the ad is 1 viewport away", and so on.

googletag.config.PageSettingsConfig

Main configuration interface for page-level settings.

Allows setting multiple features with a single API call.

All properties listed below are examples and do not reflect actual features that utilize setConfig. For the set of features, see fields within the PageSettingsConfig type below.

উদাহরণ:
  • Only features specified in the googletag.setConfig call are modified.
      // Configure feature alpha.
      googletag.setConfig({
          alpha: {...}
      });
    
      // Configure feature bravo. Feature alpha is unchanged.
      googletag.setConfig({
         bravo: {...}
      });
  • All settings for a given feature are updated with each call to googletag.setConfig .
      // Configure feature charlie to echo = 1, foxtrot = true.
      googletag.setConfig({
          charlie: {
              echo: 1,
              foxtrot: true,
          }
      });
    
      // Update feature charlie to echo = 2. Since foxtrot was not specified,
      // the value is cleared.
      googletag.setConfig({
          charlie: {
              echo: 2
          }
      });
  • All settings for a feature can be cleared by passing 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,
      });
বৈশিষ্ট্য
ad Expansion ?
Settings to control ad expansion.
adsense Attributes ?
Setting to configure AdSense attributes.
ad Yield ?
Deprecated.
auto Refresh ?
Setting to configure automatic ad refresh behavior.
category Exclusion ?
Setting to configure ad category exclusions.
centering ?
Setting to control the horizontal centering of ads.
collapse Div ?
Setting to control the collapsing behavior of ad slots.
disable Initial Load ?
Setting to control when ads are requested.
lazy Load ?
Settings to control the use of lazy loading in GPT.
location ?
Setting to geo-target line items to geographic locations.
pps ?
Settings to control publisher provided signals (PPS).
privacy Treatments ?
Settings to control publisher privacy treatments.
safe Frame ?
Settings to control the use of SafeFrame in GPT.
single Request ?
Setting to enable or disable Single Request Architecture (SRA).
targeting ?
Setting to control key-value targeting.
thread Yield ?
Setting to control whether GPT should yield the JS thread when requesting and rendering creatives.
video Ads ?
Settings to control video ads.

বৈশিষ্ট্য


Optional adExpansion

adExpansion ?: AdExpansionConfig
Settings to control ad expansion.

Optional adsenseAttributes

adsenseAttributes ?: AdSenseAttributesConfig
Setting to configure AdSense attributes.

AdSense attributes configured via this setting will apply to all ad slots on the page. This setting may be called multiple times to define multiple attribute values, or overwrite existing values.

AdSense attribute changes only apply to ads requested after this method has been called. For that reason, it is recommended to call this method before any calls to googletag.display or PubAdsService.refresh .
উদাহরণ

জাভাস্ক্রিপ্ট

// Set the document language and page URL.
googletag.setConfig({
  adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" },
});

// Clear the page URL only.
googletag.setConfig({ adsenseAttributes: { page_url: null } });

// Clear all AdSense attributes.
googletag.setConfig({ adsenseAttributes: null });

JavaScript (legacy)

// Set the document language and page URL.
googletag.setConfig({
  adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" },
});

// Clear the page URL only.
googletag.setConfig({ adsenseAttributes: { page_url: null } });

// Clear all AdSense attributes.
googletag.setConfig({ adsenseAttributes: null });

টাইপস্ক্রিপ্ট

// Set the document language and page URL.
googletag.setConfig({
  adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" },
});

// Clear the page URL only.
googletag.setConfig({ adsenseAttributes: { page_url: null } });

// Clear all AdSense attributes.
googletag.setConfig({ adsenseAttributes: null });

Optional adYield

adYield ?: "DISABLED" | "ENABLED_ALL_SLOTS"

Optional autoRefresh

autoRefresh ?: AutoRefreshConfig
Setting to configure automatic ad refresh behavior.
উদাহরণ

জাভাস্ক্রিপ্ট

// Set the auto refresh configuration.
googletag.setConfig({ autoRefresh: { heavyAds: false } });

// Clear the auto refresh configuration.
googletag.setConfig({ autoRefresh: null });

JavaScript (legacy)

// Set the auto refresh configuration.
googletag.setConfig({ autoRefresh: { heavyAds: false } });

// Clear the auto refresh configuration.
googletag.setConfig({ autoRefresh: null });

টাইপস্ক্রিপ্ট

// Set the auto refresh configuration.
googletag.setConfig({ autoRefresh: { heavyAds: false } });

// Clear the auto refresh configuration.
googletag.setConfig({ autoRefresh: null });

Optional categoryExclusion

categoryExclusion ?: string []
Setting to configure ad category exclusions.
উদাহরণ

জাভাস্ক্রিপ্ট

// Label = AirlineAd.
googletag.setConfig({ categoryExclusion: ["AirlineAd"] });

// Clearing category exclusion setting.
googletag.setConfig({ categoryExclusion: null });

JavaScript (legacy)

// Label = AirlineAd.
googletag.setConfig({ categoryExclusion: ["AirlineAd"] });

// Clearing category exclusion setting.
googletag.setConfig({ categoryExclusion: null });

টাইপস্ক্রিপ্ট

// Label = AirlineAd.
googletag.setConfig({ categoryExclusion: ["AirlineAd"] });

// Clearing category exclusion setting.
googletag.setConfig({ categoryExclusion: null });
আরও দেখুন

Optional centering

centering ?: boolean
Setting to control the horizontal centering of ads. Centering is disabled by default.

Horizontal centering changes only apply to ads requested after this method has been called. For that reason, it is recommended to call this method before any calls to googletag.display or PubAdsService.refresh .
উদাহরণ

জাভাস্ক্রিপ্ট

// Make ads centered.
googletag.setConfig({ centering: true });

// Clear the centering setting.
googletag.setConfig({ centering: null });

JavaScript (legacy)

// Make ads centered.
googletag.setConfig({ centering: true });

// Clear the centering setting.
googletag.setConfig({ centering: null });

টাইপস্ক্রিপ্ট

// Make ads centered.
googletag.setConfig({ centering: true });

// Clear the centering setting.
googletag.setConfig({ centering: null });

Optional collapseDiv

collapseDiv ?: CollapseDivBehavior
Setting to control the collapsing behavior of ad slots.

A collapsed ad slot does not take up any space on the page.

Supported values:
  • null (default): The slot will not be collapsed.
  • DISABLED : The slot will not collapse, whether or not an ad is returned.
  • BEFORE_FETCH : The slot will start out collapsed, and expand when an ad is returned.
  • ON_NO_FILL : The slot will start out expanded, and collapse if no ad is returned.
উদাহরণ

জাভাস্ক্রিপ্ট

// Collapse the div for this slot if no ad is returned.
googletag.setConfig({ collapseDiv: "ON_NO_FILL" });

// Collapse the div for this slot by default, and expand only
// if an ad is returned.
googletag.setConfig({ collapseDiv: "BEFORE_FETCH" });

// Do not collapse the div for this slot.
googletag.setConfig({ collapseDiv: "DISABLED" });

// Clear the collapse setting.
googletag.setConfig({ collapseDiv: null });

JavaScript (legacy)

// Collapse the div for this slot if no ad is returned.
googletag.setConfig({ collapseDiv: "ON_NO_FILL" });

// Collapse the div for this slot by default, and expand only
// if an ad is returned.
googletag.setConfig({ collapseDiv: "BEFORE_FETCH" });

// Do not collapse the div for this slot.
googletag.setConfig({ collapseDiv: "DISABLED" });

// Clear the collapse setting.
googletag.setConfig({ collapseDiv: null });

টাইপস্ক্রিপ্ট

// Collapse the div for this slot if no ad is returned.
googletag.setConfig({ collapseDiv: "ON_NO_FILL" });

// Collapse the div for this slot by default, and expand only
// if an ad is returned.
googletag.setConfig({ collapseDiv: "BEFORE_FETCH" });

// Do not collapse the div for this slot.
googletag.setConfig({ collapseDiv: "DISABLED" });

// Clear the collapse setting.
googletag.setConfig({ collapseDiv: null });
আরও দেখুন

Optional disableInitialLoad

disableInitialLoad ?: boolean
Setting to control when ads are requested.

By default, the googletag.display method both registers ad slots and requests ads for them. However, there are times when it may be preferable to separate these actions, in order to more precisely control when ad content is loaded.

By enabling this setting, ads will not be requested for registered slots when the display() method is called. Instead, a separate call to PubAdsService.refresh must be made to initiate an ad request.

This method must be called before calling googletag.enableServices .
উদাহরণ

জাভাস্ক্রিপ্ট

// Prevent requesting ads when `display()` is called.
googletag.setConfig({ disableInitialLoad: true });

JavaScript (legacy)

// Prevent requesting ads when `display()` is called.
googletag.setConfig({ disableInitialLoad: true });

টাইপস্ক্রিপ্ট

// Prevent requesting ads when `display()` is called.
googletag.setConfig({ disableInitialLoad: true });
আরও দেখুন

Optional lazyLoad

lazyLoad ?: LazyLoadConfig
Settings to control the use of lazy loading in GPT.

Lazy loading is a technique to delay the requesting and rendering of ads until they approach the user's viewport. For a more detailed example, see the Lazy loading sample.

Note: If singleRequest is enabled, lazy fetching only works when all slots are outside the fetch margin.

Any lazy load settings which are not specified when calling setConfig() will use a default value set by Google. These defaults may be tuned over time. To disable a particular setting, set the value to null .
উদাহরণ

জাভাস্ক্রিপ্ট

// Enable lazy loading.
googletag.setConfig({
  lazyLoad: {
    // Fetch slots within 5 viewports.
    fetchMarginPercent: 500,
    // Render slots within 2 viewports.
    renderMarginPercent: 200,
    // Double the above values on mobile.
    mobileScaling: 2.0,
  },
});

// Clear fetch margin only.
googletag.setConfig({
  lazyLoad: { fetchMarginPercent: null },
});

// Clear all lazy loading settings.
googletag.setConfig({ lazyLoad: null });

JavaScript (legacy)

// Enable lazy loading.
googletag.setConfig({
  lazyLoad: {
    // Fetch slots within 5 viewports.
    fetchMarginPercent: 500,
    // Render slots within 2 viewports.
    renderMarginPercent: 200,
    // Double the above values on mobile.
    mobileScaling: 2.0,
  },
});

// Clear fetch margin only.
googletag.setConfig({
  lazyLoad: { fetchMarginPercent: null },
});

// Clear all lazy loading settings.
googletag.setConfig({ lazyLoad: null });

টাইপস্ক্রিপ্ট

// Enable lazy loading.
googletag.setConfig({
  lazyLoad: {
    // Fetch slots within 5 viewports.
    fetchMarginPercent: 500,
    // Render slots within 2 viewports.
    renderMarginPercent: 200,
    // Double the above values on mobile.
    mobileScaling: 2.0,
  },
});

// Clear fetch margin only.
googletag.setConfig({
  lazyLoad: { fetchMarginPercent: null },
});

// Clear all lazy loading settings.
googletag.setConfig({ lazyLoad: null });
আরও দেখুন

Optional location

location ?: string
Setting to geo-target line items to geographic locations.
উদাহরণ

জাভাস্ক্রিপ্ট

// Geo-target line items to US postal code 10001.
googletag.setConfig({ location: "10001,US" });

// Clear the location setting.
googletag.setConfig({ location: null });

JavaScript (legacy)

// Geo-target line items to US postal code 10001.
googletag.setConfig({ location: "10001,US" });

// Clear the location setting.
googletag.setConfig({ location: null });

টাইপস্ক্রিপ্ট

// Geo-target line items to US postal code 10001.
googletag.setConfig({ location: "10001,US" });

// Clear the location setting.
googletag.setConfig({ location: null });
আরও দেখুন

Optional pps

Settings to control publisher provided signals (PPS).

Optional privacyTreatments

privacyTreatments ?: PrivacyTreatmentsConfig
Settings to control publisher privacy treatments.

Optional safeFrame

safeFrame ?: SafeFrameConfig
Settings to control the use of SafeFrame in GPT.

Values configured via this setting will apply to all ad slots on the page. Individual ad slots may override these values via SlotSettingsConfig.safeFrame .
উদাহরণ

জাভাস্ক্রিপ্ট

// Force SafeFrame for all ads on the page.
googletag.setConfig({
  safeFrame: { forceSafeFrame: true },
});

// Configure SafeFrame to allow overlay expansion.
googletag.setConfig({
  safeFrame: { allowOverlayExpansion: true },
});

// Clear forceSafeFrame setting.
googletag.setConfig({
  safeFrame: { forceSafeFrame: null },
});

// Clear all SafeFrame settings.
googletag.setConfig({ safeFrame: null });

JavaScript (legacy)

// Force SafeFrame for all ads on the page.
googletag.setConfig({
  safeFrame: { forceSafeFrame: true },
});

// Configure SafeFrame to allow overlay expansion.
googletag.setConfig({
  safeFrame: { allowOverlayExpansion: true },
});

// Clear forceSafeFrame setting.
googletag.setConfig({
  safeFrame: { forceSafeFrame: null },
});

// Clear all SafeFrame settings.
googletag.setConfig({ safeFrame: null });

টাইপস্ক্রিপ্ট

// Force SafeFrame for all ads on the page.
googletag.setConfig({
  safeFrame: { forceSafeFrame: true },
});

// Configure SafeFrame to allow overlay expansion.
googletag.setConfig({
  safeFrame: { allowOverlayExpansion: true },
});

// Clear forceSafeFrame setting.
googletag.setConfig({
  safeFrame: { forceSafeFrame: null },
});

// Clear all SafeFrame settings.
googletag.setConfig({ safeFrame: null });

Optional singleRequest

singleRequest ?: boolean
Setting to enable or disable Single Request Architecture (SRA).

When SRA is enabled, all ad slots defined prior to a googletag.display or PubAdsService.refresh call will be batched into a single ad request. This provides performance benefits, but is also necessary to ensure roadblocks and competetive exclusions are honored.

When SRA is disabled, each ad slot is requested individually. This is the default behavior of GPT.

This method must be called prior to calling googletag.enableServices .
উদাহরণ

জাভাস্ক্রিপ্ট

// Enable Single Request Architecture.
googletag.setConfig({ singleRequest: true });

JavaScript (legacy)

// Enable Single Request Architecture.
googletag.setConfig({ singleRequest: true });

টাইপস্ক্রিপ্ট

// Enable Single Request Architecture.
googletag.setConfig({ singleRequest: true });
আরও দেখুন

Optional targeting

targeting ?: Record < string , string | string [] >
Setting to control key-value targeting.

Targeting configured via this setting will apply to all ad slots on the page. This setting may be called multiple times to define multiple targeting key-values, or overwrite existing values. Targeting keys are defined in your Google Ad Manager account.
উদাহরণ

জাভাস্ক্রিপ্ট

// Setting a single targeting key-value.
googletag.setConfig({ targeting: { interests: "sports" } });

// Setting multiple values for a single targeting key
googletag.setConfig({ targeting: { interests: ["sports", "music"] } });

// Setting multiple targeting key-values at once.
googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });

// Clearing a single targeting key.
googletag.setConfig({ targeting: { interests: null } });

JavaScript (legacy)

// Setting a single targeting key-value.
googletag.setConfig({ targeting: { interests: "sports" } });

// Setting multiple values for a single targeting key
googletag.setConfig({ targeting: { interests: ["sports", "music"] } });

// Setting multiple targeting key-values at once.
googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });

// Clearing a single targeting key.
googletag.setConfig({ targeting: { interests: null } });

টাইপস্ক্রিপ্ট

// Setting a single targeting key-value.
googletag.setConfig({ targeting: { interests: "sports" } });

// Setting multiple values for a single targeting key
googletag.setConfig({ targeting: { interests: ["sports", "music"] } });

// Setting multiple targeting key-values at once.
googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });

// Clearing a single targeting key.
googletag.setConfig({ targeting: { interests: null } });
আরও দেখুন

Optional threadYield

threadYield ?: "DISABLED" | "ENABLED_ALL_SLOTS"
Setting to control whether GPT should yield the JS thread when requesting and rendering creatives.

GPT will yield only for browsers that support the Scheduler.postTask or Scheduler.yield API.

Supported values:
  • null (default): GPT will yield the JS thread for slots outside of the viewport.
  • ENABLED_ALL_SLOTS : GPT will yield the JS thread for all slots regardless of whether the slot is within the viewport.
  • DISABLED : GPT will not yield the JS thread.
উদাহরণ

জাভাস্ক্রিপ্ট

// Disable yielding.
googletag.setConfig({ threadYield: "DISABLED" });

// Enable yielding for all slots.
googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" });

// Enable yielding only for slots outside of the viewport (default).
googletag.setConfig({ threadYield: null });

JavaScript (legacy)

// Disable yielding.
googletag.setConfig({ threadYield: "DISABLED" });

// Enable yielding for all slots.
googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" });

// Enable yielding only for slots outside of the viewport (default).
googletag.setConfig({ threadYield: null });

টাইপস্ক্রিপ্ট

// Disable yielding.
googletag.setConfig({ threadYield: "DISABLED" });

// Enable yielding for all slots.
googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" });

// Enable yielding only for slots outside of the viewport (default).
googletag.setConfig({ threadYield: null });
আরও দেখুন

Optional videoAds

videoAds ?: VideoAdsConfig
Settings to control video ads.
উদাহরণ

জাভাস্ক্রিপ্ট

// Enable video ads and set video content and content source IDs.
googletag.setConfig({
  videoAds: {
    enableVideoAds: true,
    videoContentId: "e1eGlRL7ju8",
    videoCmsId: "1234567",
  },
});

JavaScript (legacy)

// Enable video ads and set video content and content source IDs.
googletag.setConfig({
  videoAds: {
    enableVideoAds: true,
    videoContentId: "e1eGlRL7ju8",
    videoCmsId: "1234567",
  },
});

টাইপস্ক্রিপ্ট

// Enable video ads and set video content and content source IDs.
googletag.setConfig({
  videoAds: {
    enableVideoAds: true,
    videoContentId: "e1eGlRL7ju8",
    videoCmsId: "1234567",
  },
});
আরও দেখুন

googletag.config.PrivacyTreatmentsConfig

Settings to control publisher privacy treatments.
বৈশিষ্ট্য
treatments
An array of publisher privacy treatments to enable.

বৈশিষ্ট্য


treatments

treatments : "disablePersonalization" []
An array of publisher privacy treatments to enable.
উদাহরণ

জাভাস্ক্রিপ্ট

// Disable personalization across the entire page.
googletag.setConfig({
  privacyTreatments: { treatments: ["disablePersonalization"] },
});

JavaScript (legacy)

// Disable personalization across the entire page.
googletag.setConfig({
  privacyTreatments: { treatments: ["disablePersonalization"] },
});

টাইপস্ক্রিপ্ট

// Disable personalization across the entire page.
googletag.setConfig({
  privacyTreatments: { treatments: ["disablePersonalization"] },
});

googletag.config.PublisherProvidedSignalsConfig

Publisher provided signals (PPS) configuration object.
বৈশিষ্ট্য
taxonomies
An object containing Taxonomy mappings or null to clear the config.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  pps: {
    taxonomies: {
      IAB_AUDIENCE_1_1: { values: ["6", "626"] },
      // '6' = 'Demographic | Age Range | 30-34'
      // '626' = 'Interest | Sports | Darts'
      IAB_CONTENT_2_2: { values: ["48", "127"] },
      // '48' = 'Books and Literature | Fiction'
      // '127' = 'Careers | Job Search'
    },
  },
});

JavaScript (legacy)

googletag.setConfig({
  pps: {
    taxonomies: {
      IAB_AUDIENCE_1_1: { values: ["6", "626"] },
      // '6' = 'Demographic | Age Range | 30-34'
      // '626' = 'Interest | Sports | Darts'
      IAB_CONTENT_2_2: { values: ["48", "127"] },
      // '48' = 'Books and Literature | Fiction'
      // '127' = 'Careers | Job Search'
    },
  },
});

টাইপস্ক্রিপ্ট

googletag.setConfig({
  pps: {
    taxonomies: {
      IAB_AUDIENCE_1_1: { values: ["6", "626"] },
      // '6' = 'Demographic | Age Range | 30-34'
      // '626' = 'Interest | Sports | Darts'
      IAB_CONTENT_2_2: { values: ["48", "127"] },
      // '48' = 'Books and Literature | Fiction'
      // '127' = 'Careers | Job Search'
    },
  },
});
আরও দেখুন

বৈশিষ্ট্য


taxonomies

taxonomies : Partial < Record < Taxonomy , TaxonomyData > >
An object containing Taxonomy mappings or null to clear the config.

googletag.config.SafeFrameConfig

Settings to control SafeFrame in GPT.
বৈশিষ্ট্য
allow Overlay Expansion ?
Whether SafeFrame should allow ad content to expand by overlaying page content.
allow Push Expansion ?
Whether SafeFrame should allow ad content to expand by pushing page content.
force Safe Frame ?
Whether ad(s) should be forced to be rendered using a SafeFrame container.
sandbox ?
Whether SafeFrame should use the HTML5 sandbox attribute to prevent top level navigation without user interaction.
use Unique Domain ?
Deprecated. Whether SafeFrame should use randomized subdomains for Reservation creatives.
আরও দেখুন

বৈশিষ্ট্য


Optional allowOverlayExpansion

allowOverlayExpansion ?: boolean
Whether SafeFrame should allow ad content to expand by overlaying page content.

Optional allowPushExpansion

allowPushExpansion ?: boolean
Whether SafeFrame should allow ad content to expand by pushing page content.

Optional forceSafeFrame

forceSafeFrame ?: boolean
Whether ad(s) should be forced to be rendered using a SafeFrame container.

Optional sandbox

sandbox ?: boolean
Whether SafeFrame should use the HTML5 sandbox attribute to prevent top level navigation without user interaction. The only valid value is true (cannot be forced to false ). Note that the sandbox attribute disables plugins (eg Flash).

Optional useUniqueDomain

useUniqueDomain ?: boolean
Whether SafeFrame should use randomized subdomains for Reservation creatives. Pass in null to clear the stored value.

Note: this feature is enabled by default.
আরও দেখুন

googletag.config.SlotSettingsConfig

Main configuration interface for slot-level settings.

Allows setting multiple features with a single API call for a single slot.

All properties listed below are examples and do not reflect actual features that utilize setConfig. For the set of features, see fields within the SlotSettingsConfig type below.

উদাহরণ:
  • Only features specified in the Slot.setConfig call are modified.
      const slot = googletag.defineSlot("/1234567/example", [160, 600]);
    
      // Configure feature alpha.
      slot.setConfig({
          alpha: {...}
      });
    
      // Configure feature bravo. Feature alpha is unchanged.
      slot.setConfig({
         bravo: {...}
      });
  • All settings for a given feature are updated with each call to 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
          }
      });
  • All settings for a feature can be cleared by passing 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,
      });
বৈশিষ্ট্য
ad Expansion ?
Settings to configure ad expansion.
adsense Attributes ?
Setting to configure AdSense attributes.
category Exclusion ?
Setting to configure ad category exclusions.
click Url ?
Setting to configure the URL to which users will be redirected after clicking on the ad.
collapse Div ?
Setting to configure the collapsing behavior of the ad slot.
continue Button ?
Settings to configure the continue button behavior for content pause ads.
interstitial ?
Settings that configure interstitial ad slot behavior.
safe Frame ?
Settings to configure the use of SafeFrame in GPT.
targeting ?
Setting to configure key-value targeting.

বৈশিষ্ট্য


Optional adExpansion

adExpansion ?: AdExpansionConfig
Settings to configure ad expansion.
আরও দেখুন

Optional adsenseAttributes

adsenseAttributes ?: AdSenseAttributesConfig
Setting to configure AdSense attributes.

AdSense attributes configured via this setting will only apply to the ad slot. This setting may be called multiple times to define multiple attribute values, or overwrite existing values.

AdSense attribute changes only apply to ads requested after this method has been called. For that reason, it is recommended to call this method before any calls to googletag.display or PubAdsService.refresh .
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Set the AdSense ad format and channel IDs.
slot.setConfig({
  adsenseAttributes: {
    adsense_ad_format: "120x240_as",
    adsense_channel_ids: "271828183+314159265",
  },
});

// Clear the AdSense channel IDs only.
slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } });

// Clear all AdSense attributes.
slot.setConfig({ adsenseAttributes: null });

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Set the AdSense ad format and channel IDs.
slot.setConfig({
  adsenseAttributes: {
    adsense_ad_format: "120x240_as",
    adsense_channel_ids: "271828183+314159265",
  },
});

// Clear the AdSense channel IDs only.
slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } });

// Clear all AdSense attributes.
slot.setConfig({ adsenseAttributes: null });

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

// Set the AdSense ad format and channel IDs.
slot.setConfig({
  adsenseAttributes: {
    adsense_ad_format: "120x240_as",
    adsense_channel_ids: "271828183+314159265",
  },
});

// Clear the AdSense channel IDs only.
slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } });

// Clear all AdSense attributes.
slot.setConfig({ adsenseAttributes: null });

Optional categoryExclusion

categoryExclusion ?: string []
Setting to configure ad category exclusions.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Label = AirlineAd
slot.setConfig({
  categoryExclusion: ["AirlineAd"],
});

// Clearing category exclusion setting.
slot.setConfig({ categoryExclusion: null });

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Label = AirlineAd
slot.setConfig({
  categoryExclusion: ["AirlineAd"],
});

// Clearing category exclusion setting.
slot.setConfig({ categoryExclusion: null });

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

// Label = AirlineAd
slot.setConfig({
  categoryExclusion: ["AirlineAd"],
});

// Clearing category exclusion setting.
slot.setConfig({ categoryExclusion: null });
আরও দেখুন

Optional clickUrl

clickUrl ?: string
Setting to configure the URL to which users will be redirected after clicking on the ad.

The Google Ad Manager servers still record a click even if the click URL is replaced. Any landing page URL associated with the creative that is served is appended to the provided value. Setting this value more than once will overwrite any previously configured value. Passing in null will clear the value.

Note: This setting only applies to non-SRA requests .
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Sets the click URL to 'http://www.example.com?original_click_url='.
slot.setConfig({
  clickUrl: "http://www.example.com?original_click_url=",
});

// Clears the click URL.
slot.setConfig({
  clickUrl: null,
});

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Sets the click URL to 'http://www.example.com?original_click_url='.
slot.setConfig({
  clickUrl: "http://www.example.com?original_click_url=",
});

// Clears the click URL.
slot.setConfig({
  clickUrl: null,
});

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

// Sets the click URL to 'http://www.example.com?original_click_url='.
slot.setConfig({
  clickUrl: "http://www.example.com?original_click_url=",
});

// Clears the click URL.
slot.setConfig({
  clickUrl: null,
});

Optional collapseDiv

collapseDiv ?: CollapseDivBehavior
Setting to configure the collapsing behavior of the ad slot.

A collapsed ad slot does not take up any space on the page.

Supported values:
  • null (default): The slot will not be collapsed.
  • DISABLED : The slot will not collapse, whether or not an ad is returned.
  • BEFORE_FETCH : The slot will start out collapsed, and expand when an ad is returned.
  • ON_NO_FILL : The slot will start out expanded, and collapse if no ad is returned.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Collapse the div for this slot if no ad is returned.
slot.setConfig({
  collapseDiv: "ON_NO_FILL",
});

// Collapse the div for this slot by default, and expand only
// if an ad is returned.
slot.setConfig({
  collapseDiv: "BEFORE_FETCH",
});

// Do not collapse the div for this slot.
slot.setConfig({
  collapseDiv: "DISABLED",
});

// Clear the collapse setting.
slot.setConfig({
  collapseDiv: null,
});

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Collapse the div for this slot if no ad is returned.
slot.setConfig({
  collapseDiv: "ON_NO_FILL",
});

// Collapse the div for this slot by default, and expand only
// if an ad is returned.
slot.setConfig({
  collapseDiv: "BEFORE_FETCH",
});

// Do not collapse the div for this slot.
slot.setConfig({
  collapseDiv: "DISABLED",
});

// Clear the collapse setting.
slot.setConfig({
  collapseDiv: null,
});

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

// Collapse the div for this slot if no ad is returned.
slot.setConfig({
  collapseDiv: "ON_NO_FILL",
});

// Collapse the div for this slot by default, and expand only
// if an ad is returned.
slot.setConfig({
  collapseDiv: "BEFORE_FETCH",
});

// Do not collapse the div for this slot.
slot.setConfig({
  collapseDiv: "DISABLED",
});

// Clear the collapse setting.
slot.setConfig({
  collapseDiv: null,
});
আরও দেখুন

Optional continueButton

continueButton ?: ContinueButtonConfig
Settings to configure the continue button behavior for content pause ads.

These settings allow customizing the appearance and behavior of the exit and continue reading interactions associated with content pause formats.

Any continue button settings which are not specified when calling setConfig() will use a default value set by Google.

To disable or clear all continue button settings, pass null .
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());
// Configure continue button settings.
slot.setConfig({
  continueButton: {
    font: "Arial",
    fontColor: "white",
    backgroundColor: "blue",
    targetId: "target-div-id",
    freqCapIntervalMinutes: 20,
  },
});

// Clear continue button settings.
slot.setConfig({ continueButton: null });

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());
// Configure continue button settings.
slot.setConfig({
  continueButton: {
    font: "Arial",
    fontColor: "white",
    backgroundColor: "blue",
    targetId: "target-div-id",
    freqCapIntervalMinutes: 20,
  },
});

// Clear continue button settings.
slot.setConfig({ continueButton: null });

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());
// Configure continue button settings.
slot.setConfig({
  continueButton: {
    font: "Arial",
    fontColor: "white",
    backgroundColor: "blue",
    targetId: "target-div-id",
    freqCapIntervalMinutes: 20,
  },
});

// Clear continue button settings.
slot.setConfig({ continueButton: null });

Optional interstitial

interstitial ?: InterstitialConfig
Settings that configure interstitial ad slot behavior.
আরও দেখুন

Optional safeFrame

safeFrame ?: SafeFrameConfig
Settings to configure the use of SafeFrame in GPT.

Values configured via this setting will only apply to the ad slot, and override values set via PageSettingsConfig.safeFrame .
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Force SafeFrame for the slot.
slot.setConfig({
  safeFrame: { forceSafeFrame: true },
});

// Configure SafeFrame to allow overlay expansion for the slot.
slot.setConfig({
  safeFrame: { allowOverlayExpansion: true },
});

// Clear forceSafeFrame setting for the slot.
slot.setConfig({
  safeFrame: { forceSafeFrame: null },
});

// Clear all SafeFrame settings for the slot.
slot.setConfig({ safeFrame: null });

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Force SafeFrame for the slot.
slot.setConfig({
  safeFrame: { forceSafeFrame: true },
});

// Configure SafeFrame to allow overlay expansion for the slot.
slot.setConfig({
  safeFrame: { allowOverlayExpansion: true },
});

// Clear forceSafeFrame setting for the slot.
slot.setConfig({
  safeFrame: { forceSafeFrame: null },
});

// Clear all SafeFrame settings for the slot.
slot.setConfig({ safeFrame: null });

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

// Force SafeFrame for the slot.
slot.setConfig({
  safeFrame: { forceSafeFrame: true },
});

// Configure SafeFrame to allow overlay expansion for the slot.
slot.setConfig({
  safeFrame: { allowOverlayExpansion: true },
});

// Clear forceSafeFrame setting for the slot.
slot.setConfig({
  safeFrame: { forceSafeFrame: null },
});

// Clear all SafeFrame settings for the slot.
slot.setConfig({ safeFrame: null });

Optional targeting

targeting ?: Record < string , string | string [] >
Setting to configure key-value targeting.

Targeting configured via this setting will only apply to the ad slot. This setting may be called multiple times to define multiple targeting key-values, or overwrite existing values. Targeting keys are defined in your Google Ad Manager account.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Setting a single targeting key-value.
slot.setConfig({ targeting: { interests: "sports" } });

// Setting multiple values for a single targeting key.
slot.setConfig({ targeting: { interests: ["sports", "music"] } });

// Setting multiple targeting key-values at once.
slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });

// Clearing a single targeting key.
slot.setConfig({ targeting: { interests: null } });

// Clear all targeting keys.
slot.setConfig({ targeting: null });

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Setting a single targeting key-value.
slot.setConfig({ targeting: { interests: "sports" } });

// Setting multiple values for a single targeting key.
slot.setConfig({ targeting: { interests: ["sports", "music"] } });

// Setting multiple targeting key-values at once.
slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });

// Clearing a single targeting key.
slot.setConfig({ targeting: { interests: null } });

// Clear all targeting keys.
slot.setConfig({ targeting: null });

টাইপস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

// Setting a single targeting key-value.
slot.setConfig({ targeting: { interests: "sports" } });

// Setting multiple values for a single targeting key.
slot.setConfig({ targeting: { interests: ["sports", "music"] } });

// Setting multiple targeting key-values at once.
slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });

// Clearing a single targeting key.
slot.setConfig({ targeting: { interests: null } });

// Clear all targeting keys.
slot.setConfig({ targeting: null });
আরও দেখুন

googletag.config.TaxonomyData

An object containing the values for a single Taxonomy .
বৈশিষ্ট্য
values
A list of Taxonomy values.

বৈশিষ্ট্য


মূল্যবোধ

values : readonly string []
A list of Taxonomy values.

googletag.config.VideoAdsConfig

Settings to configure video ad related settings.
বৈশিষ্ট্য
enable Video Ads
Whether videos ads will be present on the page.
video Cms Id ?
The video content source ID.
video Content Id ?
The video content ID.
আরও দেখুন

বৈশিষ্ট্য


enableVideoAds

enableVideoAds : boolean
Whether videos ads will be present on the page.

When set to true , this enables content exclusion constraints on display and video ads.

If the video content is known, set videoContentId and videoCmsId to the values provided to the Google Ad Manager content ingestion service to utilize content exclusion for display ads.

Optional videoCmsId

videoCmsId ?: string
The video content source ID.

This is a unique value assigned by the Google Ad Manager content ingestion service to identify the source of video content specified by videoContentId .
আরও দেখুন

Optional videoContentId

videoContentId ?: string
The video content ID.

This is a unique value that identifies a particular video from the content source specified by videoCmsId . This value is assigned by the CMS that hosts your video content.
আরও দেখুন

googletag.enums

This is the namespace that GPT uses for enum types.
Enumerations
Out Of Page Format
Out-of-page formats supported by GPT.
Tag For Age Treatment
Age treatment settings supported by GPT.
Traffic Source
Traffic sources supported by GPT.

Enumerations


OutOfPageFormat

OutOfPageFormat
Out-of-page formats supported by GPT.
আরও দেখুন
Enumeration Members
AD_ INTENTS
Ad Intents format.
BOTTOM_ ANCHOR
Anchor format where slot sticks to the bottom of the viewport.
GAME_ MANUAL_ INTERSTITIAL
Game manual interstitial format.

Note: Game manual interstitial is a limited-access format.
INTERSTITIAL
Web interstitial creative format.
LEFT_ SIDE_ RAIL
Left side rail format.
REWARDED
Rewarded format.
RIGHT_ SIDE_ RAIL
Right side rail format.
TOP_ ANCHOR
Anchor format where slot sticks to the top of the viewport.

TagForAgeTreatment

TagForAgeTreatment
Age treatment settings supported by GPT.
আরও দেখুন
Enumeration Members
CHILD
Indicates that ad requests should receive CHILD age treatment.
TEEN
Indicates that ad requests should receive TEEN age treatment.
UNSPECIFIED
Default value. Indicates that no specific age restricted treatment signal applies to the ad request.

TrafficSource

TrafficSource
Traffic sources supported by GPT.
আরও দেখুন
Enumeration Members
ORGANIC
Direct URL entry, site search, or app download.
PURCHASED
Traffic redirected from properties other than owned (acquired or otherwise incentivized activity).

googletag.events

This is the namespace that GPT uses for Events. Your code can react to these events using Service.addEventListener.
ইন্টারফেস
Event
Base Interface for all GPT events.
Event Type Map
This is a pseudo-type that maps an event name to its corresponding event object type for Service.addEventListener and Service.removeEventListener .
Game Manual Interstitial Slot Closed Event
This event is fired when a game manual interstitial slot has been closed by the user.
Game Manual Interstitial Slot Ready Event
This event is fired when a game manual interstitial slot is ready to be shown to the user.
Impression Viewable Event
This event is fired when an impression becomes viewable, according to the Active View criteria .
Rewarded Slot Closed Event
This event is fired when a rewarded ad slot is closed by the user.
Rewarded Slot Granted Event
This event is fired when a reward is granted for viewing a rewarded ad .
Rewarded Slot Ready Event
This event is fired when a rewarded ad is ready to be displayed.
Rewarded Slot Video Completed Event
This event is fired when a rewarded video ad has finished playing.
Slot Onload Event
This event is fired when the creative's iframe fires its load event.
Slot Render Ended Event
This event is fired when the creative code is injected into a slot.
Slot Requested Event
This event is fired when an ad has been requested for a particular slot.
Slot Response Received
This event is fired when an ad response has been received for a particular slot.
Slot Visibility Changed Event
This event is fired whenever the on-screen percentage of an ad slot's area changes.

googletag.events.Event

Base Interface for all GPT events. All GPT events below will have the following fields.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
আরও দেখুন

বৈশিষ্ট্য


serviceName

serviceName : string
Name of the service that triggered the event.

স্লট

slot : Slot
The slot that triggered the event.

googletag.events.EventTypeMap

This is a pseudo-type that maps an event name to its corresponding event object type for Service.addEventListener and Service.removeEventListener . It is documented for reference and type safety purposes only.
বৈশিষ্ট্য
game Manual Interstitial Slot Closed
game Manual Interstitial Slot Ready
impression Viewable
rewarded Slot Closed
rewarded Slot Granted
rewarded Slot Ready
rewarded Slot Video Completed
slot Onload
slot Render Ended
slot Requested
slot Response Received
slot Visibility Changed

বৈশিষ্ট্য


gameManualInterstitialSlotClosed


gameManualInterstitialSlotReady


impressionViewable

impressionViewable : ImpressionViewableEvent
Alias for events.ImpressionViewableEvent .

rewardedSlotClosed

rewardedSlotClosed : RewardedSlotClosedEvent
Alias for events.RewardedSlotClosedEvent .

rewardedSlotGranted

rewardedSlotGranted : RewardedSlotGrantedEvent
Alias for events.RewardedSlotGrantedEvent .

rewardedSlotReady

rewardedSlotReady : RewardedSlotReadyEvent
Alias for events.RewardedSlotReadyEvent .

rewardedSlotVideoCompleted


slotOnload

slotOnload : SlotOnloadEvent
Alias for events.SlotOnloadEvent .

slotRenderEnded

slotRenderEnded : SlotRenderEndedEvent
Alias for events.SlotRenderEndedEvent .

slotRequested

slotRequested : SlotRequestedEvent
Alias for events.SlotRequestedEvent .

slotResponseReceived

slotResponseReceived : SlotResponseReceived
Alias for events.SlotResponseReceived .

slotVisibilityChanged


googletag.events.GameManualInterstitialSlotClosedEvent

Extends Event
This event is fired when a game manual interstitial slot has been closed by the user.

Note: Game manual interstitial is a limited-access format.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
উদাহরণ

জাভাস্ক্রিপ্ট

// This listener is called when a game manual interstitial slot is closed.
const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
);

// Slot returns null if the page or device does not support game manual interstitial ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", (event) => {
    const slot = event.slot;
    console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

JavaScript (legacy)

// This listener is called when a game manual interstitial slot is closed.
var targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
);

// Slot returns null if the page or device does not support game manual interstitial ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", function (event) {
    var slot = event.slot;
    console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

টাইপস্ক্রিপ্ট

// This listener is called when a game manual interstitial slot is closed.
const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
);

// Slot returns null if the page or device does not support game manual interstitial ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", (event) => {
    const slot = event.slot;
    console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}
আরও দেখুন

googletag.events.GameManualInterstitialSlotReadyEvent

Extends Event
This event is fired when a game manual interstitial slot is ready to be shown to the user.

Note: Game manual interstitial is a limited-access format.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
পদ্ধতি
make Game Manual Interstitial Visible
Displays the game manual interstitial ad to the user.
উদাহরণ

জাভাস্ক্রিপ্ট

// This listener is called when a game manual interstitial slot is ready to
// be displayed.
const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
);

// Slot returns null if the page or device does not support game manual interstitial ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  googletag.pubads().addEventListener("gameManualInterstitialSlotReady", (event) => {
    const slot = event.slot;
    console.log(
      "Game manual interstital slot",
      slot.getSlotElementId(),
      "is ready to be displayed.",
    );

    // Replace with custom logic.
    const displayGmiAd = true;
    if (displayGmiAd) {
      event.makeGameManualInterstitialVisible();
    }

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

JavaScript (legacy)

// This listener is called when a game manual interstitial slot is ready to
// be displayed.
var targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
);

// Slot returns null if the page or device does not support game manual interstitial ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  googletag.pubads().addEventListener("gameManualInterstitialSlotReady", function (event) {
    var slot = event.slot;
    console.log(
      "Game manual interstital slot",
      slot.getSlotElementId(),
      "is ready to be displayed.",
    );

    // Replace with custom logic.
    var displayGmiAd = true;
    if (displayGmiAd) {
      event.makeGameManualInterstitialVisible();
    }

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

টাইপস্ক্রিপ্ট

// This listener is called when a game manual interstitial slot is ready to
// be displayed.
const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
);

// Slot returns null if the page or device does not support game manual interstitial ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  googletag.pubads().addEventListener("gameManualInterstitialSlotReady", (event) => {
    const slot = event.slot;
    console.log(
      "Game manual interstital slot",
      slot.getSlotElementId(),
      "is ready to be displayed.",
    );

    // Replace with custom logic.
    const displayGmiAd = true;
    if (displayGmiAd) {
      event.makeGameManualInterstitialVisible();
    }

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}
আরও দেখুন

পদ্ধতি


makeGameManualInterstitialVisible

makeGameManualInterstitialVisible ( ) : boolean
Displays the game manual interstitial ad to the user. Returns whether the ad was successfully displayed.
ফেরত
boolean

googletag.events.ImpressionViewableEvent

Extends Event
This event is fired when an impression becomes viewable, according to the Active View criteria .
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
উদাহরণ

জাভাস্ক্রিপ্ট

// This listener is called when an impression becomes viewable.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("impressionViewable", (event) => {
  const slot = event.slot;
  console.log("Impression for slot", slot.getSlotElementId(), "became viewable.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// This listener is called when an impression becomes viewable.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("impressionViewable", function (event) {
  var slot = event.slot;
  console.log("Impression for slot", slot.getSlotElementId(), "became viewable.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

টাইপস্ক্রিপ্ট

// 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

Extends Event
This event is fired when a rewarded ad slot is closed by the user. It may fire either before or after a reward has been granted. To determine whether a reward has been granted, use events.RewardedSlotGrantedEvent instead.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
উদাহরণ

জাভাস্ক্রিপ্ট

const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called when the user closes a rewarded ad slot.
  googletag.pubads().addEventListener("rewardedSlotClosed", (event) => {
    const slot = event.slot;
    console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

JavaScript (legacy)

var targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called when the user closes a rewarded ad slot.
  googletag.pubads().addEventListener("rewardedSlotClosed", function (event) {
    var slot = event.slot;
    console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

টাইপস্ক্রিপ্ট

const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called when the user closes a rewarded ad slot.
  googletag.pubads().addEventListener("rewardedSlotClosed", (event) => {
    const slot = event.slot;
    console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}
আরও দেখুন

googletag.events.RewardedSlotGrantedEvent

Extends Event
This event is fired when a reward is granted for viewing a rewarded ad . If the ad is closed before the criteria for granting a reward is met, this event will not fire.
বৈশিষ্ট্য
payload
An object containing information about the reward that was granted.
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
উদাহরণ

জাভাস্ক্রিপ্ট

const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called whenever a reward is granted for a
  // rewarded ad.
  googletag.pubads().addEventListener("rewardedSlotGranted", (event) => {
    const slot = event.slot;
    console.group("Reward granted for slot", slot.getSlotElementId(), ".");

    // Log details of the reward.
    console.log("Reward type:", event.payload?.type);
    console.log("Reward amount:", event.payload?.amount);
    console.groupEnd();

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

JavaScript (legacy)

var targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called whenever a reward is granted for a
  // rewarded ad.
  googletag.pubads().addEventListener("rewardedSlotGranted", function (event) {
    var _a, _b;
    var slot = event.slot;
    console.group("Reward granted for slot", slot.getSlotElementId(), ".");

    // Log details of the reward.
    console.log("Reward type:", (_a = event.payload) === null || _a === void 0 ? void 0 : _a.type);
    console.log(
      "Reward amount:",
      (_b = event.payload) === null || _b === void 0 ? void 0 : _b.amount,
    );
    console.groupEnd();

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

টাইপস্ক্রিপ্ট

const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called whenever a reward is granted for a
  // rewarded ad.
  googletag.pubads().addEventListener("rewardedSlotGranted", (event) => {
    const slot = event.slot;
    console.group("Reward granted for slot", slot.getSlotElementId(), ".");

    // Log details of the reward.
    console.log("Reward type:", event.payload?.type);
    console.log("Reward amount:", event.payload?.amount);
    console.groupEnd();

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}
আরও দেখুন

বৈশিষ্ট্য


পেলোড

payload : RewardedPayload
An object containing information about the reward that was granted.

googletag.events.RewardedSlotReadyEvent

Extends Event
This event is fired when a rewarded ad is ready to be displayed. The publisher is responsible for presenting the user an option to view the ad before displaying it.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
পদ্ধতি
make Rewarded Visible
Displays the rewarded ad.
উদাহরণ

জাভাস্ক্রিপ্ট

// This listener is called when a rewarded ad slot becomes ready to be
// displayed.
const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called whenever a reward is granted for a
  // rewarded ad.
  googletag.pubads().addEventListener("rewardedSlotReady", (event) => {
    const slot = event.slot;
    console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed.");

    // Replace with custom logic.
    const userHasConsented = true;
    if (userHasConsented) {
      event.makeRewardedVisible();
    }

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

JavaScript (legacy)

// This listener is called when a rewarded ad slot becomes ready to be
// displayed.
var targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called whenever a reward is granted for a
  // rewarded ad.
  googletag.pubads().addEventListener("rewardedSlotReady", function (event) {
    var slot = event.slot;
    console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed.");

    // Replace with custom logic.
    var userHasConsented = true;
    if (userHasConsented) {
      event.makeRewardedVisible();
    }

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

TypeScript

// This listener is called when a rewarded ad slot becomes ready to be
// displayed.
const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called whenever a reward is granted for a
  // rewarded ad.
  googletag.pubads().addEventListener("rewardedSlotReady", (event) => {
    const slot = event.slot;
    console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed.");

    // Replace with custom logic.
    const userHasConsented = true;
    if (userHasConsented) {
      event.makeRewardedVisible();
    }

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}
আরও দেখুন

পদ্ধতি


makeRewardedVisible

makeRewardedVisible ( ) : boolean
Displays the rewarded ad. This method should not be called until the user has consented to view the ad.
ফেরত
boolean Whether the rewarded ad was successfully displayed.

googletag.events.RewardedSlotVideoCompletedEvent

Extends Event
This event is fired when a rewarded video ad has finished playing.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
উদাহরণ

জাভাস্ক্রিপ্ট

const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called when the video in a rewarded ad slot has
  // finished playing.
  googletag.pubads().addEventListener("rewardedSlotVideoCompleted", (event) => {
    const slot = event.slot;
    console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

JavaScript (legacy)

var targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called when the video in a rewarded ad slot has
  // finished playing.
  googletag.pubads().addEventListener("rewardedSlotVideoCompleted", function (event) {
    var slot = event.slot;
    console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

TypeScript

const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called when the video in a rewarded ad slot has
  // finished playing.
  googletag.pubads().addEventListener("rewardedSlotVideoCompleted", (event) => {
    const slot = event.slot;
    console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}
আরও দেখুন

googletag.events.SlotOnloadEvent

Extends Event
This event is fired when the creative's iframe fires its load event. When rendering rich media ads in sync rendering mode, no iframe is used so no SlotOnloadEvent will be fired.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
উদাহরণ

জাভাস্ক্রিপ্ট

// This listener is called when a creative iframe load event fires.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", (event) => {
  const slot = event.slot;
  console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// This listener is called when a creative iframe load event fires.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", function (event) {
  var slot = event.slot;
  console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when a creative iframe load event fires.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", (event) => {
  const slot = event.slot;
  console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
আরও দেখুন

googletag.events.SlotRenderEndedEvent

Extends Event
This event is fired when the creative code is injected into a slot. This event will occur before the creative's resources are fetched, so the creative may not be visible yet. If you need to know when all creative resources for a slot have finished loading, consider the events.SlotOnloadEvent instead.
বৈশিষ্ট্য
advertiser Id
Advertiser ID of the rendered ad.
campaign Id
Campaign ID of the rendered ad.
company Ids
IDs of the companies that bid on the rendered backfill ad.
creative Id
Creative ID of the rendered reservation ad.
creative Template Id
Creative template ID of the rendered reservation ad.
is Backfill
Whether an ad was a backfill ad.
is Empty
Whether an ad was returned for the slot.
label Ids
Deprecated.
line Item Id
Line item ID of the rendered reservation ad.
response Identifier
The response identifier is a unique identifier for the ad response.
service Name
Name of the service that triggered the event.
size
Indicates the pixel size of the rendered creative.
slot
The slot that triggered the event.
slot Content Changed
Whether the slot content was changed with the rendered ad.
source Agnostic Creative Id
Creative ID of the rendered reservation or backfill ad.
source Agnostic Line Item Id
Line item ID of the rendered reservation or backfill ad.
yield Group Ids
IDs of the yield groups for the rendered backfill ad.
উদাহরণ

জাভাস্ক্রিপ্ট

// This listener is called when a slot has finished rendering.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRenderEnded", (event) => {
  const slot = event.slot;
  console.group("Slot", slot.getSlotElementId(), "finished rendering.");

  // Log details of the rendered ad.
  console.log("Advertiser ID:", event.advertiserId);
  console.log("Campaign ID:", event.campaignId);
  console.log("Company IDs:", event.companyIds);
  console.log("Creative ID:", event.creativeId);
  console.log("Creative Template ID:", event.creativeTemplateId);
  console.log("Is backfill?:", event.isBackfill);
  console.log("Is empty?:", event.isEmpty);
  console.log("Line Item ID:", event.lineItemId);
  console.log("Size:", event.size);
  console.log("Slot content changed?", event.slotContentChanged);
  console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId);
  console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId);
  console.log("Yield Group IDs:", event.yieldGroupIds);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// This listener is called when a slot has finished rendering.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRenderEnded", function (event) {
  var slot = event.slot;
  console.group("Slot", slot.getSlotElementId(), "finished rendering.");

  // Log details of the rendered ad.
  console.log("Advertiser ID:", event.advertiserId);
  console.log("Campaign ID:", event.campaignId);
  console.log("Company IDs:", event.companyIds);
  console.log("Creative ID:", event.creativeId);
  console.log("Creative Template ID:", event.creativeTemplateId);
  console.log("Is backfill?:", event.isBackfill);
  console.log("Is empty?:", event.isEmpty);
  console.log("Line Item ID:", event.lineItemId);
  console.log("Size:", event.size);
  console.log("Slot content changed?", event.slotContentChanged);
  console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId);
  console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId);
  console.log("Yield Group IDs:", event.yieldGroupIds);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when a slot has finished rendering.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRenderEnded", (event) => {
  const slot = event.slot;
  console.group("Slot", slot.getSlotElementId(), "finished rendering.");

  // Log details of the rendered ad.
  console.log("Advertiser ID:", event.advertiserId);
  console.log("Campaign ID:", event.campaignId);
  console.log("Company IDs:", event.companyIds);
  console.log("Creative ID:", event.creativeId);
  console.log("Creative Template ID:", event.creativeTemplateId);
  console.log("Is backfill?:", event.isBackfill);
  console.log("Is empty?:", event.isEmpty);
  console.log("Line Item ID:", event.lineItemId);
  console.log("Size:", event.size);
  console.log("Slot content changed?", event.slotContentChanged);
  console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId);
  console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId);
  console.log("Yield Group IDs:", event.yieldGroupIds);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
আরও দেখুন

বৈশিষ্ট্য


advertiserId

advertiserId : number
Advertiser ID of the rendered ad. Value is null for empty slots, backfill ads, and creatives rendered by services other than PubAdsService .

campaignId

campaignId : number
Campaign ID of the rendered ad. Value is null for empty slots, backfill ads, and creatives rendered by services other than PubAdsService .

companyIds

companyIds : number []
IDs of the companies that bid on the rendered backfill ad. Value is null for empty slots, reservation ads, and creatives rendered by services other than PubAdsService .

creativeId

creativeId : number
Creative ID of the rendered reservation ad. Value is null for empty slots, backfill ads, and creatives rendered by services other than PubAdsService .

creativeTemplateId

creativeTemplateId : number
Creative template ID of the rendered reservation ad. Value is null for empty slots, backfill ads, and creatives rendered by services other than PubAdsService .

isBackfill

isBackfill : boolean
Whether an ad was a backfill ad. Value is true if the ad was a backfill ad, false otherwise.

isEmpty

isEmpty : boolean
Whether an ad was returned for the slot. Value is true if no ad was returned, false otherwise.

labelIds

labelIds : number []

lineItemId

lineItemId : number
Line item ID of the rendered reservation ad. Value is null for empty slots, backfill ads, and creatives rendered by services other than PubAdsService .

responseIdentifier

responseIdentifier : string
The response identifier is a unique identifier for the ad response. This value can be used to identify and block the ad in the Ad Review Center (ARC) .

আকার

size : string | number []
Indicates the pixel size of the rendered creative. Example: [728, 90] . Value is null for empty ad slots.

slotContentChanged

slotContentChanged : boolean
Whether the slot content was changed with the rendered ad. Value is true if the content was changed, false otherwise.

sourceAgnosticCreativeId

sourceAgnosticCreativeId : number
Creative ID of the rendered reservation or backfill ad. Value is null if the ad is not a reservation or line item backfill, or the creative is rendered by services other than PubAdsService .

sourceAgnosticLineItemId

sourceAgnosticLineItemId : number
Line item ID of the rendered reservation or backfill ad. Value is null if the ad is not a reservation or line item backfill, or the creative is rendered by services other than PubAdsService .

yieldGroupIds

yieldGroupIds : number []
IDs of the yield groups for the rendered backfill ad. Value is null for empty slots, reservation ads, and creatives rendered by services other than PubAdsService .

googletag.events.SlotRequestedEvent

Extends Event
This event is fired when an ad has been requested for a particular slot.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
উদাহরণ

জাভাস্ক্রিপ্ট

// This listener is called when the specified service issues an ad
// request for a slot. Each slot will fire this event, even though they
// may be batched together in a single request if single request
// architecture (SRA) is enabled.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRequested", (event) => {
  const slot = event.slot;
  console.log("Slot", slot.getSlotElementId(), "has been requested.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// This listener is called when the specified service issues an ad
// request for a slot. Each slot will fire this event, even though they
// may be batched together in a single request if single request
// architecture (SRA) is enabled.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRequested", function (event) {
  var slot = event.slot;
  console.log("Slot", slot.getSlotElementId(), "has been requested.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when the specified service issues an ad
// request for a slot. Each slot will fire this event, even though they
// may be batched together in a single request if single request
// architecture (SRA) is enabled.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRequested", (event) => {
  const slot = event.slot;
  console.log("Slot", slot.getSlotElementId(), "has been requested.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
আরও দেখুন

googletag.events.SlotResponseReceived

Extends Event
This event is fired when an ad response has been received for a particular slot.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
উদাহরণ

জাভাস্ক্রিপ্ট

// This listener is called when an ad response has been received
// for a slot.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotResponseReceived", (event) => {
  const slot = event.slot;
  console.log("Ad response for slot", slot.getSlotElementId(), "received.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// This listener is called when an ad response has been received
// for a slot.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotResponseReceived", function (event) {
  var slot = event.slot;
  console.log("Ad response for slot", slot.getSlotElementId(), "received.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when an ad response has been received
// for a slot.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotResponseReceived", (event) => {
  const slot = event.slot;
  console.log("Ad response for slot", slot.getSlotElementId(), "received.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
আরও দেখুন

googletag.events.SlotVisibilityChangedEvent

Extends Event
This event is fired whenever the on-screen percentage of an ad slot's area changes. The event is throttled and will not fire more often than once every 200ms.
বৈশিষ্ট্য
in View Percentage
The percentage of the ad's area that is visible.
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
উদাহরণ

জাভাস্ক্রিপ্ট

// This listener is called whenever the on-screen percentage of an
// ad slot's area changes.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotVisibilityChanged", (event) => {
  const slot = event.slot;
  console.group("Visibility of slot", slot.getSlotElementId(), "changed.");

  // Log details of the event.
  console.log("Visible area:", `${event.inViewPercentage}%`);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// This listener is called whenever the on-screen percentage of an
// ad slot's area changes.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotVisibilityChanged", function (event) {
  var slot = event.slot;
  console.group("Visibility of slot", slot.getSlotElementId(), "changed.");

  // Log details of the event.
  console.log("Visible area:", "".concat(event.inViewPercentage, "%"));
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called whenever the on-screen percentage of an
// ad slot's area changes.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotVisibilityChanged", (event) => {
  const slot = event.slot;
  console.group("Visibility of slot", slot.getSlotElementId(), "changed.");

  // Log details of the event.
  console.log("Visible area:", `${event.inViewPercentage}%`);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
আরও দেখুন

বৈশিষ্ট্য


inViewPercentage

inViewPercentage : number
The percentage of the ad's area that is visible. Value is a number between 0 and 100.

googletag.secureSignals

This is the namespace that GPT uses for managing secure signals.
ইন্টারফেস
Bidder Signal Provider
Returns a secure signal for a specific bidder.
Publisher Signal Provider
Returns a secure signal for a specific publisher.
Secure Signal Providers Array
An interface for managing secure signals.
Type Aliases
Secure Signal Provider
Interface for returning a secure signal for a specific bidder or provider.

Type Aliases


SecureSignalProvider

Interface for returning a secure signal for a specific bidder or provider. One of id or networkCode must be provided, but not both.

googletag.secureSignals.BidderSignalProvider

Returns a secure signal for a specific bidder.

A bidder secure signal provider consists of 2 parts:

  1. A collector function, which returns a Promise that resolves to a secure signal.
  2. An id which identifies the bidder associated with the signal.
To return a secure signal for a publisher, use secureSignals.PublisherSignalProvider instead.
বৈশিষ্ট্য
collector Function
A function which returns a Promise that resolves to a secure signal.
id
A unique identifier for the collector associated with this secure signal, as registered in Google Ad Manager.
উদাহরণ

জাভাস্ক্রিপ্ট

// id is provided
googletag.secureSignalProviders.push({
  id: "collector123",
  collectorFunction: () => {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});

JavaScript (legacy)

// id is provided
googletag.secureSignalProviders.push({
  id: "collector123",
  collectorFunction: function () {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});

TypeScript

// id is provided
googletag.secureSignalProviders!.push({
  id: "collector123",
  collectorFunction: () => {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});
আরও দেখুন

বৈশিষ্ট্য


collectorFunction

collectorFunction : ( ( ) => Promise < string > )
A function which returns a Promise that resolves to a secure signal.

আইডি

id : string
A unique identifier for the collector associated with this secure signal, as registered in Google Ad Manager.

googletag.secureSignals.PublisherSignalProvider

Returns a secure signal for a specific publisher.

A publisher signal provider consists of 2 parts:

  1. A collector function, which returns a Promise that resolves to a secure signal.
  2. A networkCode which identifies the publisher associated with the signal.
To return a secure signal for a bidder, use secureSignals.BidderSignalProvider instead.
বৈশিষ্ট্য
collector Function
A function which returns a Promise that resolves to a secure signal.
network Code
The network code (as seen in the ad unit path) for the publisher associated with this secure signal.
উদাহরণ

জাভাস্ক্রিপ্ট

// networkCode is provided
googletag.secureSignalProviders.push({
  networkCode: "123456",
  collectorFunction: () => {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});

JavaScript (legacy)

// networkCode is provided
googletag.secureSignalProviders.push({
  networkCode: "123456",
  collectorFunction: function () {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});

TypeScript

// networkCode is provided
googletag.secureSignalProviders!.push({
  networkCode: "123456",
  collectorFunction: () => {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});
আরও দেখুন

বৈশিষ্ট্য


collectorFunction

collectorFunction : ( ( ) => Promise < string > )
A function which returns a Promise that resolves to a secure signal.

networkCode

networkCode : string
The network code (as seen in the ad unit path) for the publisher associated with this secure signal.

googletag.secureSignals.SecureSignalProvidersArray

An interface for managing secure signals.
পদ্ধতি
clear All Cache
Clears all signals for all collectors from cache.
push
Adds a new secureSignals.SecureSignalProvider to the signal provider array and begins the signal generation process.

পদ্ধতি


clearAllCache

clearAllCache ( ) : void
Clears all signals for all collectors from cache.

Calling this method may reduce the likelihood of signals being included in ad requests for the current and potentially later page views. Due to this, it should only be called when meaningful state changes occur, such as events that indicate a new user (log in, log out, sign up, etc.).

ধাক্কা

push ( provider : SecureSignalProvider ) : void
Adds a new secureSignals.SecureSignalProvider to the signal provider array and begins the signal generation process.
Parameters
provider : SecureSignalProvider The secureSignals.SecureSignalProvider object to be added to the array.
,

This reference uses TypeScript notation to describe types. The following table provides a brief explanation by example.

Type expression
string The primitive string type.
string[] An array type, where values may only be strings.
number | string A union type, where the value may be either a number or a string.
Array<number | string> An array type, where values are a complex (union) type.
[number, string] A tuple type, where the value is a two-element array that must contain a number and a string in that order.
Slot An object type, where the value is an instance of googletag.Slot .
() => void A function type with no defined arguments and no return value.

To learn more about supported types and type expressions, refer to the TypeScript Handbook .

Type annotations

A colon after a variable, parameter name, property name, or function signature denotes a type annotation. Type annotations describe the types the element to the left of the colon can accept or return. The following table shows examples of type annotations you may see in this reference.

Type annotation
param: string Indicates that param accepts or returns a string value. This syntax is used for variables, parameters, properties, and return types.
param?: number | string Indicates that param is optional, but accepts either a number or a string when specified. This syntax is used for parameters and properties.
...params: Array<() => void> Indicates that params is a rest parameter that accepts functions. Rest parameters accept an unbounded number of values of the specified type.

googletag

The global namespace the Google Publisher Tag uses for its API.
নেমস্পেস
config
Main configuration interface for page-level settings.
enums
This is the namespace that GPT uses for enum types.
events
This is the namespace that GPT uses for Events.
secure Signals
This is the namespace that GPT uses for managing secure signals.
ইন্টারফেস
Command Array
The command array accepts a sequence of functions and invokes them in order.
Companion Ads Service
Companion Ads service.
Privacy Settings Config
Configuration object for privacy settings.
Pub Ads Service
Publisher Ads service.
Response Information
An object representing a single ad response.
Rewarded Payload
An object representing the reward associated with a rewarded ad .
Service
Base service class that contains methods common for all services.
Size Mapping Builder
Builder for size mapping specification objects.
Slot
Slot is an object representing a single ad slot on a page.
Type Aliases
Fluid Size
The size string where the ad container takes 100% width of its parent div and then resizes its height to fit the creative content.
General Size
A valid size configuration for a slot, which can be one or multiple sizes.
Multi Size
A list of single valid sizes.
Named Size
Named sizes that a slot can have.
Single Size
A single valid size for a slot.
Single Size Array
Array of two numbers representing [width, height].
Size Mapping
A mapping of viewport size to ad sizes.
Size Mapping Array
A list of size mappings.
ভেরিয়েবল
api Ready
Flag indicating that the GPT API is loaded and ready to be called.
cmd
Reference to the global command queue for asynchronous execution of GPT-related calls.
pubads Ready
Flag indicating that PubAdsService is enabled, loaded and fully operational.
secure Signal Providers
Reference to the secure signal providers array.
কার্যাবলী
companion Ads
Returns a reference to the CompanionAdsService .
define Out Of Page Slot
Constructs an out-of-page ad slot with the given ad unit path.
define Slot
Constructs an ad slot with a given ad unit path and size and associates it with the ID of a div element on the page that will contain the ad.
destroy Slots
Destroys the given slots, removing all related objects and references of those slots from GPT.
disable Publisher Console
Disables the Google Publisher Console.
display
Instructs slot services to render the slot.
enable Services
Enables all GPT services that have been defined for ad slots on the page.
get Config
Gets a frozen copy of the general configuration options for the page set by setConfig .
get Version
Returns the current version of GPT.
open Console
Opens the Google Publisher Console.
pubads
Returns a reference to the PubAdsService .
set Ad Iframe Title
Sets the title for all ad container iframes created by PubAdsService , from this point onwards.
set Config
Sets general configuration options for the page.
size Mapping
Creates a new SizeMappingBuilder .

Type Aliases


FluidSize

FluidSize : "fluid"
The size string where the ad container takes 100% width of its parent div and then resizes its height to fit the creative content. Similar to how regular block elements on a page behave. Used for native ads (see related article ).

GeneralSize

GeneralSize : SingleSize | MultiSize
A valid size configuration for a slot, which can be one or multiple sizes.

MultiSize

MultiSize : SingleSize []
A list of single valid sizes.

NamedSize

NamedSize : FluidSize | [ FluidSize ]
Named sizes that a slot can have. In most cases size is a fixed-size rectangle but there are some cases when we need other kinds of size specifications. Only the following are valid named sizes:
  • fluid : the ad container takes 100% width of its parent div and then resizes its height to fit the creative content. Similar to how regular block elements on a page behave. Used for native ads (see related article ). Note that both fluid and ['fluid'] are acceptable forms to declare a slot size as fluid.

SingleSize

SingleSize : SingleSizeArray | NamedSize
A single valid size for a slot.

SingleSizeArray

SingleSizeArray : [ number , number ]
Array of two numbers representing [width, height].

SizeMapping

SizeMapping : [ SingleSizeArray , GeneralSize ]
A mapping of viewport size to ad sizes. Used for responsive ads.

SizeMappingArray

SizeMappingArray : SizeMapping []
A list of size mappings.

ভেরিয়েবল


Const apiReady

apiReady : boolean | undefined
Flag indicating that the GPT API is loaded and ready to be called. This property will be simply undefined until the API is ready.

Note that the recommended way of handling async is to use googletag.cmd to queue callbacks for when GPT is ready. These callbacks do not have to check googletag.apiReady as they are guaranteed to execute once the API is set up.

Const cmd

cmd : ( ( this : typeof globalThis ) => void ) [] | CommandArray
Reference to the global command queue for asynchronous execution of GPT-related calls.

The googletag.cmd variable is initialized to an empty JavaScript array by the GPT tag syntax on the page, and cmd.push is the standard Array.push method that adds an element to the end of the array. When the GPT JavaScript is loaded, it looks through the array and executes all the functions in order. The script then replaces cmd with a CommandArray object whose push method is defined to execute the function argument passed to it. This mechanism allows GPT to reduce perceived latency by fetching the JavaScript asynchronously while allowing the browser to continue rendering the page.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.cmd.push(() => {
  googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads());
});

JavaScript (legacy)

googletag.cmd.push(function () {
  googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads());
});

TypeScript

googletag.cmd.push(() => {
  googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads());
});

Const pubadsReady

pubadsReady : boolean | undefined
Flag indicating that PubAdsService is enabled, loaded and fully operational. This property will be simply undefined until enableServices is called and PubAdsService is loaded and initialized.

secureSignalProviders

secureSignalProviders : SecureSignalProvider [] | SecureSignalProvidersArray | undefined
Reference to the secure signal providers array.

The secure signal providers array accepts a sequence of signal-generating functions and invokes them in order. It is intended to replace a standard array that is used to enqueue signal-generating functions to be invoked once GPT is loaded.
উদাহরণ

জাভাস্ক্রিপ্ট

window.googletag = window.googletag || { cmd: [] };
googletag.secureSignalProviders = googletag.secureSignalProviders || [];
googletag.secureSignalProviders.push({
  id: "collector123",
  collectorFunction: () => {
    return Promise.resolve("signal");
  },
});

JavaScript (legacy)

window.googletag = window.googletag || { cmd: [] };
googletag.secureSignalProviders = googletag.secureSignalProviders || [];
googletag.secureSignalProviders.push({
  id: "collector123",
  collectorFunction: function () {
    return Promise.resolve("signal");
  },
});

TypeScript

window.googletag = window.googletag || { cmd: [] };
googletag.secureSignalProviders = googletag.secureSignalProviders || [];
googletag.secureSignalProviders.push({
  id: "collector123",
  collectorFunction: () => {
    return Promise.resolve("signal");
  },
});
আরও দেখুন

কার্যাবলী


companionAds

companionAds ( ) : CompanionAdsService
Returns a reference to the CompanionAdsService .
ফেরত
CompanionAdsService The Companion Ads service.

defineOutOfPageSlot

defineOutOfPageSlot ( adUnitPath : string , div ?: string | OutOfPageFormat ) : Slot | null
Constructs an out-of-page ad slot with the given ad unit path.

For custom out-of-page ads, div is the ID of the div element that will contain the ad. See the article on out-of-page creatives for more details.

For GPT managed out-of-page ads, div is a supported OutOfPageFormat .
উদাহরণ

জাভাস্ক্রিপ্ট

// Define a custom out-of-page ad slot.
googletag.defineOutOfPageSlot("/1234567/sports", "div-1");

// Define a GPT managed web interstitial ad slot.
googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);

JavaScript (legacy)

// Define a custom out-of-page ad slot.
googletag.defineOutOfPageSlot("/1234567/sports", "div-1");

// Define a GPT managed web interstitial ad slot.
googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);

TypeScript

// Define a custom out-of-page ad slot.
googletag.defineOutOfPageSlot("/1234567/sports", "div-1");

// Define a GPT managed web interstitial ad slot.
googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
আরও দেখুন
Parameters
adUnitPath : string Full ad unit path with the network code and ad unit code.
Optional div : string | OutOfPageFormat ID of the div that will contain this ad unit or OutOfPageFormat.
ফেরত
Slot | null The newly created slot, or null if a slot cannot be created.

defineSlot

defineSlot ( adUnitPath : string , size : GeneralSize , div ?: string ) : Slot | null
Constructs an ad slot with a given ad unit path and size and associates it with the ID of a div element on the page that will contain the ad.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.defineSlot("/1234567/sports", [728, 90], "div-1");

JavaScript (legacy)

googletag.defineSlot("/1234567/sports", [728, 90], "div-1");

TypeScript

googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
আরও দেখুন
Parameters
adUnitPath : string Full ad unit path with the network code and unit code.
size : GeneralSize Width and height of the added slot. This is the size that is used in the ad request if no responsive size mapping is provided or the size of the viewport is smaller than the smallest size provided in the mapping.
Optional div : string ID of the div that will contain this ad unit.
ফেরত
Slot | null The newly created slot, or null if a slot cannot be created.

destroySlots

destroySlots ( slots ?: Slot [] ) : boolean
Destroys the given slots, removing all related objects and references of those slots from GPT. This API does not support passback slots and companion slots.

Calling this API on a slot clears the ad and removes the slot object from the internal state maintained by GPT. Calling any more functions on the slot object will result in undefined behavior. Note the browser may still not free the memory associated with that slot if a reference to it is maintained by the publisher page. Calling this API makes the div associated with that slot available for reuse.

In particular, destroying a slot removes the ad from GPT's long-lived pageview , so future requests will not be influenced by roadblocks or competitive exclusions involving this ad. Failure to call this function before removing a slot's div from the page will result in undefined behavior.
উদাহরণ

জাভাস্ক্রিপ্ট

// The calls to construct an ad and display contents.
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
googletag.display("div-1");
const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2");
googletag.display("div-2");

// This call to destroy only slot1.
googletag.destroySlots([slot1]);

// This call to destroy both slot1 and slot2.
googletag.destroySlots([slot1, slot2]);

// This call to destroy all slots.
googletag.destroySlots();

JavaScript (legacy)

// The calls to construct an ad and display contents.
var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
googletag.display("div-1");
var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2");
googletag.display("div-2");

// This call to destroy only slot1.
googletag.destroySlots([slot1]);

// This call to destroy both slot1 and slot2.
googletag.destroySlots([slot1, slot2]);

// This call to destroy all slots.
googletag.destroySlots();

TypeScript

// The calls to construct an ad and display contents.
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!;
googletag.display("div-1");
const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!;
googletag.display("div-2");

// This call to destroy only slot1.
googletag.destroySlots([slot1]);

// This call to destroy both slot1 and slot2.
googletag.destroySlots([slot1, slot2]);

// This call to destroy all slots.
googletag.destroySlots();
Parameters
Optional slots : Slot [] The array of slots to destroy. Array is optional; all slots will be destroyed if it is unspecified.
ফেরত
boolean true if slots have been destroyed, false otherwise.

disablePublisherConsole

disablePublisherConsole ( ) : void
Disables the Google Publisher Console.
আরও দেখুন

প্রদর্শন

display ( divOrSlot : string | Element | Slot ) : void
Instructs slot services to render the slot. Each ad slot should only be displayed once per page. All slots must be defined and have a service associated with them before being displayed. The display call must not happen until the element is present in the DOM. The usual way to achieve that is to place it within a script block within the div element named in the method call.

If single request architecture (SRA) is being used, all unfetched ad slots at the time this method is called will be fetched at once. To force an ad slot not to display, the entire div must be removed.
আরও দেখুন
Parameters
divOrSlot : string | Element | Slot Either the ID of the div element containing the ad slot or the div element, or the slot object. If a div element is provided, it must have an 'id' attribute which matches the ID passed into defineSlot .

enableServices

enableServices ( ) : void
Enables all GPT services that have been defined for ad slots on the page.

getConfig

getConfig ( keys : string | string [] ) : Readonly < Pick < PageSettingsConfig , "adsenseAttributes" | "disableInitialLoad" | "targeting" > >
Gets a frozen copy of the general configuration options for the page set by setConfig .

Not all setConfig() properties are supported by this method. Supported properties are:
উদাহরণ

জাভাস্ক্রিপ্ট

// Get the value of the `targeting` setting.
const targetingConfig = googletag.getConfig("targeting");

// Get the value of the `adsenseAttributes` and `disableInitialLoad` settings.
const config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);

JavaScript (legacy)

// Get the value of the `targeting` setting.
var targetingConfig = googletag.getConfig("targeting");

// Get the value of the `adsenseAttributes` and `disableInitialLoad` settings.
var config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);

TypeScript

// Get the value of the `targeting` setting.
const targetingConfig = googletag.getConfig("targeting");

// Get the value of the `adsenseAttributes` and `disableInitialLoad` settings.
const config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
Parameters
keys : string | string [] The keys of the configuration options to get.
ফেরত
Readonly < Pick < PageSettingsConfig , "adsenseAttributes" | "disableInitialLoad" | "targeting" > > A frozen copy of the configuration options for the page.

getVersion

getVersion ( ) : string
Returns the current version of GPT.
আরও দেখুন
ফেরত
string The currently executing GPT version string.

openConsole

openConsole ( div ?: string ) : void
Opens the Google Publisher Console.
উদাহরণ

জাভাস্ক্রিপ্ট

// Calling with div ID.
googletag.openConsole("div-1");

// Calling without div ID.
googletag.openConsole();

JavaScript (legacy)

// Calling with div ID.
googletag.openConsole("div-1");

// Calling without div ID.
googletag.openConsole();

TypeScript

// Calling with div ID.
googletag.openConsole("div-1");

// Calling without div ID.
googletag.openConsole();
আরও দেখুন
Parameters
Optional div : string An ad slot div ID. This value is optional. When provided, the Publisher Console will attempt to open with details of the specified ad slot in view.

pubads

pubads ( ) : PubAdsService
Returns a reference to the PubAdsService .
ফেরত
PubAdsService The Publisher Ads service.

setAdIframeTitle

setAdIframeTitle ( title : string ) : void
Sets the title for all ad container iframes created by PubAdsService , from this point onwards.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setAdIframeTitle("title");

JavaScript (legacy)

googletag.setAdIframeTitle("title");

TypeScript

googletag.setAdIframeTitle("title");
Parameters
title : string The new title for all ad container iframes.

setConfig

setConfig ( config : PageSettingsConfig ) : void
Sets general configuration options for the page.
Parameters
config : PageSettingsConfig

sizeMapping

sizeMapping ( ) : SizeMappingBuilder
Creates a new SizeMappingBuilder .
আরও দেখুন
ফেরত
SizeMappingBuilder A new builder.

googletag.CommandArray

The command array accepts a sequence of functions and invokes them in order. It is intended to replace a standard array that is used to enqueue functions to be invoked once GPT is loaded.
পদ্ধতি
push
Executes the sequence of functions specified in the arguments in order.

পদ্ধতি


ধাক্কা

push ( ... f : ( ( this : typeof globalThis ) => void ) [] ) : number
Executes the sequence of functions specified in the arguments in order.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.cmd.push(() => {
  googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads());
});

JavaScript (legacy)

googletag.cmd.push(function () {
  googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads());
});

TypeScript

googletag.cmd.push(() => {
  googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads());
});
Parameters
Rest ... f : ( ( this : typeof globalThis ) => void ) [] A JavaScript function to be executed. The runtime binding will always be globalThis . Consider passing an arrow function to retain the this value of the enclosing lexical context.
ফেরত
number The number of commands processed so far. This is compatible with Array.push 's return value (the current length of the array).

googletag.CompanionAdsService

Extends Service
Companion Ads service. This service is used by video ads to show companion ads.
পদ্ধতি
add Event Listener
Registers a listener that allows you to set up and call a JavaScript function when a specific GPT event happens on the page.
get Slots
Get the list of slots associated with this service.
remove Event Listener
Removes a previously registered listener.
set Refresh Unfilled Slots
Sets whether companion slots that have not been filled will be automatically backfilled.
আরও দেখুন

পদ্ধতি


setRefreshUnfilledSlots

setRefreshUnfilledSlots ( value : boolean ) : void
Sets whether companion slots that have not been filled will be automatically backfilled.

This method can be called multiple times during the page's lifetime to turn backfill on and off. Only slots that are also registered with the PubAdsService will be backfilled. Due to policy restrictions, this method is not designed to fill empty companion slots when an Ad Exchange video is served.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.companionAds().setRefreshUnfilledSlots(true);

JavaScript (legacy)

googletag.companionAds().setRefreshUnfilledSlots(true);

TypeScript

googletag.companionAds().setRefreshUnfilledSlots(true);
Parameters
value : boolean true to automatically backfill unfilled slots, false to leave them unchanged.

googletag.PrivacySettingsConfig

Configuration object for privacy settings.
বৈশিষ্ট্য
child Directed Treatment ?
Indicates whether the page should be treated as child-directed .
limited Ads ?
Enables serving to run in limited ads mode to aid in publisher regulatory compliance needs.
non Personalized Ads ?
Enables serving to run in non-personalized ads mode to aid in publisher regulatory compliance needs.
restrict Data Processing ?
Enables serving to run in restricted processing mode to aid in publisher regulatory compliance needs.
tag For Age Treatment ?
The age-restricted treatment, indicating whether the ad request should be treated as child, teen, or unspecified.
traffic Source ?
Indicates whether requests represent purchased or organic traffic.
under Age Of Consent ?
Indicates whether to mark ad requests as coming from users under the age of consent .
আরও দেখুন

বৈশিষ্ট্য


Optional childDirectedTreatment

childDirectedTreatment ?: boolean
Indicates whether the page should be treated as child-directed . Set to null to clear the configuration.

Optional limitedAds

limitedAds ?: boolean
Enables serving to run in limited ads mode to aid in publisher regulatory compliance needs.

You can instruct GPT to request limited ads in two ways:
  • Automatically, by using a signal from an IAB TCF v2.0 consent management platform.
  • Manually, by setting the value of this field to true .
Manually configuring limited ads is only possible when GPT is loaded from the limited ads URL . Attempting to modify this setting when GPT has been loaded from the standard URL will generate a Publisher Console warning .

Note that it is not necessary to manually enable limited ads when a CMP is in use.
উদাহরণ

জাভাস্ক্রিপ্ট

// Manually enable limited ads serving.
// GPT must be loaded from the limited ads URL to configure this setting.
googletag.pubads().setPrivacySettings({
  limitedAds: true,
});

JavaScript (legacy)

// Manually enable limited ads serving.
// GPT must be loaded from the limited ads URL to configure this setting.
googletag.pubads().setPrivacySettings({
  limitedAds: true,
});

TypeScript

// Manually enable limited ads serving.
// GPT must be loaded from the limited ads URL to configure this setting.
googletag.pubads().setPrivacySettings({
  limitedAds: true,
});
আরও দেখুন

Optional nonPersonalizedAds

nonPersonalizedAds ?: boolean
Enables serving to run in non-personalized ads mode to aid in publisher regulatory compliance needs.

Optional restrictDataProcessing

restrictDataProcessing ?: boolean
Enables serving to run in restricted processing mode to aid in publisher regulatory compliance needs.

Optional tagForAgeTreatment

tagForAgeTreatment ?: TagForAgeTreatment
The age-restricted treatment, indicating whether the ad request should be treated as child, teen, or unspecified.

Consult your own legal counsel to determine the age treatment settings for your users based on your legal and regulatory requirements. For more information on this setting, review this Help Center article .

By setting this property, you certify that this notification is accurate and you are authorized to act on behalf of the owner of the site. You understand that abuse of this setting may result in termination of your Google account.
উদাহরণ

জাভাস্ক্রিপ্ট

// Enable teen privacy treatment.
googletag.pubads().setPrivacySettings({
  tagForAgeTreatment: googletag.enums.TagForAgeTreatment.TEEN,
});

// Clear age treatment configuration.
googletag.pubads().setPrivacySettings({
  tagForAgeTreatment: googletag.enums.TagForAgeTreatment.UNSPECIFIED,
});

JavaScript (legacy)

// Enable teen privacy treatment.
googletag.pubads().setPrivacySettings({
  tagForAgeTreatment: googletag.enums.TagForAgeTreatment.TEEN,
});

// Clear age treatment configuration.
googletag.pubads().setPrivacySettings({
  tagForAgeTreatment: googletag.enums.TagForAgeTreatment.UNSPECIFIED,
});

TypeScript

// Enable teen privacy treatment.
googletag.pubads().setPrivacySettings({
  tagForAgeTreatment: googletag.enums.TagForAgeTreatment.TEEN,
});

// Clear age treatment configuration.
googletag.pubads().setPrivacySettings({
  tagForAgeTreatment: googletag.enums.TagForAgeTreatment.UNSPECIFIED,
});

Optional trafficSource

trafficSource ?: TrafficSource
Indicates whether requests represent purchased or organic traffic. This value populates the Traffic source dimension in Ad Manager reporting. If not set, traffic source defaults to undefined in reporting.
উদাহরণ

জাভাস্ক্রিপ্ট

// Indicate requests represent organic traffic.
googletag.pubads().setPrivacySettings({
  trafficSource: googletag.enums.TrafficSource.ORGANIC,
});

// Indicate requests represent purchased traffic.
googletag.pubads().setPrivacySettings({
  trafficSource: googletag.enums.TrafficSource.PURCHASED,
});

JavaScript (legacy)

// Indicate requests represent organic traffic.
googletag.pubads().setPrivacySettings({
  trafficSource: googletag.enums.TrafficSource.ORGANIC,
});

// Indicate requests represent purchased traffic.
googletag.pubads().setPrivacySettings({
  trafficSource: googletag.enums.TrafficSource.PURCHASED,
});

TypeScript

// Indicate requests represent organic traffic.
googletag.pubads().setPrivacySettings({
  trafficSource: googletag.enums.TrafficSource.ORGANIC,
});

// Indicate requests represent purchased traffic.
googletag.pubads().setPrivacySettings({
  trafficSource: googletag.enums.TrafficSource.PURCHASED,
});

Optional underAgeOfConsent

underAgeOfConsent ?: boolean
Indicates whether to mark ad requests as coming from users under the age of consent . Set to null to clear the configuration.

googletag.PubAdsService

Extends Service
Publisher Ads service. This service is used to fetch and show ads from your Google Ad Manager account.
পদ্ধতি
add Event Listener
Registers a listener that allows you to set up and call a JavaScript function when a specific GPT event happens on the page.
clear
Removes the ads from the given slots and replaces them with blank content.
clear Category Exclusions
Deprecated. Clears all page-level ad category exclusion labels.
clear Targeting
Deprecated. Clears custom targeting parameters for a specific key or for all keys.
collapse Empty Divs
Deprecated. Enables collapsing of slot divs so that they don't take up any space on the page when there is no ad content to display.
disable Initial Load
Deprecated. Disables requests for ads on page load, but allows ads to be requested with a PubAdsService.refresh call.
display
Constructs and displays an ad slot with the given ad unit path and size.
enable Lazy Load
Deprecated. Enables lazy loading in GPT as defined by the config object.
enable Single Request
Deprecated. Enables single request mode for fetching multiple ads at the same time.
enable Video Ads
Deprecated. Signals to GPT that video ads will be present on the page.
get
Deprecated. Returns the value for the AdSense attribute associated with the given key.
get Attribute Keys
Deprecated. Returns the attribute keys that have been set on this service.
get Slots
Get the list of slots associated with this service.
get Targeting
Deprecated. Returns a specific custom service-level targeting parameter that has been set.
get Targeting Keys
Deprecated. Returns the list of all custom service-level targeting keys that have been set.
is Initial Load Disabled
Deprecated. Returns whether or not initial requests for ads was successfully disabled by a previous PubAdsService.disableInitialLoad call.
refresh
Fetches and displays new ads for specific or all slots on the page.
remove Event Listener
Removes a previously registered listener.
set
Deprecated. Sets values for AdSense attributes that apply to all ad slots under the Publisher Ads service.
set Category Exclusion
Deprecated. Sets a page-level ad category exclusion for the given label name.
set Centering
Deprecated. Enables and disables horizontal centering of ads.
set Force Safe Frame
Deprecated. Configures whether all ads on the page should be forced to be rendered using a SafeFrame container.
set Location
Deprecated. Passes location information from websites so you can geo-target line items to specific locations.
set Privacy Settings
Allows configuration of all privacy settings from a single API using a config object.
set Publisher Provided Id
Sets the value for the publisher-provided ID.
set Safe Frame Config
Deprecated. Sets the page-level preferences for SafeFrame configuration.
set Targeting
Deprecated. Sets custom targeting parameters for a given key that apply to all Publisher Ads service ad slots.
set Video Content
Deprecated. Sets the video content information to be sent along with the ad requests for targeting and content exclusion purposes.
update Correlator
Changes the correlator that is sent with ad requests, effectively starting a new page view.

পদ্ধতি


পরিষ্কার

clear ( slots ?: Slot [] ) : boolean
Removes the ads from the given slots and replaces them with blank content. The slots will be marked as unfetched.

In particular, clearing a slot removes the ad from GPT's long-lived pageview , so future requests will not be influenced by roadblocks or competitive exclusions involving this ad.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
googletag.display("div-1");
const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2");
googletag.display("div-2");

// This call to clear only slot1.
googletag.pubads().clear([slot1]);

// This call to clear both slot1 and slot2.
googletag.pubads().clear([slot1, slot2]);

// This call to clear all slots.
googletag.pubads().clear();

JavaScript (legacy)

var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
googletag.display("div-1");
var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2");
googletag.display("div-2");

// This call to clear only slot1.
googletag.pubads().clear([slot1]);

// This call to clear both slot1 and slot2.
googletag.pubads().clear([slot1, slot2]);

// This call to clear all slots.
googletag.pubads().clear();

TypeScript

const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!;
googletag.display("div-1");
const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!;
googletag.display("div-2");

// This call to clear only slot1.
googletag.pubads().clear([slot1]);

// This call to clear both slot1 and slot2.
googletag.pubads().clear([slot1, slot2]);

// This call to clear all slots.
googletag.pubads().clear();
Parameters
Optional slots : Slot [] The array of slots to clear. Array is optional; all slots will be cleared if it is unspecified.
ফেরত
boolean Returns true if slots have been cleared, false otherwise.

clearCategoryExclusions

clearCategoryExclusions ( ) : PubAdsService
Clears all page-level ad category exclusion labels. This is useful if you want to refresh the slot.
উদাহরণ

জাভাস্ক্রিপ্ট

// Set category exclusion to exclude ads with 'AirlineAd' labels.
googletag.setConfig({
  categoryExclusion: ["AirlineAd"],
});

// Make ad requests. No ad with 'AirlineAd' label will be returned.

// Clear category exclusions so all ads can be returned.
googletag.setConfig({
  categoryExclusion: null,
});

// Make ad requests. Any ad can be returned.

JavaScript (legacy)

// Set category exclusion to exclude ads with 'AirlineAd' labels.
googletag.setConfig({
  categoryExclusion: ["AirlineAd"],
});

// Make ad requests. No ad with 'AirlineAd' label will be returned.

// Clear category exclusions so all ads can be returned.
googletag.setConfig({
  categoryExclusion: null,
});

// Make ad requests. Any ad can be returned.

TypeScript

// Set category exclusion to exclude ads with 'AirlineAd' labels.
googletag.setConfig({
  categoryExclusion: ["AirlineAd"],
});

// Make ad requests. No ad with 'AirlineAd' label will be returned.

// Clear category exclusions so all ads can be returned.
googletag.setConfig({
  categoryExclusion: null,
});

// Make ad requests. Any ad can be returned.
আরও দেখুন
ফেরত
PubAdsService The service object on which the method was called.

clearTargeting

clearTargeting ( key ?: string ) : PubAdsService
Clears custom targeting parameters for a specific key or for all keys.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  targeting: {
    interests: "sports",
    colors: "blue",
    fruits: "apple",
  },
});

googletag.setConfig({
  targeting: {
    interests: null,
  },
});
// Targeting 'colors' and 'fruits' are still present, while 'interests'
// was cleared.

googletag.setConfig({
  targeting: null,
});
// All targeting has been cleared.

JavaScript (legacy)

googletag.setConfig({
  targeting: {
    interests: "sports",
    colors: "blue",
    fruits: "apple",
  },
});

googletag.setConfig({
  targeting: {
    interests: null,
  },
});
// Targeting 'colors' and 'fruits' are still present, while 'interests'
// was cleared.

googletag.setConfig({
  targeting: null,
});
// All targeting has been cleared.

TypeScript

googletag.setConfig({
  targeting: {
    interests: "sports",
    colors: "blue",
    fruits: "apple",
  },
});

googletag.setConfig({
  targeting: {
    interests: null,
  },
});
// Targeting 'colors' and 'fruits' are still present, while 'interests'
// was cleared.

googletag.setConfig({
  targeting: null,
});
// All targeting has been cleared.
আরও দেখুন
Parameters
Optional key : string Targeting parameter key. The key is optional; all targeting parameters will be cleared if it is unspecified.
ফেরত
PubAdsService The service object on which the method was called.

collapseEmptyDivs

collapseEmptyDivs ( collapseBeforeAdFetch ?: boolean ) : boolean
Enables collapsing of slot divs so that they don't take up any space on the page when there is no ad content to display. This mode must be set before the service is enabled.
আরও দেখুন
Parameters
Optional collapseBeforeAdFetch : boolean Whether to collapse the slots even before the ads are fetched. This parameter is optional; if not provided, false will be used as the default value.
ফেরত
boolean Returns true if div collapse mode was enabled and false if it is impossible to enable collapse mode because the method was called after the service was enabled.

disableInitialLoad

disableInitialLoad ( ) : void
Disables requests for ads on page load, but allows ads to be requested with a PubAdsService.refresh call. This should be set prior to enabling the service. Async mode must be used; otherwise it will be impossible to request ads using refresh .
আরও দেখুন

প্রদর্শন

display ( adUnitPath : string , size : GeneralSize , div ?: string | Element , clickUrl ?: string ) : void
Constructs and displays an ad slot with the given ad unit path and size.

This method is a shorthand equivalent to calling googletag.defineSlot followed immediately by googletag.display .

The behavior of this method depends on whether Single Request Architecture (SRA) is enabled:
  • SRA enabled: All ad slots defined up to the point of this call will be batched and requested together.
  • SRA disabled (default): The ad slot will be requested individually.
Note: When this method is called, a snapshot of the slot and page state is created to ensure consistency when sending the ad request and rendering the response. Any changes that are made to the slot or page state after this method is called (including targeting, privacy settings, force SafeFrame, etc.) will only apply to subsequent display() or refresh() requests.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.pubads().display("/1234567/sports", [728, 90], "div-1");

JavaScript (legacy)

googletag.pubads().display("/1234567/sports", [728, 90], "div-1");

TypeScript

googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
আরও দেখুন
Parameters
adUnitPath : string The ad unit path of slot to be rendered.
size : GeneralSize Width and height of the slot.
Optional div : string | Element Either the ID of the div containing the slot or the div element itself.
Optional clickUrl : string The click URL to use on this slot.

enableLazyLoad

enableLazyLoad ( config ?: {
  fetchMarginPercent ?: number ;
  mobileScaling ?: number ;
  renderMarginPercent ?: number ;
} ) : void
Enables lazy loading in GPT as defined by the config object. For more detailed examples, see the Lazy loading sample.

Note: Lazy fetching in SRA only works if all slots are outside the fetching margin.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  lazyLoad: {
    // Fetch slots within 5 viewports.
    fetchMarginPercent: 500,
    // Render slots within 2 viewports.
    renderMarginPercent: 200,
    // Double the above values on mobile.
    mobileScaling: 2.0,
  },
});

JavaScript (legacy)

googletag.setConfig({
  lazyLoad: {
    // Fetch slots within 5 viewports.
    fetchMarginPercent: 500,
    // Render slots within 2 viewports.
    renderMarginPercent: 200,
    // Double the above values on mobile.
    mobileScaling: 2.0,
  },
});

TypeScript

googletag.setConfig({
  lazyLoad: {
    // Fetch slots within 5 viewports.
    fetchMarginPercent: 500,
    // Render slots within 2 viewports.
    renderMarginPercent: 200,
    // Double the above values on mobile.
    mobileScaling: 2.0,
  },
});
আরও দেখুন
Parameters
Optional config : {
  fetchMarginPercent ?: number ;
  mobileScaling ?: number ;
  renderMarginPercent ?: number ;
}
Configuration object allows customization of lazy behavior. Any omitted configurations will use a default set by Google that will be tuned over time. To disable a particular setting, such as a fetching margin, set the value to -1 .
  • fetchMarginPercent

    The minimum distance from the current viewport a slot must be before we fetch the ad as a percentage of viewport size. A value of 0 means "when the slot enters the viewport", 100 means "when the ad is 1 viewport away", and so on.
  • renderMarginPercent

    The minimum distance from the current viewport a slot must be before we render an ad. This allows for prefetching the ad, but waiting to render and download other subresources. The value works just like fetchMarginPercent as a percentage of viewport.
  • mobileScaling

    A multiplier applied to margins on mobile devices. This allows varying margins on mobile vs. desktop. For example, a value of 2.0 will multiply all margins by 2 on mobile devices, increasing the minimum distance a slot can be before fetching and rendering.

enableSingleRequest

enableSingleRequest ( ) : boolean
Enables single request mode for fetching multiple ads at the same time. This requires all Publisher Ads slots to be defined and added to the PubAdsService prior to enabling the service. Single request mode must be set before the service is enabled.
আরও দেখুন
ফেরত
boolean Returns true if single request mode was enabled and false if it is impossible to enable single request mode because the method was called after the service was enabled.

enableVideoAds

enableVideoAds ( ) : void
Signals to GPT that video ads will be present on the page. This enables competitive exclusion constraints on display and video ads. If the video content is known, call PubAdsService.setVideoContent in order to be able to use content exclusion for display ads.

পেতে

get ( key : string ) : string
Returns the value for the AdSense attribute associated with the given key.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
  },
});

const adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes;
const pageUrl = adsenseConfig?.page_url || null;
// Returns 'http://www.example.com'.

JavaScript (legacy)

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
  },
});

var adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes;
var pageUrl =
  (adsenseConfig === null || adsenseConfig === void 0 ? void 0 : adsenseConfig.page_url) || null;
// Returns 'http://www.example.com'.

TypeScript

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
  },
});

const adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes;
const pageUrl = adsenseConfig?.page_url || null;
// Returns 'http://www.example.com'.
আরও দেখুন
Parameters
key : string Name of the attribute to look for.
ফেরত
string Current value for the attribute key, or null if the key is not present.

getAttributeKeys

getAttributeKeys ( ) : string []
Returns the attribute keys that have been set on this service.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
    document_language: "en",
  },
});

const adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes;
const adsenseAttributes = Object.keys(adsenseConfig || {});
// Returns ['page_url', 'document_language'].

JavaScript (legacy)

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
    document_language: "en",
  },
});

var adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes;
var adsenseAttributes = Object.keys(adsenseConfig || {});
// Returns ['page_url', 'document_language'].

TypeScript

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
    document_language: "en",
  },
});

const adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes;
const adsenseAttributes = Object.keys(adsenseConfig || {});
// Returns ['page_url', 'document_language'].
ফেরত
string [] Array of attribute keys set on this service. Ordering is undefined.

getTargeting

getTargeting ( key : string ) : string []
Returns a specific custom service-level targeting parameter that has been set.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  targeting: {
    interests: "sports",
  },
});

const targetingConfig = googletag.getConfig("targeting").targeting;

// Get targeting for a specific key.
const targeting = targetingConfig?.["interests"] || [];
// Returns ['sports'].

const ageTargeting = targetingConfig?.["age"] || [];
// Returns [] (empty array).

JavaScript (legacy)

googletag.setConfig({
  targeting: {
    interests: "sports",
  },
});

var targetingConfig = googletag.getConfig("targeting").targeting;

// Get targeting for a specific key.
var targeting =
  (targetingConfig === null || targetingConfig === void 0
    ? void 0
    : targetingConfig["interests"]) || [];
// Returns ['sports'].

var ageTargeting =
  (targetingConfig === null || targetingConfig === void 0 ? void 0 : targetingConfig["age"]) || [];
// Returns [] (empty array).

TypeScript

googletag.setConfig({
  targeting: {
    interests: "sports",
  },
});

const targetingConfig = googletag.getConfig("targeting").targeting;

// Get targeting for a specific key.
const targeting = targetingConfig?.["interests"] || [];
// Returns ['sports'].

const ageTargeting = targetingConfig?.["age"] || [];
// Returns [] (empty array).
Parameters
key : string The targeting key to look for.
ফেরত
string [] The values associated with this key, or an empty array if there is no such key.

getTargetingKeys

getTargetingKeys ( ) : string []
Returns the list of all custom service-level targeting keys that have been set.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  targeting: {
    interests: "sports",
    colors: "blue",
  },
});

const targetingConfig = googletag.getConfig("targeting").targeting;
const keys = Object.keys(targetingConfig || {});
// Returns ['interests', 'colors'].

JavaScript (legacy)

googletag.setConfig({
  targeting: {
    interests: "sports",
    colors: "blue",
  },
});

var targetingConfig = googletag.getConfig("targeting").targeting;
var keys = Object.keys(targetingConfig || {});
// Returns ['interests', 'colors'].

TypeScript

googletag.setConfig({
  targeting: {
    interests: "sports",
    colors: "blue",
  },
});

const targetingConfig = googletag.getConfig("targeting").targeting;
const keys = Object.keys(targetingConfig || {});
// Returns ['interests', 'colors'].
ফেরত
string [] Array of targeting keys. Ordering is undefined.

isInitialLoadDisabled

isInitialLoadDisabled ( ) : boolean
Returns whether or not initial requests for ads was successfully disabled by a previous PubAdsService.disableInitialLoad call.
ফেরত
boolean Returns true if a previous call to PubAdsService.disableInitialLoad was successful, false otherwise.

রিফ্রেশ

refresh ( slots ?: Slot [] , options ?: {
  changeCorrelator : boolean ;
} ) : void
Fetches and displays new ads for specific or all slots on the page. Works only in asynchronous rendering mode.

For proper behavior across all browsers, calling refresh must be preceded by a call to display the ad slot. If the call to display is omitted, refresh may behave unexpectedly. If desired, the PubAdsService.disableInitialLoad method can be used to stop display from fetching an ad.

Refreshing a slot removes the old ad from GPT's long-lived pageview , so future requests will not be influenced by roadblocks or competitive exclusions involving that ad.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
googletag.display("div-1");
const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2");
googletag.display("div-2");

// This call to refresh fetches a new ad for slot1 only.
googletag.pubads().refresh([slot1]);

// This call to refresh fetches a new ad for both slot1 and slot2.
googletag.pubads().refresh([slot1, slot2]);

// This call to refresh fetches a new ad for each slot.
googletag.pubads().refresh();

// This call to refresh fetches a new ad for slot1, without changing
// the correlator.
googletag.pubads().refresh([slot1], { changeCorrelator: false });

// This call to refresh fetches a new ad for each slot, without
// changing the correlator.
googletag.pubads().refresh(null, { changeCorrelator: false });

JavaScript (legacy)

var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
googletag.display("div-1");
var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2");
googletag.display("div-2");

// This call to refresh fetches a new ad for slot1 only.
googletag.pubads().refresh([slot1]);

// This call to refresh fetches a new ad for both slot1 and slot2.
googletag.pubads().refresh([slot1, slot2]);

// This call to refresh fetches a new ad for each slot.
googletag.pubads().refresh();

// This call to refresh fetches a new ad for slot1, without changing
// the correlator.
googletag.pubads().refresh([slot1], { changeCorrelator: false });

// This call to refresh fetches a new ad for each slot, without
// changing the correlator.
googletag.pubads().refresh(null, { changeCorrelator: false });

TypeScript

const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!;
googletag.display("div-1");
const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!;
googletag.display("div-2");

// This call to refresh fetches a new ad for slot1 only.
googletag.pubads().refresh([slot1]);

// This call to refresh fetches a new ad for both slot1 and slot2.
googletag.pubads().refresh([slot1, slot2]);

// This call to refresh fetches a new ad for each slot.
googletag.pubads().refresh();

// This call to refresh fetches a new ad for slot1, without changing
// the correlator.
googletag.pubads().refresh([slot1], { changeCorrelator: false });

// This call to refresh fetches a new ad for each slot, without
// changing the correlator.
googletag.pubads().refresh(null, { changeCorrelator: false });
আরও দেখুন
Parameters
Optional slots : Slot [] The slots to refresh. Array is optional; all slots will be refreshed if it is unspecified.
Optional options : {
  changeCorrelator : boolean ;
}
Configuration options associated with this refresh call.
  • changeCorrelator

    Specifies whether or not a new correlator is to be generated for fetching ads. Our ad servers maintain this correlator value briefly (currently for 30 seconds, but subject to change), such that requests with the same correlator received close together will be considered a single page view. By default a new correlator is generated for every refresh.

    Note: this option has no effect on GPT's long-lived pageview , which automatically reflects the ads currently on the page and has no expiration time.

সেট

set ( key : string , value : string ) : PubAdsService
Sets values for AdSense attributes that apply to all ad slots under the Publisher Ads service.

Calling this more than once for the same key will override previously set values for that key. All values must be set before calling display or refresh .
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
  },
});

JavaScript (legacy)

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
  },
});

TypeScript

googletag.setConfig({
  adsenseAttributes: {
    page_url: "http://www.example.com",
  },
});
আরও দেখুন
Parameters
key : string The name of the attribute.
value : string Attribute value.
ফেরত
PubAdsService The service object on which the method was called.

setCategoryExclusion

setCategoryExclusion ( categoryExclusion : string ) : PubAdsService
Sets a page-level ad category exclusion for the given label name.
উদাহরণ

জাভাস্ক্রিপ্ট

// Label = AirlineAd.
googletag.setConfig({
  categoryExclusion: ["AirlineAd"],
});

JavaScript (legacy)

// Label = AirlineAd.
googletag.setConfig({
  categoryExclusion: ["AirlineAd"],
});

TypeScript

// Label = AirlineAd.
googletag.setConfig({
  categoryExclusion: ["AirlineAd"],
});
আরও দেখুন
Parameters
categoryExclusion : string The ad category exclusion label to add.
ফেরত
PubAdsService The service object on which the method was called.

setCentering

setCentering ( centerAds : boolean ) : void
Enables and disables horizontal centering of ads. Centering is disabled by default. In legacy gpt_mobile.js, centering is enabled by default.

This method should be invoked before calling display or refresh because only ads that are requested after calling this method will be centered.
উদাহরণ

জাভাস্ক্রিপ্ট

// Make ads centered.
googletag.setConfig({
  centering: true,
});

JavaScript (legacy)

// Make ads centered.
googletag.setConfig({
  centering: true,
});

TypeScript

// Make ads centered.
googletag.setConfig({
  centering: true,
});
Parameters
centerAds : boolean true to center ads, false to left-align them.

setForceSafeFrame

setForceSafeFrame ( forceSafeFrame : boolean ) : PubAdsService
Configures whether all ads on the page should be forced to be rendered using a SafeFrame container.

Please keep the following things in mind while using this API:
  • This setting will only take effect for subsequent ad requests made for the respective slots.
  • The slot level setting, if specified, will always override the page level setting.
  • If set to true (at slot-level or page level), the ad will always be rendered using a SafeFrame container independent of the choice made in the Google Ad Manager UI.
  • However, if set to false or left unspecified, the ad will be rendered using a SafeFrame container depending on the type of creative and the selection made in the Google Ad Manager UI.
  • This API should be used with caution as it could impact the behaviour of creatives that attempt to break out of their iFrames or rely on them being rendered directly in a publishers page.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  safeFrame: {
    forceSafeFrame: true,
  },
});

// The following slot will be opted-out of the page-level force
// SafeFrame instruction.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setConfig({
    safeFrame: {
      forceSafeFrame: false,
    },
  })
  .addService(googletag.pubads());

// The following slot will have SafeFrame forced.
googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads());

googletag.display("div-1");
googletag.display("div-2");

JavaScript (legacy)

googletag.setConfig({
  safeFrame: {
    forceSafeFrame: true,
  },
});

// The following slot will be opted-out of the page-level force
// SafeFrame instruction.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setConfig({
    safeFrame: {
      forceSafeFrame: 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.setConfig({
  safeFrame: {
    forceSafeFrame: true,
  },
});

// The following slot will be opted-out of the page-level force
// SafeFrame instruction.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")!
  .setConfig({
    safeFrame: {
      forceSafeFrame: 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");
আরও দেখুন
Parameters
forceSafeFrame : boolean true to force all ads on the page to be rendered in SafeFrames and false to change the previous setting to false. Setting this to false when unspecified earlier, won't change anything.
ফেরত
PubAdsService The service object on which the method was called.

setLocation

setLocation ( address : string ) : PubAdsService
Passes location information from websites so you can geo-target line items to specific locations.
উদাহরণ

জাভাস্ক্রিপ্ট

// Postal code:
googletag.setConfig({
  location: "10001,US",
});

JavaScript (legacy)

// Postal code:
googletag.setConfig({
  location: "10001,US",
});

TypeScript

// Postal code:
googletag.setConfig({
  location: "10001,US",
});
Parameters
address : string Freeform address.
ফেরত
PubAdsService The service object on which the method was called.

setPrivacySettings

setPrivacySettings ( privacySettings : PrivacySettingsConfig ) : PubAdsService
Allows configuration of all privacy settings from a single API using a config object.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.pubads().setPrivacySettings({
  restrictDataProcessing: true,
});

// Set multiple privacy settings at the same time.
googletag.pubads().setPrivacySettings({
  childDirectedTreatment: true,
  underAgeOfConsent: true,
});

// Clear the configuration for childDirectedTreatment.
googletag.pubads().setPrivacySettings({
  childDirectedTreatment: null,
});

JavaScript (legacy)

googletag.pubads().setPrivacySettings({
  restrictDataProcessing: true,
});

// Set multiple privacy settings at the same time.
googletag.pubads().setPrivacySettings({
  childDirectedTreatment: true,
  underAgeOfConsent: true,
});

// Clear the configuration for childDirectedTreatment.
googletag.pubads().setPrivacySettings({
  childDirectedTreatment: null,
});

TypeScript

googletag.pubads().setPrivacySettings({
  restrictDataProcessing: true,
});

// Set multiple privacy settings at the same time.
googletag.pubads().setPrivacySettings({
  childDirectedTreatment: true,
  underAgeOfConsent: true,
});

// Clear the configuration for childDirectedTreatment.
googletag.pubads().setPrivacySettings({
  childDirectedTreatment: null,
});
আরও দেখুন
Parameters
privacySettings : PrivacySettingsConfig Object containing privacy settings config.
ফেরত
PubAdsService The service object on which the function was called.

setPublisherProvidedId

setPublisherProvidedId ( ppid : string ) : PubAdsService
Sets the value for the publisher-provided ID.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");

JavaScript (legacy)

googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");

TypeScript

googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
আরও দেখুন
Parameters
ppid : string An alphanumeric ID provided by the publisher. Must be between 32 and 150 characters.
ফেরত
PubAdsService The service object on which the method was called.

setSafeFrameConfig

setSafeFrameConfig ( config : SafeFrameConfig ) : PubAdsService
Sets the page-level preferences for SafeFrame configuration. Any unrecognized keys in the config object will be ignored. The entire config will be ignored if an invalid value is passed for a recognized key.

These page-level preferences will be overridden by slot-level preferences, if specified.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.setConfig({
  safeFrame: {
    forceSafeFrame: true,
    allowOverlayExpansion: true,
    allowPushExpansion: true,
    sandbox: true,
  },
});

googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setConfig({
    safeFrame: {
      allowOverlayExpansion: false,
    },
  })
  .addService(googletag.pubads());

// The following slot will inherit the page level settings, and hence
// would allow for expansion by overlay.
googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads());

googletag.display("div-1");
googletag.display("div-2");

JavaScript (legacy)

googletag.setConfig({
  safeFrame: {
    forceSafeFrame: true,
    allowOverlayExpansion: true,
    allowPushExpansion: true,
    sandbox: true,
  },
});

googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setConfig({
    safeFrame: {
      allowOverlayExpansion: false,
    },
  })
  .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.setConfig({
  safeFrame: {
    forceSafeFrame: true,
    allowOverlayExpansion: true,
    allowPushExpansion: true,
    sandbox: true,
  },
});

googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")!
  .setConfig({
    safeFrame: {
      allowOverlayExpansion: false,
    },
  })
  .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 The configuration object.
ফেরত
PubAdsService The service object on which the method was called.

setTargeting

setTargeting ( key : string , value : string | string [] ) : PubAdsService
Sets custom targeting parameters for a given key that apply to all Publisher Ads service ad slots. Calling this multiple times for the same key will overwrite old values. These keys are defined in your Google Ad Manager account.
উদাহরণ

জাভাস্ক্রিপ্ট

// Example with a single value for a key.
googletag.setConfig({
  targeting: {
    interests: "sports",
  },
});

// Example with multiple values for a key inside in an array.
googletag.setConfig({
  targeting: {
    interests: ["sports", "music"],
  },
});

JavaScript (legacy)

// Example with a single value for a key.
googletag.setConfig({
  targeting: {
    interests: "sports",
  },
});

// Example with multiple values for a key inside in an array.
googletag.setConfig({
  targeting: {
    interests: ["sports", "music"],
  },
});

TypeScript

// Example with a single value for a key.
googletag.setConfig({
  targeting: {
    interests: "sports",
  },
});

// Example with multiple values for a key inside in an array.
googletag.setConfig({
  targeting: {
    interests: ["sports", "music"],
  },
});
আরও দেখুন
Parameters
key : string Targeting parameter key.
value : string | string [] Targeting parameter value or array of values.
ফেরত
PubAdsService The service object on which the method was called.

setVideoContent

setVideoContent ( videoContentId : string , videoCmsId : string ) : void
Sets the video content information to be sent along with the ad requests for targeting and content exclusion purposes. Video ads will be automatically enabled when this method is called. For videoContentId and videoCmsId , use the values that are provided to the Google Ad Manager content ingestion service.
আরও দেখুন
Parameters
videoContentId : string The video content ID.
videoCmsId : string The video CMS ID.

updateCorrelator

updateCorrelator ( ) : PubAdsService
Changes the correlator that is sent with ad requests, effectively starting a new page view. The correlator is the same for all the ad requests coming from one page view, and unique across page views. Only applies to async mode.

Note: this has no effect on GPT's long-lived pageview , which automatically reflects the ads actually on the page and has no expiration time.
উদাহরণ

জাভাস্ক্রিপ্ট

// Assume that the correlator is currently 12345. All ad requests made
// by this page will currently use that value.

// Replace the current correlator with a new correlator.
googletag.pubads().updateCorrelator();

// The correlator will now be a new randomly selected value, different
// from 12345. All subsequent ad requests made by this page will use
// the new value.

JavaScript (legacy)

// Assume that the correlator is currently 12345. All ad requests made
// by this page will currently use that value.

// Replace the current correlator with a new correlator.
googletag.pubads().updateCorrelator();

// The correlator will now be a new randomly selected value, different
// from 12345. All subsequent ad requests made by this page will use
// the new value.

TypeScript

// Assume that the correlator is currently 12345. All ad requests made
// by this page will currently use that value.

// Replace the current correlator with a new correlator.
googletag.pubads().updateCorrelator();

// The correlator will now be a new randomly selected value, different
// from 12345. All subsequent ad requests made by this page will use
// the new value.
ফেরত
PubAdsService The service object on which the function was called.

googletag.ResponseInformation

An object representing a single ad response.
বৈশিষ্ট্য
advertiser Id
The ID of the advertiser.
campaign Id
The ID of the campaign.
creative Id
The ID of the creative.
creative Template Id
The template ID of the ad.
line Item Id
The ID of the line item.
আরও দেখুন

বৈশিষ্ট্য


advertiserId

advertiserId : number
The ID of the advertiser.

campaignId

campaignId : number
The ID of the campaign.

creativeId

creativeId : number
The ID of the creative.

creativeTemplateId

creativeTemplateId : number
The template ID of the ad.

lineItemId

lineItemId : number
The ID of the line item.

googletag.RewardedPayload

An object representing the reward associated with a rewarded ad
বৈশিষ্ট্য
amount
The number of items included in the reward.
type
The type of item included in the reward (for example, "coin").
আরও দেখুন

বৈশিষ্ট্য


পরিমাণ

amount : number
The number of items included in the reward.

প্রকার

type : string
The type of item included in the reward (for example, "coin").

googletag.Service

Base service class that contains methods common for all services.
পদ্ধতি
add Event Listener
Registers a listener that allows you to set up and call a JavaScript function when a specific GPT event happens on the page.
get Slots
Get the list of slots associated with this service.
remove Event Listener
Removes a previously registered listener.

পদ্ধতি


addEventListener

addEventListener < K extends keyof EventTypeMap > ( eventType : K , listener : ( ( arg : EventTypeMap [ K ] ) => void ) ) : Service
Registers a listener that allows you to set up and call a JavaScript function when a specific GPT event happens on the page. The following events are supported: An object of the appropriate event type is passed to the listener when it is called.
উদাহরণ

জাভাস্ক্রিপ্ট

// 1. Adding an event listener for the PubAdsService.
googletag.pubads().addEventListener("slotOnload", (event) => {
  console.log("Slot has been loaded:");
  console.log(event);
});

// 2. Adding an event listener with slot specific logic.
// Listeners operate at service level, which means that you cannot add
// a listener for an event for a specific slot only. You can, however,
// programmatically filter a listener to respond only to a certain ad
// slot, using this pattern:
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", (event) => {
  if (event.slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// 1. Adding an event listener for the PubAdsService.
googletag.pubads().addEventListener("slotOnload", function (event) {
  console.log("Slot has been loaded:");
  console.log(event);
});

// 2. Adding an event listener with slot specific logic.
// Listeners operate at service level, which means that you cannot add
// a listener for an event for a specific slot only. You can, however,
// programmatically filter a listener to respond only to a certain ad
// slot, using this pattern:
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", function (event) {
  if (event.slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// 1. Adding an event listener for the PubAdsService.
googletag.pubads().addEventListener("slotOnload", (event) => {
  console.log("Slot has been loaded:");
  console.log(event);
});

// 2. Adding an event listener with slot specific logic.
// Listeners operate at service level, which means that you cannot add
// a listener for an event for a specific slot only. You can, however,
// programmatically filter a listener to respond only to a certain ad
// slot, using this pattern:
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", (event) => {
  if (event.slot === targetSlot) {
    // Slot specific logic.
  }
});
আরও দেখুন
Parameters
eventType : K A string representing the type of event generated by GPT. Event types are case sensitive.
listener : ( ( arg : EventTypeMap [ K ] ) => void ) Function that takes a single event object argument.
ফেরত
Service The service object on which the method was called.

getSlots

getSlots ( ) : Slot []
Get the list of slots associated with this service.
ফেরত
Slot [] Slots in the order in which they were added to the service.

removeEventListener

removeEventListener < K extends keyof EventTypeMap > ( eventType : K , listener : ( ( event : EventTypeMap [ K ] ) => void ) ) : void
Removes a previously registered listener.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.cmd.push(() => {
  // Define a new ad slot.
  googletag.defineSlot("/6355419/Travel", [728, 90], "div-for-slot").addService(googletag.pubads());

  // Define a new function that removes itself via removeEventListener
  // after the impressionViewable event fires.
  const onViewableListener = (event) => {
    googletag.pubads().removeEventListener("impressionViewable", onViewableListener);
    setTimeout(() => {
      googletag.pubads().refresh([event.slot]);
    }, 30000);
  };

  // Add onViewableListener as a listener for impressionViewable events.
  googletag.pubads().addEventListener("impressionViewable", onViewableListener);
  googletag.enableServices();
});

JavaScript (legacy)

googletag.cmd.push(function () {
  // Define a new ad slot.
  googletag.defineSlot("/6355419/Travel", [728, 90], "div-for-slot").addService(googletag.pubads());

  // Define a new function that removes itself via removeEventListener
  // after the impressionViewable event fires.
  var onViewableListener = function (event) {
    googletag.pubads().removeEventListener("impressionViewable", onViewableListener);
    setTimeout(function () {
      googletag.pubads().refresh([event.slot]);
    }, 30000);
  };

  // Add onViewableListener as a listener for impressionViewable events.
  googletag.pubads().addEventListener("impressionViewable", onViewableListener);
  googletag.enableServices();
});

TypeScript

googletag.cmd.push(() => {
  // Define a new ad slot.
  googletag
    .defineSlot("/6355419/Travel", [728, 90], "div-for-slot")!
    .addService(googletag.pubads());

  // Define a new function that removes itself via removeEventListener
  // after the impressionViewable event fires.
  const onViewableListener = (event: googletag.events.ImpressionViewableEvent) => {
    googletag.pubads().removeEventListener("impressionViewable", onViewableListener);
    setTimeout(() => {
      googletag.pubads().refresh([event.slot]);
    }, 30000);
  };

  // Add onViewableListener as a listener for impressionViewable events.
  googletag.pubads().addEventListener("impressionViewable", onViewableListener);
  googletag.enableServices();
});
Parameters
eventType : K A string representing the type of event generated by GPT. Event types are case sensitive.
listener : ( ( event : EventTypeMap [ K ] ) => void ) Function that takes a single event object argument.

googletag.SizeMappingBuilder

Builder for size mapping specification objects. This builder is provided to help easily construct size specifications.
পদ্ধতি
add Size
Adds a mapping from a single-size array (representing the viewport) to a single- or multi-size array representing the slot.
build
Builds a size map specification from the mappings added to this builder.
আরও দেখুন

পদ্ধতি


addSize

addSize ( viewportSize : SingleSizeArray , slotSize : GeneralSize ) : SizeMappingBuilder
Adds a mapping from a single-size array (representing the viewport) to a single- or multi-size array representing the slot.
উদাহরণ

জাভাস্ক্রিপ্ট

// 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 &lt; 640x480
  .build();

// Mapping 2
googletag
  .sizeMapping()
  .addSize([1024, 768], [970, 250])
  .addSize([980, 690], [])
  .addSize([640, 480], [120, 60])
  .addSize([0, 0], [])
  .build();

// Mapping 2 will not show any ads for the following viewport sizes:
// [1024, 768] > size >= [980, 690] and
// [640, 480] > size >= [0, 0]

JavaScript (legacy)

// Mapping 1
googletag
  .sizeMapping()
  .addSize([1024, 768], [970, 250])
  .addSize([980, 690], [728, 90])
  .addSize([640, 480], "fluid")
  .addSize([0, 0], [88, 31]) // All viewports &lt; 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 &lt; 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]
Parameters
viewportSize : SingleSizeArray The size of the viewport for this mapping entry.
slotSize : GeneralSize The sizes of the slot for this mapping entry.
ফেরত
SizeMappingBuilder A reference to this builder.

নির্মাণ করুন

build ( ) : SizeMappingArray
Builds a size map specification from the mappings added to this builder.

If any invalid mappings have been supplied, this method will return null . Otherwise it returns a specification in the correct format to pass to Slot.defineSizeMapping .

Note: the behavior of the builder after calling this method is undefined.
ফেরত
SizeMappingArray The result built by this builder. Can be null if invalid size mappings were supplied.

googletag.Slot

Slot is an object representing a single ad slot on a page.
পদ্ধতি
add Service
Adds a Service to this slot.
clear Category Exclusions
Deprecated. Clears all slot-level ad category exclusion labels for this slot.
clear Targeting
Deprecated. Clears specific or all custom slot-level targeting parameters for this slot.
define Size Mapping
Sets an array of mappings from a minimum viewport size to slot size for this slot.
get
Deprecated. Returns the value for the AdSense attribute associated with the given key for this slot.
get Ad Unit Path
Returns the full path of the ad unit, with the network code and ad unit path.
get Attribute Keys
Deprecated. Returns the list of attribute keys set on this slot.
get Category Exclusions
Deprecated. Returns the ad category exclusion labels for this slot.
get Config
Gets a frozen copy of the general configuration options for the slot set by setConfig .
get Response Information
Returns the ad response information.
get Slot Element Id
Returns the ID of the slot div provided when the slot was defined.
get Targeting
Deprecated. Returns a specific custom targeting parameter set on this slot.
get Targeting Keys
Deprecated. Returns the list of all custom targeting keys set on this slot.
set
Deprecated. Sets a value for an AdSense attribute on this ad slot.
set Category Exclusion
Deprecated. Sets a slot-level ad category exclusion label on this slot.
set Click Url
Deprecated. Sets the click URL to which users will be redirected after clicking on the ad.
set Collapse Empty Div
Deprecated. Sets whether the slot div should be hidden when there is no ad in the slot.
set Config
Sets general configuration options for this slot.
set Force Safe Frame
Deprecated. Configures whether ads in this slot should be forced to be rendered using a SafeFrame container.
set Safe Frame Config
Deprecated. Sets the slot-level preferences for SafeFrame configuration.
set Targeting
Deprecated. Sets a custom targeting parameter for this slot.
update Targeting From Map
Deprecated. Sets custom targeting parameters for this slot, from a key:value map in a JSON object.

পদ্ধতি


addService

addService ( service : Service ) : Slot
Adds a Service to this slot.
উদাহরণ

জাভাস্ক্রিপ্ট

googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());

JavaScript (legacy)

googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());

TypeScript

googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
আরও দেখুন
Parameters
service : Service The service to be added.
ফেরত
Slot The slot object on which the method was called.

clearCategoryExclusions

clearCategoryExclusions ( ) : Slot
Clears all slot-level ad category exclusion labels for this slot.
উদাহরণ

জাভাস্ক্রিপ্ট

// Set category exclusion to exclude ads with 'AirlineAd' labels.
const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    categoryExclusion: ["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.setConfig({
  categoryExclusion: null,
});

// Make an ad request. Any ad can be returned for the slot.

JavaScript (legacy)

// Set category exclusion to exclude ads with 'AirlineAd' labels.
var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    categoryExclusion: ["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.setConfig({
  categoryExclusion: null,
});

// 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")!
  .setConfig({
    categoryExclusion: ["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.setConfig({
  categoryExclusion: null,
});

// Make an ad request. Any ad can be returned for the slot.
ফেরত
Slot The slot object on which the method was called.

clearTargeting

clearTargeting ( key ?: string ) : Slot
Clears specific or all custom slot-level targeting parameters for this slot.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    targeting: {
      allow_expandable: "true",
      interests: ["sports", "music"],
      color: "red",
    },
  })
  .addService(googletag.pubads());

slot.setConfig({
  targeting: {
    color: null,
  },
});
// Targeting 'allow_expandable' and 'interests' are still present,
// while 'color' was cleared.

slot.setConfig({
  targeting: null,
});
// All targeting has been cleared.

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    targeting: {
      allow_expandable: "true",
      interests: ["sports", "music"],
      color: "red",
    },
  })
  .addService(googletag.pubads());

slot.setConfig({
  targeting: {
    color: null,
  },
});
// Targeting 'allow_expandable' and 'interests' are still present,
// while 'color' was cleared.

slot.setConfig({
  targeting: null,
});
// All targeting has been cleared.

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    targeting: {
      allow_expandable: "true",
      interests: ["sports", "music"],
      color: "red",
    },
  })
  .addService(googletag.pubads());

slot.setConfig({
  targeting: {
    color: null,
  },
});
// Targeting 'allow_expandable' and 'interests' are still present,
// while 'color' was cleared.

slot.setConfig({
  targeting: null,
});
// All targeting has been cleared.
আরও দেখুন
Parameters
Optional key : string Targeting parameter key. The key is optional; all targeting parameters will be cleared if it is unspecified.
ফেরত
Slot The slot object on which the method was called.

defineSizeMapping

defineSizeMapping ( sizeMapping : SizeMappingArray ) : Slot
Sets an array of mappings from a minimum viewport size to slot size for this slot.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

const mapping = googletag
  .sizeMapping()
  .addSize([100, 100], [88, 31])
  .addSize(
    [320, 400],
    [
      [320, 50],
      [300, 50],
    ],
  )
  .build();

slot.defineSizeMapping(mapping);

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

var mapping = googletag
  .sizeMapping()
  .addSize([100, 100], [88, 31])
  .addSize(
    [320, 400],
    [
      [320, 50],
      [300, 50],
    ],
  )
  .build();

slot.defineSizeMapping(mapping);

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

const mapping = googletag
  .sizeMapping()
  .addSize([100, 100], [88, 31])
  .addSize(
    [320, 400],
    [
      [320, 50],
      [300, 50],
    ],
  )
  .build();

slot.defineSizeMapping(mapping!);
আরও দেখুন
Parameters
sizeMapping : SizeMappingArray Array of size mappings. You can use SizeMappingBuilder to create it. Each size mapping is an array of two elements: SingleSizeArray and GeneralSize .
ফেরত
Slot The slot object on which the method was called.

পেতে

get ( key : string ) : string
Returns the value for the AdSense attribute associated with the given key for this slot. To see service-level attributes inherited by this slot, use PubAdsService.get .
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
    },
  })
  .addService(googletag.pubads());

const adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes;
const pageUrl = adsenseConfig?.page_url || null;
// Returns 'http://www.example.com'.

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
    },
  })
  .addService(googletag.pubads());

var adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes;
var pageUrl =
  (adsenseConfig === null || adsenseConfig === void 0 ? void 0 : adsenseConfig.page_url) || null;
// Returns 'http://www.example.com'.

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
    },
  })
  .addService(googletag.pubads());

const adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes;
const pageUrl = adsenseConfig?.page_url || null;
// Returns 'http://www.example.com'.
আরও দেখুন
Parameters
key : string Name of the attribute to look for.
ফেরত
string Current value for the attribute key, or null if the key is not present.

getAdUnitPath

getAdUnitPath ( ) : string
Returns the full path of the ad unit, with the network code and ad unit path.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

slot.getAdUnitPath();
// Returns '/1234567/sports'.

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

slot.getAdUnitPath();
// Returns '/1234567/sports'.

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

slot.getAdUnitPath();
// Returns '/1234567/sports'.
ফেরত
string Ad unit path.

getAttributeKeys

getAttributeKeys ( ) : string []
Returns the list of attribute keys set on this slot. To see the keys of service-level attributes inherited by this slot, use PubAdsService.getAttributeKeys .
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
      document_language: "en",
    },
  })
  .addService(googletag.pubads());

const adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes;
const adsenseAttributes = Object.keys(adsenseConfig || {});
// Returns ['page_url', 'document_language'].

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
      document_language: "en",
    },
  })
  .addService(googletag.pubads());

var adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes;
var adsenseAttributes = Object.keys(adsenseConfig || {});
// Returns ['page_url', 'document_language'].

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
      document_language: "en",
    },
  })
  .addService(googletag.pubads());

const adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes;
const adsenseAttributes = Object.keys(adsenseConfig || {});
// Returns ['page_url', 'document_language'].
ফেরত
string [] Array of attribute keys. Ordering is undefined.

getCategoryExclusions

getCategoryExclusions ( ) : string []
Returns the ad category exclusion labels for this slot.
উদাহরণ

জাভাস্ক্রিপ্ট

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    categoryExclusion: ["AirlineAd", "TrainAd"],
  })
  .addService(googletag.pubads());

const exclusions = slot.getConfig("categoryExclusion")?.categoryExclusion || [];
// Returns ['AirlineAd', 'TrainAd'].

JavaScript (legacy)

var _a;
var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    categoryExclusion: ["AirlineAd", "TrainAd"],
  })
  .addService(googletag.pubads());

var exclusions =
  ((_a = slot.getConfig("categoryExclusion")) === null || _a === void 0
    ? void 0
    : _a.categoryExclusion) || [];
// Returns ['AirlineAd', 'TrainAd'].

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    categoryExclusion: ["AirlineAd", "TrainAd"],
  })
  .addService(googletag.pubads());

const exclusions = slot.getConfig("categoryExclusion")?.categoryExclusion || [];
// Returns ['AirlineAd', 'TrainAd'].
ফেরত
string [] The ad category exclusion labels for this slot, or an empty array if none have been set.

getConfig

getConfig ( keys : string | string [] ) : Readonly < Pick < SlotSettingsConfig , "adsenseAttributes" | "targeting" | "categoryExclusion" > >
Gets a frozen copy of the general configuration options for the slot set by setConfig .

Not all setConfig() properties are supported by this method. Supported properties are:
উদাহরণ

JavaScript

const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div");

// Get the value of the `targeting` setting.
const targetingConfig = slot.getConfig("targeting");

// Get the value of the `adsenseAttributes` and `categoryExclusion` settings.
const config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);

JavaScript (legacy)

var slot = googletag.defineSlot("/1234567/sports", [160, 600], "div");

// Get the value of the `targeting` setting.
var targetingConfig = slot.getConfig("targeting");

// Get the value of the `adsenseAttributes` and `categoryExclusion` settings.
var config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);

TypeScript

const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!;

// Get the value of the `targeting` setting.
const targetingConfig = slot.getConfig("targeting");

// Get the value of the `adsenseAttributes` and `categoryExclusion` settings.
const config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
Parameters
keys : string | string [] The keys of the configuration options to get.
ফেরত
Readonly < Pick < SlotSettingsConfig , "adsenseAttributes" | "targeting" | "categoryExclusion" > > A frozen copy of the configuration options for the slot.

getResponseInformation

getResponseInformation ( ) : ResponseInformation
Returns the ad response information. This is based on the last ad response for the slot. If this is called when the slot has no ad, null will be returned.
ফেরত
ResponseInformation The latest ad response information, or null if the slot has no ad.

getSlotElementId

getSlotElementId ( ) : string
Returns the ID of the slot div provided when the slot was defined.
উদাহরণ

JavaScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

slot.getSlotElementId();
// Returns 'div'.

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

slot.getSlotElementId();
// Returns 'div'.

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

slot.getSlotElementId();
// Returns 'div'.
ফেরত
string Slot div ID.

getTargeting

getTargeting ( key : string ) : string []
Returns a specific custom targeting parameter set on this slot. Service-level targeting parameters are not included.
Example

JavaScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    targeting: {
      allow_expandable: "true",
    },
  })
  .addService(googletag.pubads());

const targetingConfig = slot.getConfig("targeting").targeting;

// Get targeting for a specific key.
const targeting = targetingConfig?.["allow_expandable"] || [];
// Returns ['true'].

const ageTargeting = targetingConfig?.["age"] || [];
// Returns [] (empty array).

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    targeting: {
      allow_expandable: "true",
    },
  })
  .addService(googletag.pubads());

var targetingConfig = slot.getConfig("targeting").targeting;

// Get targeting for a specific key.
var targeting =
  (targetingConfig === null || targetingConfig === void 0
    ? void 0
    : targetingConfig["allow_expandable"]) || [];
// Returns ['true'].

var ageTargeting =
  (targetingConfig === null || targetingConfig === void 0 ? void 0 : targetingConfig["age"]) || [];
// Returns [] (empty array).

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    targeting: {
      allow_expandable: "true",
    },
  })
  .addService(googletag.pubads());

const targetingConfig = slot.getConfig("targeting").targeting;

// Get targeting for a specific key.
const targeting = targetingConfig?.["allow_expandable"] || [];
// Returns ['true'].

const ageTargeting = targetingConfig?.["age"] || [];
// Returns [] (empty array).
Parameters
key : string The targeting key to look for.
ফেরত
string [] The values associated with this key, or an empty array if there is no such key.

getTargetingKeys

getTargetingKeys ( ) : string []
Returns the list of all custom targeting keys set on this slot. Service-level targeting keys are not included.
উদাহরণ

JavaScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    targeting: {
      allow_expandable: "true",
      interests: ["sports", "music"],
    },
  })
  .addService(googletag.pubads());

const targetingConfig = slot.getConfig("targeting").targeting;
const keys = Object.keys(targetingConfig || {});
// Returns ['interests', 'allow_expandable'].

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    targeting: {
      allow_expandable: "true",
      interests: ["sports", "music"],
    },
  })
  .addService(googletag.pubads());

var targetingConfig = slot.getConfig("targeting").targeting;
var keys = Object.keys(targetingConfig || {});
// Returns ['interests', 'allow_expandable'].

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    targeting: {
      allow_expandable: "true",
      interests: ["sports", "music"],
    },
  })
  .addService(googletag.pubads());

const targetingConfig = slot.getConfig("targeting").targeting;
const keys = Object.keys(targetingConfig || {});
// Returns ['interests', 'allow_expandable'].
ফেরত
string [] Array of targeting keys. Ordering is undefined.

সেট

set ( key : string , value : string ) : Slot
Sets a value for an AdSense attribute on this ad slot. This will override any values set at the service level for this key.

Calling this method more than once for the same key will override previously set values for that key. All values must be set before calling display or refresh .
Example

JavaScript

// Setting an attribute on a single ad slot.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
    },
  })
  .addService(googletag.pubads());

JavaScript (legacy)

// Setting an attribute on a single ad slot.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
    },
  })
  .addService(googletag.pubads());

TypeScript

// Setting an attribute on a single ad slot.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    adsenseAttributes: {
      page_url: "http://www.example.com",
    },
  })
  .addService(googletag.pubads());
আরও দেখুন
Parameters
key : string The name of the attribute.
value : string Attribute value.
ফেরত
Slot The slot object on which the method was called.

setCategoryExclusion

setCategoryExclusion ( categoryExclusion : string ) : Slot
Sets a slot-level ad category exclusion label on this slot.
Example

JavaScript

// Label = AirlineAd.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    categoryExclusion: ["AirlineAd"],
  })
  .addService(googletag.pubads());

JavaScript (legacy)

// Label = AirlineAd.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    categoryExclusion: ["AirlineAd"],
  })
  .addService(googletag.pubads());

TypeScript

// Label = AirlineAd.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    categoryExclusion: ["AirlineAd"],
  })
  .addService(googletag.pubads());
আরও দেখুন
Parameters
categoryExclusion : string The ad category exclusion label to add.
ফেরত
Slot The slot object on which the method was called.

setClickUrl

setClickUrl ( value : string ) : Slot
Sets the click URL to which users will be redirected after clicking on the ad.

The Google Ad Manager servers still record a click even if the click URL is replaced. Any landing page URL associated with the creative that is served is appended to the provided value. Subsequent calls overwrite the value. This works only for non-SRA requests.
Example

JavaScript

googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    clickUrl: "http://www.example.com?original_click_url=",
  })
  .addService(googletag.pubads());

JavaScript (legacy)

googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setConfig({
    clickUrl: "http://www.example.com?original_click_url=",
  })
  .addService(googletag.pubads());

TypeScript

googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setConfig({
    clickUrl: "http://www.example.com?original_click_url=",
  })
  .addService(googletag.pubads());
Parameters
value : string The click URL to set.
ফেরত
Slot The slot object on which the method was called.

setCollapseEmptyDiv

setCollapseEmptyDiv ( collapse : boolean , collapseBeforeAdFetch ?: boolean ) : Slot
Sets whether the slot div should be hidden when there is no ad in the slot. This overrides the service-level settings.
Example

JavaScript

const slot1 = googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setConfig({
    collapseDiv: "BEFORE_FETCH",
  })
  .addService(googletag.pubads());
// The above will cause the div for this slot to be collapsed
// when the page is loaded, before ads are requested.

const slot2 = googletag
  .defineSlot("/1234567/sports", [160, 600], "div-2")
  .setConfig({
    collapseDiv: "ON_NO_FILL",
  })
  .addService(googletag.pubads());
// The above will cause the div for this slot to be collapsed
// only after GPT detects that no ads are available for the slot.

JavaScript (legacy)

var slot1 = googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setConfig({
    collapseDiv: "BEFORE_FETCH",
  })
  .addService(googletag.pubads());
// The above will cause the div for this slot to be collapsed
// when the page is loaded, before ads are requested.

var slot2 = googletag
  .defineSlot("/1234567/sports", [160, 600], "div-2")
  .setConfig({
    collapseDiv: "ON_NO_FILL",
  })
  .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

const slot1 = googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")!
  .setConfig({
    collapseDiv: "BEFORE_FETCH",
  })
  .addService(googletag.pubads());
// The above will cause the div for this slot to be collapsed
// when the page is loaded, before ads are requested.

const slot2 = googletag
  .defineSlot("/1234567/sports", [160, 600], "div-2")!
  .setConfig({
    collapseDiv: "ON_NO_FILL",
  })
  .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.
আরও দেখুন
Parameters
collapse : boolean Whether to collapse the slot if no ad is returned.
Optional collapseBeforeAdFetch : boolean Whether to collapse the slot even before an ad is fetched. Ignored if collapse is not true .
ফেরত
Slot The slot object on which the method was called.

setConfig

setConfig ( slotConfig : SlotSettingsConfig ) : Slot
Sets general configuration options for this slot.
Parameters
slotConfig : SlotSettingsConfig The configuration object.
ফেরত
Slot The slot object on which the method was called.

setForceSafeFrame

setForceSafeFrame ( forceSafeFrame : boolean ) : Slot
Configures whether ads in this slot should be forced to be rendered using a SafeFrame container.

Please keep the following things in mind while using this API:
  • This setting will only take effect for subsequent ad requests made for the respective slots.
  • The slot level setting, if specified, will always override the page level setting.
  • If set to true (at slot-level or page level), the ad will always be rendered using a SafeFrame container independent of the choice made in the Google Ad Manager UI.
  • However, if set to false or left unspecified, the ad will be rendered using a SafeFrame container depending on the type of creative and the selection made in the Google Ad Manager UI.
  • This API should be used with caution as it could impact the behaviour of creatives that attempt to break out of their iFrames or rely on them being rendered directly in a publishers page.
Example

JavaScript

googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setForceSafeFrame(true)
  .addService(googletag.pubads());

JavaScript (legacy)

googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .setForceSafeFrame(true)
  .addService(googletag.pubads());

TypeScript

googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .setForceSafeFrame(true)
  .addService(googletag.pubads());
আরও দেখুন
Parameters
forceSafeFrame : boolean true to force all ads in this slot to be rendered in SafeFrames and false to opt-out of a page-level setting (if present). Setting this to false when not specified at the page-level won't change anything.
ফেরত
Slot The slot object on which the method was called.

setSafeFrameConfig

setSafeFrameConfig ( config : SafeFrameConfig ) : Slot
Sets the slot-level preferences for SafeFrame configuration. Any unrecognized keys in the config object will be ignored. The entire config will be ignored if an invalid value is passed for a recognized key.

These slot-level preferences, if specified, will override any page-level preferences.
Example

JavaScript

googletag.pubads().setForceSafeFrame(true);

// The following slot will have a sandboxed safeframe that only
// disallows top-level navigation.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setSafeFrameConfig({ sandbox: true })
  .addService(googletag.pubads());

// The following slot will inherit page-level settings.
googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads());

googletag.display("div-1");
googletag.display("div-2");

JavaScript (legacy)

googletag.pubads().setForceSafeFrame(true);

// The following slot will have a sandboxed safeframe that only
// disallows top-level navigation.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")
  .setSafeFrameConfig({ sandbox: true })
  .addService(googletag.pubads());

// The following slot will inherit page-level settings.
googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads());

googletag.display("div-1");
googletag.display("div-2");

TypeScript

googletag.pubads().setForceSafeFrame(true);

// The following slot will have a sandboxed safeframe that only
// disallows top-level navigation.
googletag
  .defineSlot("/1234567/sports", [160, 600], "div-1")!
  .setSafeFrameConfig({ sandbox: true })
  .addService(googletag.pubads());

// The following slot will inherit page-level settings.
googletag.defineSlot("/1234567/news", [160, 600], "div-2")!.addService(googletag.pubads());

googletag.display("div-1");
googletag.display("div-2");
আরও দেখুন
Parameters
config : SafeFrameConfig The configuration object.
ফেরত
Slot The slot object on which the method was called.

setTargeting

setTargeting ( key : string , value : string | string [] ) : Slot
Sets a custom targeting parameter for this slot. Calling this method multiple times for the same key will overwrite old values. Values set here will overwrite targeting parameters set at the service-level. These keys are defined in your Google Ad Manager account.
উদাহরণ

JavaScript

const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div");
slot.addService(googletag.pubads());

// Example with a single value for a key.
slot.setConfig({
  targeting: {
    allow_expandable: "true",
  },
});

// Example with multiple values for a key inside in an array.
slot.setConfig({
  targeting: {
    interests: ["sports", "music"],
  },
});

JavaScript (legacy)

var slot = googletag.defineSlot("/1234567/sports", [160, 600], "div");
slot.addService(googletag.pubads());

// Example with a single value for a key.
slot.setConfig({
  targeting: {
    allow_expandable: "true",
  },
});

// Example with multiple values for a key inside in an array.
slot.setConfig({
  targeting: {
    interests: ["sports", "music"],
  },
});

TypeScript

const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!;
slot.addService(googletag.pubads());

// Example with a single value for a key.
slot.setConfig({
  targeting: {
    allow_expandable: "true",
  },
});

// Example with multiple values for a key inside in an array.
slot.setConfig({
  targeting: {
    interests: ["sports", "music"],
  },
});
আরও দেখুন
Parameters
key : string Targeting parameter key.
value : string | string [] Targeting parameter value or array of values.
ফেরত
Slot The slot object on which the method was called.

updateTargetingFromMap

updateTargetingFromMap ( map : {
  [ adUnitPath : string ] : string | string [] ;
} ) : Slot
Sets custom targeting parameters for this slot, from a key:value map in a JSON object. This is the same as calling Slot.setTargeting for all the key values of the object. These keys are defined in your Google Ad Manager account.

Notes:
  • In case of overwriting, only the last value will be kept.
  • If the value is an array, any previous value will be overwritten, not merged.
  • Values set here will overwrite targeting parameters set at the service-level.
Example

JavaScript

const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div");

slot.updateTargetingFromMap({
  color: "red",
  interests: ["sports", "music", "movies"],
});

JavaScript (legacy)

var slot = googletag.defineSlot("/1234567/sports", [160, 600], "div");

slot.updateTargetingFromMap({
  color: "red",
  interests: ["sports", "music", "movies"],
});

TypeScript

const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!;

slot.updateTargetingFromMap({
  color: "red",
  interests: ["sports", "music", "movies"],
});
Parameters
map : {
  [ adUnitPath : string ] : string | string [] ;
}
Targeting parameter key:value map.
ফেরত
Slot The slot object on which the method was called.

googletag.config

Main configuration interface for page-level settings.
ইন্টারফেস
Ad Expansion Config
Settings to control ad expansion.
Ad Sense Attributes Config
Settings to control the behavior of AdSense ads.
Auto Refresh Config
Auto refresh configuration settings.
Continue Button Config
Settings to configure the continue button behavior.
Interstitial Config
An object which defines the behavior of a single interstitial ad slot.
Lazy Load Config
Settings to control the use of lazy loading in GPT.
Page Settings Config
Main configuration interface for page-level settings.
Privacy Treatments Config
Settings to control publisher privacy treatments.
Publisher Provided Signals Config
Publisher provided signals (PPS) configuration object.
Safe Frame Config
Settings to control SafeFrame in GPT.
Slot Settings Config
Main configuration interface for slot-level settings.
Taxonomy Data
An object containing the values for a single Taxonomy .
Video Ads Config
Settings to configure video ad related settings.
Type Aliases
Collapse Div Behavior
Supported values for controlling the collapsing behavior of ad slots.
Interstitial Trigger
Supported interstitial ad triggers.
Privacy Treatment
Supported publisher privacy treatments.
Taxonomy
Supported taxonomies for publisher provided signals (PPS) .

Type Aliases


CollapseDivBehavior

CollapseDivBehavior : "DISABLED" | "BEFORE_FETCH" | "ON_NO_FILL"
Supported values for controlling the collapsing behavior of ad slots.
আরও দেখুন

InterstitialTrigger

InterstitialTrigger : "unhideWindow" | "navBar" | "inactivity" | "endOfArticle" | "continueReading" | "backward"
Supported interstitial ad triggers.

Note : Beginning June 15, 2026, the backward trigger will no longer be supported and enabling it will have no effect. See the GPT release notes for more information.

PrivacyTreatment

PrivacyTreatment : "disablePersonalization"
Supported publisher privacy treatments.

শ্রেণিবিন্যাস

Taxonomy : "IAB_AUDIENCE_1_1" | "IAB_CONTENT_2_2"
Supported taxonomies for publisher provided signals (PPS) .
আরও দেখুন

googletag.config.AdExpansionConfig

Settings to control ad expansion.
বৈশিষ্ট্য
enabled ?
Whether ad expansion is enabled or disabled.
Example

JavaScript

// Enable ad slot expansion across the entire page.
googletag.setConfig({
  adExpansion: { enabled: true },
});

JavaScript (legacy)

// Enable ad slot expansion across the entire page.
googletag.setConfig({
  adExpansion: { enabled: true },
});

TypeScript

// Enable ad slot expansion across the entire page.
googletag.setConfig({
  adExpansion: { enabled: true },
});

বৈশিষ্ট্য


Optional enabled

enabled ?: boolean
Whether ad expansion is enabled or disabled.

Setting this value overrides the default configured in Google Ad Manager.
আরও দেখুন

googletag.config.AdSenseAttributesConfig

Settings to control the behavior of AdSense ads.

These attributes can be used to override server-side settings on a per-request basis.
বৈশিষ্ট্য
adsense _ad _format ?
AdSense ad format.
adsense _channel _ids ?
AdSense channel IDs.
adsense _test _mode ?
Whether or not test mode is enabled.
document _language ?
Language of the page on which ads are displayed.
page _url ?
URL of the page on which ads are displayed.
আরও দেখুন

বৈশিষ্ট্য


Optional adsense_ad_format

adsense_ad_format ?: "120x240_as" | "120x600_as" | "125x125_as" | "160x600_as" | "180x150_as" | "200x200_as" | "234x60_as" | "250x250_as" | "300x250_as" | "336x280_as" | "468x60_as" | "728x90_as"
AdSense ad format.

Optional adsense_channel_ids

adsense_channel_ids ?: string
AdSense channel IDs.

Allowed values are channel IDs separated by '+'.

Example: 271828183+314159265
আরও দেখুন

Optional adsense_test_mode

adsense_test_mode ?: "on"
Whether or not test mode is enabled.

When set to on , ads are marked as test-only, and won't be included in counting or billing. This setting must be unset for production, non-test traffic.

Optional document_language

document_language ?: string
Language of the page on which ads are displayed.

Allowed values are valid ISO 639-1 language codes.

Example: en
আরও দেখুন

Optional page_url

page_url ?: string
URL of the page on which ads are displayed.

Allowed values are valid URLs.

Example: http://www.example.com

googletag.config.AutoRefreshConfig

Auto refresh configuration settings.
বৈশিষ্ট্য
heavy Ads ?
Whether GPT will automatically refresh an ad slot if Chrome's Heavy Ad Intervention triggers on the slot's ad iframe.

বৈশিষ্ট্য


Optional heavyAds

heavyAds ?: boolean
Whether GPT will automatically refresh an ad slot if Chrome's Heavy Ad Intervention triggers on the slot's ad iframe. Defaults to true .
Example

JavaScript

// Set the auto refresh configuration, disabling auto refresh on heavy
// ad intervention.
googletag.setConfig({ autoRefresh: { heavyAds: false } });

// Clear the auto refresh configuration, restoring to default behavior.
googletag.setConfig({ autoRefresh: null });

JavaScript (legacy)

// Set the auto refresh configuration, disabling auto refresh on heavy
// ad intervention.
googletag.setConfig({ autoRefresh: { heavyAds: false } });

// Clear the auto refresh configuration, restoring to default behavior.
googletag.setConfig({ autoRefresh: null });

TypeScript

// Set the auto refresh configuration, disabling auto refresh on heavy
// ad intervention.
googletag.setConfig({ autoRefresh: { heavyAds: false } });

// Clear the auto refresh configuration, restoring to default behavior.
googletag.setConfig({ autoRefresh: null });
আরও দেখুন

googletag.config.ContinueButtonConfig

Settings to configure the continue button behavior.
বৈশিষ্ট্য
background Color ?
The background color of the button.
font ?
The font family of the button text.
font Color ?
The text color of the button.
freq Cap Interval Minutes ?
The frequency capping interval in minutes.
target Id ?
The ID of the HTML element on which to render/trigger the continue button.
আরও দেখুন

বৈশিষ্ট্য


Optional backgroundColor

backgroundColor ?: string
The background color of the button.

Example: 'blue' , '#94B1FF'

Optional font

font ?: string
The font family of the button text.

Example: 'Arial'

Optional fontColor

fontColor ?: string
The text color of the button.

Example: 'white' , '#B73B87'

Optional freqCapIntervalMinutes

freqCapIntervalMinutes ?: number
The frequency capping interval in minutes.

Must be an integer greater than or equal to 1.

Optional targetId

targetId ?: string
The ID of the HTML element on which to render/trigger the continue button.

googletag.config.InterstitialConfig

An object which defines the behavior of a single interstitial ad slot.
বৈশিষ্ট্য
require Storage Access ?
Whether local storage consent is required to display this interstitial ad.
triggers ?
The interstitial trigger configuration for this interstitial ad.

বৈশিষ্ট্য


Optional requireStorageAccess

requireStorageAccess ?: boolean
Whether local storage consent is required to display this interstitial ad.

GPT uses local storage to enforce a frequency cap for interstitial ads. However, users who have not provided local storage consent are still eligible to be served interstitial ads. Setting this property to true opts out of the default behavior, and ensures interstitial ads are only shown to users who have provided local storage consent.
Example

JavaScript

// Opt out of showing interstitials to users
// without local storage consent.
const interstitialSlot = googletag.defineOutOfPageSlot(
  "/1234567/sports",
  googletag.enums.OutOfPageFormat.INTERSTITIAL,
);

interstitialSlot.setConfig({
  interstitial: {
    requireStorageAccess: true, // defaults to false
  },
});

JavaScript (legacy)

// Opt out of showing interstitials to users
// without local storage consent.
var interstitialSlot = googletag.defineOutOfPageSlot(
  "/1234567/sports",
  googletag.enums.OutOfPageFormat.INTERSTITIAL,
);

interstitialSlot.setConfig({
  interstitial: {
    requireStorageAccess: true, // defaults to false
  },
});

TypeScript

// Opt out of showing interstitials to users
// without local storage consent.
const interstitialSlot = googletag.defineOutOfPageSlot(
  "/1234567/sports",
  googletag.enums.OutOfPageFormat.INTERSTITIAL,
)!;

interstitialSlot.setConfig({
  interstitial: {
    requireStorageAccess: true, // defaults to false
  },
});
আরও দেখুন

Optional triggers

triggers ?: Partial < Record < InterstitialTrigger , boolean > >
The interstitial trigger configuration for this interstitial ad.

Setting the value of an interstitial trigger to true will enable it and false will disable it. This will override the default values configured in Google Ad Manager .
Example

JavaScript

// Define a GPT managed web interstitial ad slot.
const interstitialSlot = googletag.defineOutOfPageSlot(
  "/1234567/sports",
  googletag.enums.OutOfPageFormat.INTERSTITIAL,
);

// Enable optional interstitial triggers.
// Change this value to false to disable.
const enableTriggers = true;

interstitialSlot.setConfig({
  interstitial: {
    triggers: {
      navBar: enableTriggers,
      unhideWindow: enableTriggers,
    },
  },
});

JavaScript (legacy)

// Define a GPT managed web interstitial ad slot.
var interstitialSlot = googletag.defineOutOfPageSlot(
  "/1234567/sports",
  googletag.enums.OutOfPageFormat.INTERSTITIAL,
);

// Enable optional interstitial triggers.
// Change this value to false to disable.
var enableTriggers = true;

interstitialSlot.setConfig({
  interstitial: {
    triggers: {
      navBar: enableTriggers,
      unhideWindow: enableTriggers,
    },
  },
});

TypeScript

// Define a GPT managed web interstitial ad slot.
const interstitialSlot = googletag.defineOutOfPageSlot(
  "/1234567/sports",
  googletag.enums.OutOfPageFormat.INTERSTITIAL,
)!;

// Enable optional interstitial triggers.
// Change this value to false to disable.
const enableTriggers = true;

interstitialSlot.setConfig({
  interstitial: {
    triggers: {
      navBar: enableTriggers,
      unhideWindow: enableTriggers,
    },
  },
});
আরও দেখুন

googletag.config.LazyLoadConfig

Settings to control the use of lazy loading in GPT.
বৈশিষ্ট্য
fetch Margin Percent ?
The minimum distance from the current viewport a slot must be before we request an ad, expressed as a percentage of viewport size.
mobile Scaling ?
A multiplier applied to margins on mobile devices.
render Margin Percent ?
The minimum distance from the current viewport a slot must be before we render an ad, expressed as a percentage of viewport size.
আরও দেখুন

বৈশিষ্ট্য


Optional fetchMarginPercent

fetchMarginPercent ?: number
The minimum distance from the current viewport a slot must be before we request an ad, expressed as a percentage of viewport size.

Used in conjunction with renderMarginPercent , this setting allows for prefetching an ad, but waiting to render and download other subresources. As such, this value should always be greater than or equal to renderMarginPercent .

A value of 0 means "when the slot enters the viewport", 100 means "when the ad is 1 viewport away", and so on.

Optional mobileScaling

mobileScaling ?: number
A multiplier applied to margins on mobile devices. This multiplier is applied to both fetchMarginPercent and renderMarginPercent .

This allows for different margins on mobile vs. desktop, where viewport sizes and scroll speeds may be different. For example, a value of 2.0 will multiply all margins by 2 on mobile devices, increasing the minimum distance a slot can be from the viewport before fetching and rendering.

Optional renderMarginPercent

renderMarginPercent ?: number
The minimum distance from the current viewport a slot must be before we render an ad, expressed as a percentage of viewport size.

Used in conjunction with fetchMarginPercent , this setting allows for prefetching an ad, but waiting to render and download other subresources. As such, this value should always be less than or equal to fetchMarginPercent .

A value of 0 means "when the slot enters the viewport", 100 means "when the ad is 1 viewport away", and so on.

googletag.config.PageSettingsConfig

Main configuration interface for page-level settings.

Allows setting multiple features with a single API call.

All properties listed below are examples and do not reflect actual features that utilize setConfig. For the set of features, see fields within the PageSettingsConfig type below.

উদাহরণ:
  • Only features specified in the googletag.setConfig call are modified.
      // Configure feature alpha.
      googletag.setConfig({
          alpha: {...}
      });
    
      // Configure feature bravo. Feature alpha is unchanged.
      googletag.setConfig({
         bravo: {...}
      });
  • All settings for a given feature are updated with each call to googletag.setConfig .
      // Configure feature charlie to echo = 1, foxtrot = true.
      googletag.setConfig({
          charlie: {
              echo: 1,
              foxtrot: true,
          }
      });
    
      // Update feature charlie to echo = 2. Since foxtrot was not specified,
      // the value is cleared.
      googletag.setConfig({
          charlie: {
              echo: 2
          }
      });
  • All settings for a feature can be cleared by passing 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,
      });
বৈশিষ্ট্য
ad Expansion ?
Settings to control ad expansion.
adsense Attributes ?
Setting to configure AdSense attributes.
ad Yield ?
Deprecated.
auto Refresh ?
Setting to configure automatic ad refresh behavior.
category Exclusion ?
Setting to configure ad category exclusions.
centering ?
Setting to control the horizontal centering of ads.
collapse Div ?
Setting to control the collapsing behavior of ad slots.
disable Initial Load ?
Setting to control when ads are requested.
lazy Load ?
Settings to control the use of lazy loading in GPT.
location ?
Setting to geo-target line items to geographic locations.
pps ?
Settings to control publisher provided signals (PPS).
privacy Treatments ?
Settings to control publisher privacy treatments.
safe Frame ?
Settings to control the use of SafeFrame in GPT.
single Request ?
Setting to enable or disable Single Request Architecture (SRA).
targeting ?
Setting to control key-value targeting.
thread Yield ?
Setting to control whether GPT should yield the JS thread when requesting and rendering creatives.
video Ads ?
Settings to control video ads.

বৈশিষ্ট্য


Optional adExpansion

adExpansion ?: AdExpansionConfig
Settings to control ad expansion.

Optional adsenseAttributes

adsenseAttributes ?: AdSenseAttributesConfig
Setting to configure AdSense attributes.

AdSense attributes configured via this setting will apply to all ad slots on the page. This setting may be called multiple times to define multiple attribute values, or overwrite existing values.

AdSense attribute changes only apply to ads requested after this method has been called. For that reason, it is recommended to call this method before any calls to googletag.display or PubAdsService.refresh .
Example

JavaScript

// Set the document language and page URL.
googletag.setConfig({
  adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" },
});

// Clear the page URL only.
googletag.setConfig({ adsenseAttributes: { page_url: null } });

// Clear all AdSense attributes.
googletag.setConfig({ adsenseAttributes: null });

JavaScript (legacy)

// Set the document language and page URL.
googletag.setConfig({
  adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" },
});

// Clear the page URL only.
googletag.setConfig({ adsenseAttributes: { page_url: null } });

// Clear all AdSense attributes.
googletag.setConfig({ adsenseAttributes: null });

TypeScript

// Set the document language and page URL.
googletag.setConfig({
  adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" },
});

// Clear the page URL only.
googletag.setConfig({ adsenseAttributes: { page_url: null } });

// Clear all AdSense attributes.
googletag.setConfig({ adsenseAttributes: null });

Optional adYield

adYield ?: "DISABLED" | "ENABLED_ALL_SLOTS"

Optional autoRefresh

autoRefresh ?: AutoRefreshConfig
Setting to configure automatic ad refresh behavior.
Example

JavaScript

// Set the auto refresh configuration.
googletag.setConfig({ autoRefresh: { heavyAds: false } });

// Clear the auto refresh configuration.
googletag.setConfig({ autoRefresh: null });

JavaScript (legacy)

// Set the auto refresh configuration.
googletag.setConfig({ autoRefresh: { heavyAds: false } });

// Clear the auto refresh configuration.
googletag.setConfig({ autoRefresh: null });

TypeScript

// Set the auto refresh configuration.
googletag.setConfig({ autoRefresh: { heavyAds: false } });

// Clear the auto refresh configuration.
googletag.setConfig({ autoRefresh: null });

Optional categoryExclusion

categoryExclusion ?: string []
Setting to configure ad category exclusions.
Example

JavaScript

// Label = AirlineAd.
googletag.setConfig({ categoryExclusion: ["AirlineAd"] });

// Clearing category exclusion setting.
googletag.setConfig({ categoryExclusion: null });

JavaScript (legacy)

// Label = AirlineAd.
googletag.setConfig({ categoryExclusion: ["AirlineAd"] });

// Clearing category exclusion setting.
googletag.setConfig({ categoryExclusion: null });

TypeScript

// Label = AirlineAd.
googletag.setConfig({ categoryExclusion: ["AirlineAd"] });

// Clearing category exclusion setting.
googletag.setConfig({ categoryExclusion: null });
আরও দেখুন

Optional centering

centering ?: boolean
Setting to control the horizontal centering of ads. Centering is disabled by default.

Horizontal centering changes only apply to ads requested after this method has been called. For that reason, it is recommended to call this method before any calls to googletag.display or PubAdsService.refresh .
Example

JavaScript

// Make ads centered.
googletag.setConfig({ centering: true });

// Clear the centering setting.
googletag.setConfig({ centering: null });

JavaScript (legacy)

// Make ads centered.
googletag.setConfig({ centering: true });

// Clear the centering setting.
googletag.setConfig({ centering: null });

TypeScript

// Make ads centered.
googletag.setConfig({ centering: true });

// Clear the centering setting.
googletag.setConfig({ centering: null });

Optional collapseDiv

collapseDiv ?: CollapseDivBehavior
Setting to control the collapsing behavior of ad slots.

A collapsed ad slot does not take up any space on the page.

Supported values:
  • null (default): The slot will not be collapsed.
  • DISABLED : The slot will not collapse, whether or not an ad is returned.
  • BEFORE_FETCH : The slot will start out collapsed, and expand when an ad is returned.
  • ON_NO_FILL : The slot will start out expanded, and collapse if no ad is returned.
Example

JavaScript

// Collapse the div for this slot if no ad is returned.
googletag.setConfig({ collapseDiv: "ON_NO_FILL" });

// Collapse the div for this slot by default, and expand only
// if an ad is returned.
googletag.setConfig({ collapseDiv: "BEFORE_FETCH" });

// Do not collapse the div for this slot.
googletag.setConfig({ collapseDiv: "DISABLED" });

// Clear the collapse setting.
googletag.setConfig({ collapseDiv: null });

JavaScript (legacy)

// Collapse the div for this slot if no ad is returned.
googletag.setConfig({ collapseDiv: "ON_NO_FILL" });

// Collapse the div for this slot by default, and expand only
// if an ad is returned.
googletag.setConfig({ collapseDiv: "BEFORE_FETCH" });

// Do not collapse the div for this slot.
googletag.setConfig({ collapseDiv: "DISABLED" });

// Clear the collapse setting.
googletag.setConfig({ collapseDiv: null });

TypeScript

// Collapse the div for this slot if no ad is returned.
googletag.setConfig({ collapseDiv: "ON_NO_FILL" });

// Collapse the div for this slot by default, and expand only
// if an ad is returned.
googletag.setConfig({ collapseDiv: "BEFORE_FETCH" });

// Do not collapse the div for this slot.
googletag.setConfig({ collapseDiv: "DISABLED" });

// Clear the collapse setting.
googletag.setConfig({ collapseDiv: null });
আরও দেখুন

Optional disableInitialLoad

disableInitialLoad ?: boolean
Setting to control when ads are requested.

By default, the googletag.display method both registers ad slots and requests ads for them. However, there are times when it may be preferable to separate these actions, in order to more precisely control when ad content is loaded.

By enabling this setting, ads will not be requested for registered slots when the display() method is called. Instead, a separate call to PubAdsService.refresh must be made to initiate an ad request.

This method must be called before calling googletag.enableServices .
Example

JavaScript

// Prevent requesting ads when `display()` is called.
googletag.setConfig({ disableInitialLoad: true });

JavaScript (legacy)

// Prevent requesting ads when `display()` is called.
googletag.setConfig({ disableInitialLoad: true });

TypeScript

// Prevent requesting ads when `display()` is called.
googletag.setConfig({ disableInitialLoad: true });
See also

Optional lazyLoad

lazyLoad ?: LazyLoadConfig
Settings to control the use of lazy loading in GPT.

Lazy loading is a technique to delay the requesting and rendering of ads until they approach the user's viewport. For a more detailed example, see the Lazy loading sample.

Note: If singleRequest is enabled, lazy fetching only works when all slots are outside the fetch margin.

Any lazy load settings which are not specified when calling setConfig() will use a default value set by Google. These defaults may be tuned over time. To disable a particular setting, set the value to null .
Example

JavaScript

// Enable lazy loading.
googletag.setConfig({
  lazyLoad: {
    // Fetch slots within 5 viewports.
    fetchMarginPercent: 500,
    // Render slots within 2 viewports.
    renderMarginPercent: 200,
    // Double the above values on mobile.
    mobileScaling: 2.0,
  },
});

// Clear fetch margin only.
googletag.setConfig({
  lazyLoad: { fetchMarginPercent: null },
});

// Clear all lazy loading settings.
googletag.setConfig({ lazyLoad: null });

JavaScript (legacy)

// Enable lazy loading.
googletag.setConfig({
  lazyLoad: {
    // Fetch slots within 5 viewports.
    fetchMarginPercent: 500,
    // Render slots within 2 viewports.
    renderMarginPercent: 200,
    // Double the above values on mobile.
    mobileScaling: 2.0,
  },
});

// Clear fetch margin only.
googletag.setConfig({
  lazyLoad: { fetchMarginPercent: null },
});

// Clear all lazy loading settings.
googletag.setConfig({ lazyLoad: null });

TypeScript

// Enable lazy loading.
googletag.setConfig({
  lazyLoad: {
    // Fetch slots within 5 viewports.
    fetchMarginPercent: 500,
    // Render slots within 2 viewports.
    renderMarginPercent: 200,
    // Double the above values on mobile.
    mobileScaling: 2.0,
  },
});

// Clear fetch margin only.
googletag.setConfig({
  lazyLoad: { fetchMarginPercent: null },
});

// Clear all lazy loading settings.
googletag.setConfig({ lazyLoad: null });
See also

Optional location

location ?: string
Setting to geo-target line items to geographic locations.
Example

JavaScript

// Geo-target line items to US postal code 10001.
googletag.setConfig({ location: "10001,US" });

// Clear the location setting.
googletag.setConfig({ location: null });

JavaScript (legacy)

// Geo-target line items to US postal code 10001.
googletag.setConfig({ location: "10001,US" });

// Clear the location setting.
googletag.setConfig({ location: null });

TypeScript

// Geo-target line items to US postal code 10001.
googletag.setConfig({ location: "10001,US" });

// Clear the location setting.
googletag.setConfig({ location: null });
See also

Optional pps

Settings to control publisher provided signals (PPS).

Optional privacyTreatments

privacyTreatments ?: PrivacyTreatmentsConfig
Settings to control publisher privacy treatments.

Optional safeFrame

safeFrame ?: SafeFrameConfig
Settings to control the use of SafeFrame in GPT.

Values configured via this setting will apply to all ad slots on the page. Individual ad slots may override these values via SlotSettingsConfig.safeFrame .
Example

JavaScript

// Force SafeFrame for all ads on the page.
googletag.setConfig({
  safeFrame: { forceSafeFrame: true },
});

// Configure SafeFrame to allow overlay expansion.
googletag.setConfig({
  safeFrame: { allowOverlayExpansion: true },
});

// Clear forceSafeFrame setting.
googletag.setConfig({
  safeFrame: { forceSafeFrame: null },
});

// Clear all SafeFrame settings.
googletag.setConfig({ safeFrame: null });

JavaScript (legacy)

// Force SafeFrame for all ads on the page.
googletag.setConfig({
  safeFrame: { forceSafeFrame: true },
});

// Configure SafeFrame to allow overlay expansion.
googletag.setConfig({
  safeFrame: { allowOverlayExpansion: true },
});

// Clear forceSafeFrame setting.
googletag.setConfig({
  safeFrame: { forceSafeFrame: null },
});

// Clear all SafeFrame settings.
googletag.setConfig({ safeFrame: null });

TypeScript

// Force SafeFrame for all ads on the page.
googletag.setConfig({
  safeFrame: { forceSafeFrame: true },
});

// Configure SafeFrame to allow overlay expansion.
googletag.setConfig({
  safeFrame: { allowOverlayExpansion: true },
});

// Clear forceSafeFrame setting.
googletag.setConfig({
  safeFrame: { forceSafeFrame: null },
});

// Clear all SafeFrame settings.
googletag.setConfig({ safeFrame: null });

Optional singleRequest

singleRequest ?: boolean
Setting to enable or disable Single Request Architecture (SRA).

When SRA is enabled, all ad slots defined prior to a googletag.display or PubAdsService.refresh call will be batched into a single ad request. This provides performance benefits, but is also necessary to ensure roadblocks and competetive exclusions are honored.

When SRA is disabled, each ad slot is requested individually. This is the default behavior of GPT.

This method must be called prior to calling googletag.enableServices .
Example

JavaScript

// Enable Single Request Architecture.
googletag.setConfig({ singleRequest: true });

JavaScript (legacy)

// Enable Single Request Architecture.
googletag.setConfig({ singleRequest: true });

TypeScript

// Enable Single Request Architecture.
googletag.setConfig({ singleRequest: true });
See also

Optional targeting

targeting ?: Record < string , string | string [] >
Setting to control key-value targeting.

Targeting configured via this setting will apply to all ad slots on the page. This setting may be called multiple times to define multiple targeting key-values, or overwrite existing values. Targeting keys are defined in your Google Ad Manager account.
Example

JavaScript

// Setting a single targeting key-value.
googletag.setConfig({ targeting: { interests: "sports" } });

// Setting multiple values for a single targeting key
googletag.setConfig({ targeting: { interests: ["sports", "music"] } });

// Setting multiple targeting key-values at once.
googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });

// Clearing a single targeting key.
googletag.setConfig({ targeting: { interests: null } });

JavaScript (legacy)

// Setting a single targeting key-value.
googletag.setConfig({ targeting: { interests: "sports" } });

// Setting multiple values for a single targeting key
googletag.setConfig({ targeting: { interests: ["sports", "music"] } });

// Setting multiple targeting key-values at once.
googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });

// Clearing a single targeting key.
googletag.setConfig({ targeting: { interests: null } });

TypeScript

// Setting a single targeting key-value.
googletag.setConfig({ targeting: { interests: "sports" } });

// Setting multiple values for a single targeting key
googletag.setConfig({ targeting: { interests: ["sports", "music"] } });

// Setting multiple targeting key-values at once.
googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });

// Clearing a single targeting key.
googletag.setConfig({ targeting: { interests: null } });
See also

Optional threadYield

threadYield ?: "DISABLED" | "ENABLED_ALL_SLOTS"
Setting to control whether GPT should yield the JS thread when requesting and rendering creatives.

GPT will yield only for browsers that support the Scheduler.postTask or Scheduler.yield API.

Supported values:
  • null (default): GPT will yield the JS thread for slots outside of the viewport.
  • ENABLED_ALL_SLOTS : GPT will yield the JS thread for all slots regardless of whether the slot is within the viewport.
  • DISABLED : GPT will not yield the JS thread.
Example

JavaScript

// Disable yielding.
googletag.setConfig({ threadYield: "DISABLED" });

// Enable yielding for all slots.
googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" });

// Enable yielding only for slots outside of the viewport (default).
googletag.setConfig({ threadYield: null });

JavaScript (legacy)

// Disable yielding.
googletag.setConfig({ threadYield: "DISABLED" });

// Enable yielding for all slots.
googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" });

// Enable yielding only for slots outside of the viewport (default).
googletag.setConfig({ threadYield: null });

TypeScript

// Disable yielding.
googletag.setConfig({ threadYield: "DISABLED" });

// Enable yielding for all slots.
googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" });

// Enable yielding only for slots outside of the viewport (default).
googletag.setConfig({ threadYield: null });
See also

Optional videoAds

videoAds ?: VideoAdsConfig
Settings to control video ads.
Example

JavaScript

// Enable video ads and set video content and content source IDs.
googletag.setConfig({
  videoAds: {
    enableVideoAds: true,
    videoContentId: "e1eGlRL7ju8",
    videoCmsId: "1234567",
  },
});

JavaScript (legacy)

// Enable video ads and set video content and content source IDs.
googletag.setConfig({
  videoAds: {
    enableVideoAds: true,
    videoContentId: "e1eGlRL7ju8",
    videoCmsId: "1234567",
  },
});

TypeScript

// Enable video ads and set video content and content source IDs.
googletag.setConfig({
  videoAds: {
    enableVideoAds: true,
    videoContentId: "e1eGlRL7ju8",
    videoCmsId: "1234567",
  },
});
See also

googletag.config.PrivacyTreatmentsConfig

Settings to control publisher privacy treatments.
বৈশিষ্ট্য
treatments
An array of publisher privacy treatments to enable.

বৈশিষ্ট্য


treatments

treatments : "disablePersonalization" []
An array of publisher privacy treatments to enable.
উদাহরণ

JavaScript

// Disable personalization across the entire page.
googletag.setConfig({
  privacyTreatments: { treatments: ["disablePersonalization"] },
});

JavaScript (legacy)

// Disable personalization across the entire page.
googletag.setConfig({
  privacyTreatments: { treatments: ["disablePersonalization"] },
});

TypeScript

// Disable personalization across the entire page.
googletag.setConfig({
  privacyTreatments: { treatments: ["disablePersonalization"] },
});

googletag.config.PublisherProvidedSignalsConfig

Publisher provided signals (PPS) configuration object.
বৈশিষ্ট্য
taxonomies
An object containing Taxonomy mappings or null to clear the config.
Example

JavaScript

googletag.setConfig({
  pps: {
    taxonomies: {
      IAB_AUDIENCE_1_1: { values: ["6", "626"] },
      // '6' = 'Demographic | Age Range | 30-34'
      // '626' = 'Interest | Sports | Darts'
      IAB_CONTENT_2_2: { values: ["48", "127"] },
      // '48' = 'Books and Literature | Fiction'
      // '127' = 'Careers | Job Search'
    },
  },
});

JavaScript (legacy)

googletag.setConfig({
  pps: {
    taxonomies: {
      IAB_AUDIENCE_1_1: { values: ["6", "626"] },
      // '6' = 'Demographic | Age Range | 30-34'
      // '626' = 'Interest | Sports | Darts'
      IAB_CONTENT_2_2: { values: ["48", "127"] },
      // '48' = 'Books and Literature | Fiction'
      // '127' = 'Careers | Job Search'
    },
  },
});

TypeScript

googletag.setConfig({
  pps: {
    taxonomies: {
      IAB_AUDIENCE_1_1: { values: ["6", "626"] },
      // '6' = 'Demographic | Age Range | 30-34'
      // '626' = 'Interest | Sports | Darts'
      IAB_CONTENT_2_2: { values: ["48", "127"] },
      // '48' = 'Books and Literature | Fiction'
      // '127' = 'Careers | Job Search'
    },
  },
});
See also

বৈশিষ্ট্য


taxonomies

taxonomies : Partial < Record < Taxonomy , TaxonomyData > >
An object containing Taxonomy mappings or null to clear the config.

googletag.config.SafeFrameConfig

Settings to control SafeFrame in GPT.
বৈশিষ্ট্য
allow Overlay Expansion ?
Whether SafeFrame should allow ad content to expand by overlaying page content.
allow Push Expansion ?
Whether SafeFrame should allow ad content to expand by pushing page content.
force Safe Frame ?
Whether ad(s) should be forced to be rendered using a SafeFrame container.
sandbox ?
Whether SafeFrame should use the HTML5 sandbox attribute to prevent top level navigation without user interaction.
use Unique Domain ?
Deprecated. Whether SafeFrame should use randomized subdomains for Reservation creatives.
See also

বৈশিষ্ট্য


Optional allowOverlayExpansion

allowOverlayExpansion ?: boolean
Whether SafeFrame should allow ad content to expand by overlaying page content.

Optional allowPushExpansion

allowPushExpansion ?: boolean
Whether SafeFrame should allow ad content to expand by pushing page content.

Optional forceSafeFrame

forceSafeFrame ?: boolean
Whether ad(s) should be forced to be rendered using a SafeFrame container.

Optional sandbox

sandbox ?: boolean
Whether SafeFrame should use the HTML5 sandbox attribute to prevent top level navigation without user interaction. The only valid value is true (cannot be forced to false ). Note that the sandbox attribute disables plugins (eg Flash).

Optional useUniqueDomain

useUniqueDomain ?: boolean
Whether SafeFrame should use randomized subdomains for Reservation creatives. Pass in null to clear the stored value.

Note: this feature is enabled by default.
See also

googletag.config.SlotSettingsConfig

Main configuration interface for slot-level settings.

Allows setting multiple features with a single API call for a single slot.

All properties listed below are examples and do not reflect actual features that utilize setConfig. For the set of features, see fields within the SlotSettingsConfig type below.

উদাহরণ:
  • Only features specified in the Slot.setConfig call are modified.
      const slot = googletag.defineSlot("/1234567/example", [160, 600]);
    
      // Configure feature alpha.
      slot.setConfig({
          alpha: {...}
      });
    
      // Configure feature bravo. Feature alpha is unchanged.
      slot.setConfig({
         bravo: {...}
      });
  • All settings for a given feature are updated with each call to 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
          }
      });
  • All settings for a feature can be cleared by passing 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,
      });
বৈশিষ্ট্য
ad Expansion ?
Settings to configure ad expansion.
adsense Attributes ?
Setting to configure AdSense attributes.
category Exclusion ?
Setting to configure ad category exclusions.
click Url ?
Setting to configure the URL to which users will be redirected after clicking on the ad.
collapse Div ?
Setting to configure the collapsing behavior of the ad slot.
continue Button ?
Settings to configure the continue button behavior for content pause ads.
interstitial ?
Settings that configure interstitial ad slot behavior.
safe Frame ?
Settings to configure the use of SafeFrame in GPT.
targeting ?
Setting to configure key-value targeting.

বৈশিষ্ট্য


Optional adExpansion

adExpansion ?: AdExpansionConfig
Settings to configure ad expansion.
See also

Optional adsenseAttributes

adsenseAttributes ?: AdSenseAttributesConfig
Setting to configure AdSense attributes.

AdSense attributes configured via this setting will only apply to the ad slot. This setting may be called multiple times to define multiple attribute values, or overwrite existing values.

AdSense attribute changes only apply to ads requested after this method has been called. For that reason, it is recommended to call this method before any calls to googletag.display or PubAdsService.refresh .
Example

JavaScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Set the AdSense ad format and channel IDs.
slot.setConfig({
  adsenseAttributes: {
    adsense_ad_format: "120x240_as",
    adsense_channel_ids: "271828183+314159265",
  },
});

// Clear the AdSense channel IDs only.
slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } });

// Clear all AdSense attributes.
slot.setConfig({ adsenseAttributes: null });

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Set the AdSense ad format and channel IDs.
slot.setConfig({
  adsenseAttributes: {
    adsense_ad_format: "120x240_as",
    adsense_channel_ids: "271828183+314159265",
  },
});

// Clear the AdSense channel IDs only.
slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } });

// Clear all AdSense attributes.
slot.setConfig({ adsenseAttributes: null });

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

// Set the AdSense ad format and channel IDs.
slot.setConfig({
  adsenseAttributes: {
    adsense_ad_format: "120x240_as",
    adsense_channel_ids: "271828183+314159265",
  },
});

// Clear the AdSense channel IDs only.
slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } });

// Clear all AdSense attributes.
slot.setConfig({ adsenseAttributes: null });

Optional categoryExclusion

categoryExclusion ?: string []
Setting to configure ad category exclusions.
Example

JavaScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Label = AirlineAd
slot.setConfig({
  categoryExclusion: ["AirlineAd"],
});

// Clearing category exclusion setting.
slot.setConfig({ categoryExclusion: null });

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Label = AirlineAd
slot.setConfig({
  categoryExclusion: ["AirlineAd"],
});

// Clearing category exclusion setting.
slot.setConfig({ categoryExclusion: null });

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

// Label = AirlineAd
slot.setConfig({
  categoryExclusion: ["AirlineAd"],
});

// Clearing category exclusion setting.
slot.setConfig({ categoryExclusion: null });
See also

Optional clickUrl

clickUrl ?: string
Setting to configure the URL to which users will be redirected after clicking on the ad.

The Google Ad Manager servers still record a click even if the click URL is replaced. Any landing page URL associated with the creative that is served is appended to the provided value. Setting this value more than once will overwrite any previously configured value. Passing in null will clear the value.

Note: This setting only applies to non-SRA requests .
Example

JavaScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Sets the click URL to 'http://www.example.com?original_click_url='.
slot.setConfig({
  clickUrl: "http://www.example.com?original_click_url=",
});

// Clears the click URL.
slot.setConfig({
  clickUrl: null,
});

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Sets the click URL to 'http://www.example.com?original_click_url='.
slot.setConfig({
  clickUrl: "http://www.example.com?original_click_url=",
});

// Clears the click URL.
slot.setConfig({
  clickUrl: null,
});

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

// Sets the click URL to 'http://www.example.com?original_click_url='.
slot.setConfig({
  clickUrl: "http://www.example.com?original_click_url=",
});

// Clears the click URL.
slot.setConfig({
  clickUrl: null,
});

Optional collapseDiv

collapseDiv ?: CollapseDivBehavior
Setting to configure the collapsing behavior of the ad slot.

A collapsed ad slot does not take up any space on the page.

Supported values:
  • null (default): The slot will not be collapsed.
  • DISABLED : The slot will not collapse, whether or not an ad is returned.
  • BEFORE_FETCH : The slot will start out collapsed, and expand when an ad is returned.
  • ON_NO_FILL : The slot will start out expanded, and collapse if no ad is returned.
Example

JavaScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Collapse the div for this slot if no ad is returned.
slot.setConfig({
  collapseDiv: "ON_NO_FILL",
});

// Collapse the div for this slot by default, and expand only
// if an ad is returned.
slot.setConfig({
  collapseDiv: "BEFORE_FETCH",
});

// Do not collapse the div for this slot.
slot.setConfig({
  collapseDiv: "DISABLED",
});

// Clear the collapse setting.
slot.setConfig({
  collapseDiv: null,
});

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Collapse the div for this slot if no ad is returned.
slot.setConfig({
  collapseDiv: "ON_NO_FILL",
});

// Collapse the div for this slot by default, and expand only
// if an ad is returned.
slot.setConfig({
  collapseDiv: "BEFORE_FETCH",
});

// Do not collapse the div for this slot.
slot.setConfig({
  collapseDiv: "DISABLED",
});

// Clear the collapse setting.
slot.setConfig({
  collapseDiv: null,
});

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

// Collapse the div for this slot if no ad is returned.
slot.setConfig({
  collapseDiv: "ON_NO_FILL",
});

// Collapse the div for this slot by default, and expand only
// if an ad is returned.
slot.setConfig({
  collapseDiv: "BEFORE_FETCH",
});

// Do not collapse the div for this slot.
slot.setConfig({
  collapseDiv: "DISABLED",
});

// Clear the collapse setting.
slot.setConfig({
  collapseDiv: null,
});
আরও দেখুন

Optional continueButton

continueButton ?: ContinueButtonConfig
Settings to configure the continue button behavior for content pause ads.

These settings allow customizing the appearance and behavior of the exit and continue reading interactions associated with content pause formats.

Any continue button settings which are not specified when calling setConfig() will use a default value set by Google.

To disable or clear all continue button settings, pass null .
Example

JavaScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());
// Configure continue button settings.
slot.setConfig({
  continueButton: {
    font: "Arial",
    fontColor: "white",
    backgroundColor: "blue",
    targetId: "target-div-id",
    freqCapIntervalMinutes: 20,
  },
});

// Clear continue button settings.
slot.setConfig({ continueButton: null });

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());
// Configure continue button settings.
slot.setConfig({
  continueButton: {
    font: "Arial",
    fontColor: "white",
    backgroundColor: "blue",
    targetId: "target-div-id",
    freqCapIntervalMinutes: 20,
  },
});

// Clear continue button settings.
slot.setConfig({ continueButton: null });

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());
// Configure continue button settings.
slot.setConfig({
  continueButton: {
    font: "Arial",
    fontColor: "white",
    backgroundColor: "blue",
    targetId: "target-div-id",
    freqCapIntervalMinutes: 20,
  },
});

// Clear continue button settings.
slot.setConfig({ continueButton: null });

Optional interstitial

interstitial ?: InterstitialConfig
Settings that configure interstitial ad slot behavior.
See also

Optional safeFrame

safeFrame ?: SafeFrameConfig
Settings to configure the use of SafeFrame in GPT.

Values configured via this setting will only apply to the ad slot, and override values set via PageSettingsConfig.safeFrame .
Example

JavaScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Force SafeFrame for the slot.
slot.setConfig({
  safeFrame: { forceSafeFrame: true },
});

// Configure SafeFrame to allow overlay expansion for the slot.
slot.setConfig({
  safeFrame: { allowOverlayExpansion: true },
});

// Clear forceSafeFrame setting for the slot.
slot.setConfig({
  safeFrame: { forceSafeFrame: null },
});

// Clear all SafeFrame settings for the slot.
slot.setConfig({ safeFrame: null });

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Force SafeFrame for the slot.
slot.setConfig({
  safeFrame: { forceSafeFrame: true },
});

// Configure SafeFrame to allow overlay expansion for the slot.
slot.setConfig({
  safeFrame: { allowOverlayExpansion: true },
});

// Clear forceSafeFrame setting for the slot.
slot.setConfig({
  safeFrame: { forceSafeFrame: null },
});

// Clear all SafeFrame settings for the slot.
slot.setConfig({ safeFrame: null });

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

// Force SafeFrame for the slot.
slot.setConfig({
  safeFrame: { forceSafeFrame: true },
});

// Configure SafeFrame to allow overlay expansion for the slot.
slot.setConfig({
  safeFrame: { allowOverlayExpansion: true },
});

// Clear forceSafeFrame setting for the slot.
slot.setConfig({
  safeFrame: { forceSafeFrame: null },
});

// Clear all SafeFrame settings for the slot.
slot.setConfig({ safeFrame: null });

Optional targeting

targeting ?: Record < string , string | string [] >
Setting to configure key-value targeting.

Targeting configured via this setting will only apply to the ad slot. This setting may be called multiple times to define multiple targeting key-values, or overwrite existing values. Targeting keys are defined in your Google Ad Manager account.
Example

JavaScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Setting a single targeting key-value.
slot.setConfig({ targeting: { interests: "sports" } });

// Setting multiple values for a single targeting key.
slot.setConfig({ targeting: { interests: ["sports", "music"] } });

// Setting multiple targeting key-values at once.
slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });

// Clearing a single targeting key.
slot.setConfig({ targeting: { interests: null } });

// Clear all targeting keys.
slot.setConfig({ targeting: null });

JavaScript (legacy)

var slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")
  .addService(googletag.pubads());

// Setting a single targeting key-value.
slot.setConfig({ targeting: { interests: "sports" } });

// Setting multiple values for a single targeting key.
slot.setConfig({ targeting: { interests: ["sports", "music"] } });

// Setting multiple targeting key-values at once.
slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });

// Clearing a single targeting key.
slot.setConfig({ targeting: { interests: null } });

// Clear all targeting keys.
slot.setConfig({ targeting: null });

TypeScript

const slot = googletag
  .defineSlot("/1234567/sports", [160, 600], "div")!
  .addService(googletag.pubads());

// Setting a single targeting key-value.
slot.setConfig({ targeting: { interests: "sports" } });

// Setting multiple values for a single targeting key.
slot.setConfig({ targeting: { interests: ["sports", "music"] } });

// Setting multiple targeting key-values at once.
slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });

// Clearing a single targeting key.
slot.setConfig({ targeting: { interests: null } });

// Clear all targeting keys.
slot.setConfig({ targeting: null });
See also

googletag.config.TaxonomyData

An object containing the values for a single Taxonomy .
বৈশিষ্ট্য
values
A list of Taxonomy values.

বৈশিষ্ট্য


মূল্যবোধ

values : readonly string []
A list of Taxonomy values.

googletag.config.VideoAdsConfig

Settings to configure video ad related settings.
বৈশিষ্ট্য
enable Video Ads
Whether videos ads will be present on the page.
video Cms Id ?
The video content source ID.
video Content Id ?
The video content ID.
See also

বৈশিষ্ট্য


enableVideoAds

enableVideoAds : boolean
Whether videos ads will be present on the page.

When set to true , this enables content exclusion constraints on display and video ads.

If the video content is known, set videoContentId and videoCmsId to the values provided to the Google Ad Manager content ingestion service to utilize content exclusion for display ads.

Optional videoCmsId

videoCmsId ?: string
The video content source ID.

This is a unique value assigned by the Google Ad Manager content ingestion service to identify the source of video content specified by videoContentId .
See also

Optional videoContentId

videoContentId ?: string
The video content ID.

This is a unique value that identifies a particular video from the content source specified by videoCmsId . This value is assigned by the CMS that hosts your video content.
See also

googletag.enums

This is the namespace that GPT uses for enum types.
Enumerations
Out Of Page Format
Out-of-page formats supported by GPT.
Tag For Age Treatment
Age treatment settings supported by GPT.
Traffic Source
Traffic sources supported by GPT.

Enumerations


OutOfPageFormat

OutOfPageFormat
Out-of-page formats supported by GPT.
See also
Enumeration Members
AD_ INTENTS
Ad Intents format.
BOTTOM_ ANCHOR
Anchor format where slot sticks to the bottom of the viewport.
GAME_ MANUAL_ INTERSTITIAL
Game manual interstitial format.

Note: Game manual interstitial is a limited-access format.
INTERSTITIAL
Web interstitial creative format.
LEFT_ SIDE_ RAIL
Left side rail format.
REWARDED
Rewarded format.
RIGHT_ SIDE_ RAIL
Right side rail format.
TOP_ ANCHOR
Anchor format where slot sticks to the top of the viewport.

TagForAgeTreatment

TagForAgeTreatment
Age treatment settings supported by GPT.
See also
Enumeration Members
CHILD
Indicates that ad requests should receive CHILD age treatment.
TEEN
Indicates that ad requests should receive TEEN age treatment.
UNSPECIFIED
Default value. Indicates that no specific age restricted treatment signal applies to the ad request.

TrafficSource

TrafficSource
Traffic sources supported by GPT.
See also
Enumeration Members
ORGANIC
Direct URL entry, site search, or app download.
PURCHASED
Traffic redirected from properties other than owned (acquired or otherwise incentivized activity).

googletag.events

This is the namespace that GPT uses for Events. Your code can react to these events using Service.addEventListener.
ইন্টারফেস
Event
Base Interface for all GPT events.
Event Type Map
This is a pseudo-type that maps an event name to its corresponding event object type for Service.addEventListener and Service.removeEventListener .
Game Manual Interstitial Slot Closed Event
This event is fired when a game manual interstitial slot has been closed by the user.
Game Manual Interstitial Slot Ready Event
This event is fired when a game manual interstitial slot is ready to be shown to the user.
Impression Viewable Event
This event is fired when an impression becomes viewable, according to the Active View criteria .
Rewarded Slot Closed Event
This event is fired when a rewarded ad slot is closed by the user.
Rewarded Slot Granted Event
This event is fired when a reward is granted for viewing a rewarded ad .
Rewarded Slot Ready Event
This event is fired when a rewarded ad is ready to be displayed.
Rewarded Slot Video Completed Event
This event is fired when a rewarded video ad has finished playing.
Slot Onload Event
This event is fired when the creative's iframe fires its load event.
Slot Render Ended Event
This event is fired when the creative code is injected into a slot.
Slot Requested Event
This event is fired when an ad has been requested for a particular slot.
Slot Response Received
This event is fired when an ad response has been received for a particular slot.
Slot Visibility Changed Event
This event is fired whenever the on-screen percentage of an ad slot's area changes.

googletag.events.Event

Base Interface for all GPT events. All GPT events below will have the following fields.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
See also

বৈশিষ্ট্য


serviceName

serviceName : string
Name of the service that triggered the event.

স্লট

slot : Slot
The slot that triggered the event.

googletag.events.EventTypeMap

This is a pseudo-type that maps an event name to its corresponding event object type for Service.addEventListener and Service.removeEventListener . It is documented for reference and type safety purposes only.
বৈশিষ্ট্য
game Manual Interstitial Slot Closed
game Manual Interstitial Slot Ready
impression Viewable
rewarded Slot Closed
rewarded Slot Granted
rewarded Slot Ready
rewarded Slot Video Completed
slot Onload
slot Render Ended
slot Requested
slot Response Received
slot Visibility Changed

বৈশিষ্ট্য


gameManualInterstitialSlotClosed


gameManualInterstitialSlotReady


impressionViewable

impressionViewable : ImpressionViewableEvent
Alias for events.ImpressionViewableEvent .

rewardedSlotClosed

rewardedSlotClosed : RewardedSlotClosedEvent
Alias for events.RewardedSlotClosedEvent .

rewardedSlotGranted

rewardedSlotGranted : RewardedSlotGrantedEvent
Alias for events.RewardedSlotGrantedEvent .

rewardedSlotReady

rewardedSlotReady : RewardedSlotReadyEvent
Alias for events.RewardedSlotReadyEvent .

rewardedSlotVideoCompleted


slotOnload

slotOnload : SlotOnloadEvent
Alias for events.SlotOnloadEvent .

slotRenderEnded

slotRenderEnded : SlotRenderEndedEvent
Alias for events.SlotRenderEndedEvent .

slotRequested

slotRequested : SlotRequestedEvent
Alias for events.SlotRequestedEvent .

slotResponseReceived

slotResponseReceived : SlotResponseReceived
Alias for events.SlotResponseReceived .

slotVisibilityChanged


googletag.events.GameManualInterstitialSlotClosedEvent

Extends Event
This event is fired when a game manual interstitial slot has been closed by the user.

Note: Game manual interstitial is a limited-access format.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
Example

JavaScript

// This listener is called when a game manual interstitial slot is closed.
const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
);

// Slot returns null if the page or device does not support game manual interstitial ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", (event) => {
    const slot = event.slot;
    console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

JavaScript (legacy)

// This listener is called when a game manual interstitial slot is closed.
var targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
);

// Slot returns null if the page or device does not support game manual interstitial ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", function (event) {
    var slot = event.slot;
    console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

TypeScript

// This listener is called when a game manual interstitial slot is closed.
const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
);

// Slot returns null if the page or device does not support game manual interstitial ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", (event) => {
    const slot = event.slot;
    console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}
See also

googletag.events.GameManualInterstitialSlotReadyEvent

Extends Event
This event is fired when a game manual interstitial slot is ready to be shown to the user.

Note: Game manual interstitial is a limited-access format.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
পদ্ধতি
make Game Manual Interstitial Visible
Displays the game manual interstitial ad to the user.
Example

JavaScript

// This listener is called when a game manual interstitial slot is ready to
// be displayed.
const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
);

// Slot returns null if the page or device does not support game manual interstitial ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  googletag.pubads().addEventListener("gameManualInterstitialSlotReady", (event) => {
    const slot = event.slot;
    console.log(
      "Game manual interstital slot",
      slot.getSlotElementId(),
      "is ready to be displayed.",
    );

    // Replace with custom logic.
    const displayGmiAd = true;
    if (displayGmiAd) {
      event.makeGameManualInterstitialVisible();
    }

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

JavaScript (legacy)

// This listener is called when a game manual interstitial slot is ready to
// be displayed.
var targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
);

// Slot returns null if the page or device does not support game manual interstitial ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  googletag.pubads().addEventListener("gameManualInterstitialSlotReady", function (event) {
    var slot = event.slot;
    console.log(
      "Game manual interstital slot",
      slot.getSlotElementId(),
      "is ready to be displayed.",
    );

    // Replace with custom logic.
    var displayGmiAd = true;
    if (displayGmiAd) {
      event.makeGameManualInterstitialVisible();
    }

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

TypeScript

// This listener is called when a game manual interstitial slot is ready to
// be displayed.
const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
);

// Slot returns null if the page or device does not support game manual interstitial ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  googletag.pubads().addEventListener("gameManualInterstitialSlotReady", (event) => {
    const slot = event.slot;
    console.log(
      "Game manual interstital slot",
      slot.getSlotElementId(),
      "is ready to be displayed.",
    );

    // Replace with custom logic.
    const displayGmiAd = true;
    if (displayGmiAd) {
      event.makeGameManualInterstitialVisible();
    }

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}
See also

পদ্ধতি


makeGameManualInterstitialVisible

makeGameManualInterstitialVisible ( ) : boolean
Displays the game manual interstitial ad to the user. Returns whether the ad was successfully displayed.
ফেরত
boolean

googletag.events.ImpressionViewableEvent

Extends Event
This event is fired when an impression becomes viewable, according to the Active View criteria .
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
উদাহরণ

JavaScript

// This listener is called when an impression becomes viewable.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("impressionViewable", (event) => {
  const slot = event.slot;
  console.log("Impression for slot", slot.getSlotElementId(), "became viewable.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// This listener is called when an impression becomes viewable.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("impressionViewable", function (event) {
  var slot = event.slot;
  console.log("Impression for slot", slot.getSlotElementId(), "became viewable.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when an impression becomes viewable.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("impressionViewable", (event) => {
  const slot = event.slot;
  console.log("Impression for slot", slot.getSlotElementId(), "became viewable.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
See also

googletag.events.RewardedSlotClosedEvent

Extends Event
This event is fired when a rewarded ad slot is closed by the user. It may fire either before or after a reward has been granted. To determine whether a reward has been granted, use events.RewardedSlotGrantedEvent instead.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
Example

JavaScript

const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called when the user closes a rewarded ad slot.
  googletag.pubads().addEventListener("rewardedSlotClosed", (event) => {
    const slot = event.slot;
    console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

JavaScript (legacy)

var targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called when the user closes a rewarded ad slot.
  googletag.pubads().addEventListener("rewardedSlotClosed", function (event) {
    var slot = event.slot;
    console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

TypeScript

const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called when the user closes a rewarded ad slot.
  googletag.pubads().addEventListener("rewardedSlotClosed", (event) => {
    const slot = event.slot;
    console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}
আরও দেখুন

googletag.events.RewardedSlotGrantedEvent

Extends Event
This event is fired when a reward is granted for viewing a rewarded ad . If the ad is closed before the criteria for granting a reward is met, this event will not fire.
বৈশিষ্ট্য
payload
An object containing information about the reward that was granted.
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
Example

JavaScript

const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called whenever a reward is granted for a
  // rewarded ad.
  googletag.pubads().addEventListener("rewardedSlotGranted", (event) => {
    const slot = event.slot;
    console.group("Reward granted for slot", slot.getSlotElementId(), ".");

    // Log details of the reward.
    console.log("Reward type:", event.payload?.type);
    console.log("Reward amount:", event.payload?.amount);
    console.groupEnd();

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

JavaScript (legacy)

var targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called whenever a reward is granted for a
  // rewarded ad.
  googletag.pubads().addEventListener("rewardedSlotGranted", function (event) {
    var _a, _b;
    var slot = event.slot;
    console.group("Reward granted for slot", slot.getSlotElementId(), ".");

    // Log details of the reward.
    console.log("Reward type:", (_a = event.payload) === null || _a === void 0 ? void 0 : _a.type);
    console.log(
      "Reward amount:",
      (_b = event.payload) === null || _b === void 0 ? void 0 : _b.amount,
    );
    console.groupEnd();

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

TypeScript

const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called whenever a reward is granted for a
  // rewarded ad.
  googletag.pubads().addEventListener("rewardedSlotGranted", (event) => {
    const slot = event.slot;
    console.group("Reward granted for slot", slot.getSlotElementId(), ".");

    // Log details of the reward.
    console.log("Reward type:", event.payload?.type);
    console.log("Reward amount:", event.payload?.amount);
    console.groupEnd();

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}
See also

বৈশিষ্ট্য


পেলোড

payload : RewardedPayload
An object containing information about the reward that was granted.

googletag.events.RewardedSlotReadyEvent

Extends Event
This event is fired when a rewarded ad is ready to be displayed. The publisher is responsible for presenting the user an option to view the ad before displaying it.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
পদ্ধতি
make Rewarded Visible
Displays the rewarded ad.
Example

JavaScript

// This listener is called when a rewarded ad slot becomes ready to be
// displayed.
const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called whenever a reward is granted for a
  // rewarded ad.
  googletag.pubads().addEventListener("rewardedSlotReady", (event) => {
    const slot = event.slot;
    console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed.");

    // Replace with custom logic.
    const userHasConsented = true;
    if (userHasConsented) {
      event.makeRewardedVisible();
    }

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

JavaScript (legacy)

// This listener is called when a rewarded ad slot becomes ready to be
// displayed.
var targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called whenever a reward is granted for a
  // rewarded ad.
  googletag.pubads().addEventListener("rewardedSlotReady", function (event) {
    var slot = event.slot;
    console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed.");

    // Replace with custom logic.
    var userHasConsented = true;
    if (userHasConsented) {
      event.makeRewardedVisible();
    }

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

TypeScript

// This listener is called when a rewarded ad slot becomes ready to be
// displayed.
const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called whenever a reward is granted for a
  // rewarded ad.
  googletag.pubads().addEventListener("rewardedSlotReady", (event) => {
    const slot = event.slot;
    console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed.");

    // Replace with custom logic.
    const userHasConsented = true;
    if (userHasConsented) {
      event.makeRewardedVisible();
    }

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}
See also

পদ্ধতি


makeRewardedVisible

makeRewardedVisible ( ) : boolean
Displays the rewarded ad. This method should not be called until the user has consented to view the ad.
ফেরত
boolean Whether the rewarded ad was successfully displayed.

googletag.events.RewardedSlotVideoCompletedEvent

Extends Event
This event is fired when a rewarded video ad has finished playing.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
Example

JavaScript

const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called when the video in a rewarded ad slot has
  // finished playing.
  googletag.pubads().addEventListener("rewardedSlotVideoCompleted", (event) => {
    const slot = event.slot;
    console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

JavaScript (legacy)

var targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called when the video in a rewarded ad slot has
  // finished playing.
  googletag.pubads().addEventListener("rewardedSlotVideoCompleted", function (event) {
    var slot = event.slot;
    console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}

TypeScript

const targetSlot = googletag.defineOutOfPageSlot(
  "/1234567/example",
  googletag.enums.OutOfPageFormat.REWARDED,
);

// Slot returns null if the page or device does not support rewarded ads.
if (targetSlot) {
  targetSlot.addService(googletag.pubads());

  // This listener is called when the video in a rewarded ad slot has
  // finished playing.
  googletag.pubads().addEventListener("rewardedSlotVideoCompleted", (event) => {
    const slot = event.slot;
    console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing.");

    if (slot === targetSlot) {
      // Slot specific logic.
    }
  });
}
See also

googletag.events.SlotOnloadEvent

Extends Event
This event is fired when the creative's iframe fires its load event. When rendering rich media ads in sync rendering mode, no iframe is used so no SlotOnloadEvent will be fired.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
Example

JavaScript

// This listener is called when a creative iframe load event fires.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", (event) => {
  const slot = event.slot;
  console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// This listener is called when a creative iframe load event fires.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", function (event) {
  var slot = event.slot;
  console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when a creative iframe load event fires.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", (event) => {
  const slot = event.slot;
  console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
See also

googletag.events.SlotRenderEndedEvent

Extends Event
This event is fired when the creative code is injected into a slot. This event will occur before the creative's resources are fetched, so the creative may not be visible yet. If you need to know when all creative resources for a slot have finished loading, consider the events.SlotOnloadEvent instead.
বৈশিষ্ট্য
advertiser Id
Advertiser ID of the rendered ad.
campaign Id
Campaign ID of the rendered ad.
company Ids
IDs of the companies that bid on the rendered backfill ad.
creative Id
Creative ID of the rendered reservation ad.
creative Template Id
Creative template ID of the rendered reservation ad.
is Backfill
Whether an ad was a backfill ad.
is Empty
Whether an ad was returned for the slot.
label Ids
Deprecated.
line Item Id
Line item ID of the rendered reservation ad.
response Identifier
The response identifier is a unique identifier for the ad response.
service Name
Name of the service that triggered the event.
size
Indicates the pixel size of the rendered creative.
slot
The slot that triggered the event.
slot Content Changed
Whether the slot content was changed with the rendered ad.
source Agnostic Creative Id
Creative ID of the rendered reservation or backfill ad.
source Agnostic Line Item Id
Line item ID of the rendered reservation or backfill ad.
yield Group Ids
IDs of the yield groups for the rendered backfill ad.
Example

JavaScript

// This listener is called when a slot has finished rendering.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRenderEnded", (event) => {
  const slot = event.slot;
  console.group("Slot", slot.getSlotElementId(), "finished rendering.");

  // Log details of the rendered ad.
  console.log("Advertiser ID:", event.advertiserId);
  console.log("Campaign ID:", event.campaignId);
  console.log("Company IDs:", event.companyIds);
  console.log("Creative ID:", event.creativeId);
  console.log("Creative Template ID:", event.creativeTemplateId);
  console.log("Is backfill?:", event.isBackfill);
  console.log("Is empty?:", event.isEmpty);
  console.log("Line Item ID:", event.lineItemId);
  console.log("Size:", event.size);
  console.log("Slot content changed?", event.slotContentChanged);
  console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId);
  console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId);
  console.log("Yield Group IDs:", event.yieldGroupIds);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// This listener is called when a slot has finished rendering.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRenderEnded", function (event) {
  var slot = event.slot;
  console.group("Slot", slot.getSlotElementId(), "finished rendering.");

  // Log details of the rendered ad.
  console.log("Advertiser ID:", event.advertiserId);
  console.log("Campaign ID:", event.campaignId);
  console.log("Company IDs:", event.companyIds);
  console.log("Creative ID:", event.creativeId);
  console.log("Creative Template ID:", event.creativeTemplateId);
  console.log("Is backfill?:", event.isBackfill);
  console.log("Is empty?:", event.isEmpty);
  console.log("Line Item ID:", event.lineItemId);
  console.log("Size:", event.size);
  console.log("Slot content changed?", event.slotContentChanged);
  console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId);
  console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId);
  console.log("Yield Group IDs:", event.yieldGroupIds);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when a slot has finished rendering.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRenderEnded", (event) => {
  const slot = event.slot;
  console.group("Slot", slot.getSlotElementId(), "finished rendering.");

  // Log details of the rendered ad.
  console.log("Advertiser ID:", event.advertiserId);
  console.log("Campaign ID:", event.campaignId);
  console.log("Company IDs:", event.companyIds);
  console.log("Creative ID:", event.creativeId);
  console.log("Creative Template ID:", event.creativeTemplateId);
  console.log("Is backfill?:", event.isBackfill);
  console.log("Is empty?:", event.isEmpty);
  console.log("Line Item ID:", event.lineItemId);
  console.log("Size:", event.size);
  console.log("Slot content changed?", event.slotContentChanged);
  console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId);
  console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId);
  console.log("Yield Group IDs:", event.yieldGroupIds);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
See also

বৈশিষ্ট্য


advertiserId

advertiserId : number
Advertiser ID of the rendered ad. Value is null for empty slots, backfill ads, and creatives rendered by services other than PubAdsService .

campaignId

campaignId : number
Campaign ID of the rendered ad. Value is null for empty slots, backfill ads, and creatives rendered by services other than PubAdsService .

companyIds

companyIds : number []
IDs of the companies that bid on the rendered backfill ad. Value is null for empty slots, reservation ads, and creatives rendered by services other than PubAdsService .

creativeId

creativeId : number
Creative ID of the rendered reservation ad. Value is null for empty slots, backfill ads, and creatives rendered by services other than PubAdsService .

creativeTemplateId

creativeTemplateId : number
Creative template ID of the rendered reservation ad. Value is null for empty slots, backfill ads, and creatives rendered by services other than PubAdsService .

isBackfill

isBackfill : boolean
Whether an ad was a backfill ad. Value is true if the ad was a backfill ad, false otherwise.

isEmpty

isEmpty : boolean
Whether an ad was returned for the slot. Value is true if no ad was returned, false otherwise.

labelIds

labelIds : number []

lineItemId

lineItemId : number
Line item ID of the rendered reservation ad. Value is null for empty slots, backfill ads, and creatives rendered by services other than PubAdsService .

responseIdentifier

responseIdentifier : string
The response identifier is a unique identifier for the ad response. This value can be used to identify and block the ad in the Ad Review Center (ARC) .

আকার

size : string | number []
Indicates the pixel size of the rendered creative. Example: [728, 90] . Value is null for empty ad slots.

slotContentChanged

slotContentChanged : boolean
Whether the slot content was changed with the rendered ad. Value is true if the content was changed, false otherwise.

sourceAgnosticCreativeId

sourceAgnosticCreativeId : number
Creative ID of the rendered reservation or backfill ad. Value is null if the ad is not a reservation or line item backfill, or the creative is rendered by services other than PubAdsService .

sourceAgnosticLineItemId

sourceAgnosticLineItemId : number
Line item ID of the rendered reservation or backfill ad. Value is null if the ad is not a reservation or line item backfill, or the creative is rendered by services other than PubAdsService .

yieldGroupIds

yieldGroupIds : number []
IDs of the yield groups for the rendered backfill ad. Value is null for empty slots, reservation ads, and creatives rendered by services other than PubAdsService .

googletag.events.SlotRequestedEvent

Extends Event
This event is fired when an ad has been requested for a particular slot.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
Example

JavaScript

// This listener is called when the specified service issues an ad
// request for a slot. Each slot will fire this event, even though they
// may be batched together in a single request if single request
// architecture (SRA) is enabled.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRequested", (event) => {
  const slot = event.slot;
  console.log("Slot", slot.getSlotElementId(), "has been requested.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// This listener is called when the specified service issues an ad
// request for a slot. Each slot will fire this event, even though they
// may be batched together in a single request if single request
// architecture (SRA) is enabled.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRequested", function (event) {
  var slot = event.slot;
  console.log("Slot", slot.getSlotElementId(), "has been requested.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when the specified service issues an ad
// request for a slot. Each slot will fire this event, even though they
// may be batched together in a single request if single request
// architecture (SRA) is enabled.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRequested", (event) => {
  const slot = event.slot;
  console.log("Slot", slot.getSlotElementId(), "has been requested.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
See also

googletag.events.SlotResponseReceived

Extends Event
This event is fired when an ad response has been received for a particular slot.
বৈশিষ্ট্য
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
Example

JavaScript

// This listener is called when an ad response has been received
// for a slot.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotResponseReceived", (event) => {
  const slot = event.slot;
  console.log("Ad response for slot", slot.getSlotElementId(), "received.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// This listener is called when an ad response has been received
// for a slot.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotResponseReceived", function (event) {
  var slot = event.slot;
  console.log("Ad response for slot", slot.getSlotElementId(), "received.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when an ad response has been received
// for a slot.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotResponseReceived", (event) => {
  const slot = event.slot;
  console.log("Ad response for slot", slot.getSlotElementId(), "received.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
See also

googletag.events.SlotVisibilityChangedEvent

Extends Event
This event is fired whenever the on-screen percentage of an ad slot's area changes. The event is throttled and will not fire more often than once every 200ms.
বৈশিষ্ট্য
in View Percentage
The percentage of the ad's area that is visible.
service Name
Name of the service that triggered the event.
slot
The slot that triggered the event.
Example

JavaScript

// This listener is called whenever the on-screen percentage of an
// ad slot's area changes.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotVisibilityChanged", (event) => {
  const slot = event.slot;
  console.group("Visibility of slot", slot.getSlotElementId(), "changed.");

  // Log details of the event.
  console.log("Visible area:", `${event.inViewPercentage}%`);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (legacy)

// This listener is called whenever the on-screen percentage of an
// ad slot's area changes.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotVisibilityChanged", function (event) {
  var slot = event.slot;
  console.group("Visibility of slot", slot.getSlotElementId(), "changed.");

  // Log details of the event.
  console.log("Visible area:", "".concat(event.inViewPercentage, "%"));
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called whenever the on-screen percentage of an
// ad slot's area changes.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotVisibilityChanged", (event) => {
  const slot = event.slot;
  console.group("Visibility of slot", slot.getSlotElementId(), "changed.");

  // Log details of the event.
  console.log("Visible area:", `${event.inViewPercentage}%`);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
See also

বৈশিষ্ট্য


inViewPercentage

inViewPercentage : number
The percentage of the ad's area that is visible. Value is a number between 0 and 100.

googletag.secureSignals

This is the namespace that GPT uses for managing secure signals.
ইন্টারফেস
Bidder Signal Provider
Returns a secure signal for a specific bidder.
Publisher Signal Provider
Returns a secure signal for a specific publisher.
Secure Signal Providers Array
An interface for managing secure signals.
Type Aliases
Secure Signal Provider
Interface for returning a secure signal for a specific bidder or provider.

Type Aliases


SecureSignalProvider

Interface for returning a secure signal for a specific bidder or provider. One of id or networkCode must be provided, but not both.

googletag.secureSignals.BidderSignalProvider

Returns a secure signal for a specific bidder.

A bidder secure signal provider consists of 2 parts:

  1. A collector function, which returns a Promise that resolves to a secure signal.
  2. An id which identifies the bidder associated with the signal.
To return a secure signal for a publisher, use secureSignals.PublisherSignalProvider instead.
বৈশিষ্ট্য
collector Function
A function which returns a Promise that resolves to a secure signal.
id
A unique identifier for the collector associated with this secure signal, as registered in Google Ad Manager.
Example

JavaScript

// id is provided
googletag.secureSignalProviders.push({
  id: "collector123",
  collectorFunction: () => {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});

JavaScript (legacy)

// id is provided
googletag.secureSignalProviders.push({
  id: "collector123",
  collectorFunction: function () {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});

TypeScript

// id is provided
googletag.secureSignalProviders!.push({
  id: "collector123",
  collectorFunction: () => {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});
See also

বৈশিষ্ট্য


collectorFunction

collectorFunction : ( ( ) => Promise < string > )
A function which returns a Promise that resolves to a secure signal.

আইডি

id : string
A unique identifier for the collector associated with this secure signal, as registered in Google Ad Manager.

googletag.secureSignals.PublisherSignalProvider

Returns a secure signal for a specific publisher.

A publisher signal provider consists of 2 parts:

  1. A collector function, which returns a Promise that resolves to a secure signal.
  2. A networkCode which identifies the publisher associated with the signal.
To return a secure signal for a bidder, use secureSignals.BidderSignalProvider instead.
বৈশিষ্ট্য
collector Function
A function which returns a Promise that resolves to a secure signal.
network Code
The network code (as seen in the ad unit path) for the publisher associated with this secure signal.
Example

JavaScript

// networkCode is provided
googletag.secureSignalProviders.push({
  networkCode: "123456",
  collectorFunction: () => {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});

JavaScript (legacy)

// networkCode is provided
googletag.secureSignalProviders.push({
  networkCode: "123456",
  collectorFunction: function () {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});

TypeScript

// networkCode is provided
googletag.secureSignalProviders!.push({
  networkCode: "123456",
  collectorFunction: () => {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});
See also

বৈশিষ্ট্য


collectorFunction

collectorFunction : ( ( ) => Promise < string > )
A function which returns a Promise that resolves to a secure signal.

networkCode

networkCode : string
The network code (as seen in the ad unit path) for the publisher associated with this secure signal.

googletag.secureSignals.SecureSignalProvidersArray

An interface for managing secure signals.
পদ্ধতি
clear All Cache
Clears all signals for all collectors from cache.
push
Adds a new secureSignals.SecureSignalProvider to the signal provider array and begins the signal generation process.

পদ্ধতি


clearAllCache

clearAllCache ( ) : void
Clears all signals for all collectors from cache.

Calling this method may reduce the likelihood of signals being included in ad requests for the current and potentially later page views. Due to this, it should only be called when meaningful state changes occur, such as events that indicate a new user (log in, log out, sign up, etc.).

ধাক্কা

push ( provider : SecureSignalProvider ) : void
Adds a new secureSignals.SecureSignalProvider to the signal provider array and begins the signal generation process.
Parameters
provider : SecureSignalProvider The secureSignals.SecureSignalProvider object to be added to the array.