Config API মাইগ্রেশন

এই নির্দেশিকা পুরনো কনফিগারেশন পদ্ধতি থেকে নতুন Google Publisher Tag (GPT) লাইব্রেরি setConfig এবং getConfig API-তে মাইগ্রেট করার উদাহরণ প্রদান করে।

setConfig এবং getConfig API, পৃষ্ঠা এবং স্লট-লেভেল কনফিগারেশন ম্যানেজ করার জন্য একটি সেন্ট্রালাইজড উপায় প্রদান করে।

পৃষ্ঠা-লেভেল কনফিগারেশন সেট করা

নিচের সারণীতে পুরনো PubAdsService কনফিগারেশন পদ্ধতিকে সেটির setConfig বিকল্পের সাথে ম্যাপ করা হয়েছে।

ফিচার পুরনো পদ্ধতি setConfigটি রিপ্লেসমেন্ট
AdSense অ্যাট্রিবিউট set(key, value) googletag.setConfig({ adsenseAttributes: { [key]: value } })
বিভাগ বাদ দেওয়া clearCategoryExclusions() googletag.setConfig({ categoryExclusion: null })
setCategoryExclusion(label) googletag.setConfig({ categoryExclusion: [label] })
সেন্টারিং setCentering(centerAds) googletag.setConfig({ centering: centerAds })
খালি div আড়াল করুন collapseEmptyDivs(collapseBeforeFetch) googletag.setConfig({ collapseDiv: collapseBeforeFetch ? 'BEFORE_FETCH' : 'ON_NO_FILL' })
প্রাথমিক লোড ও সিঙ্গেল রিকোয়েস্ট আর্কিটেকচার (SRA) disableInitialLoad() googletag.setConfig({ disableInitialLoad: true })
enableSingleRequest() googletag.setConfig({ singleRequest: true })
ধীরে ধীরে লোড করা enableLazyLoad(config) googletag.setConfig({ lazyLoad: config })
লোকেশন setLocation(address) googletag.setConfig({ location: address })
SafeFrame setForceSafeFrame(force) googletag.setConfig({ safeFrame: { forceSafeFrame: force } })
setSafeFrameConfig(config) googletag.setConfig({ safeFrame: config })
টার্গেটিং clearTargeting(key) googletag.setConfig({ targeting: { [key]: null } })
setTargeting(key, value) googletag.setConfig({ targeting: { [key]: value } })
ভিডিও বিজ্ঞাপন enableVideoAds() googletag.setConfig({ videoAds: { enableVideoAds: true } })
setVideoContent(contentId, cmsId) googletag.setConfig({ videoAds: { enableVideoAds: true, videoContentId: contentId, videoCmsId: cmsId } })

AdSense অ্যাট্রিবিউট

লিগ্যাসি:

googletag.pubads().set('document_language', 'en');

নতুন:

googletag.setConfig({
  adsenseAttributes: {
    document_language: 'en'
  }
});

বিভাগ বর্জন

লিগ্যাসি:

googletag.pubads().setCategoryExclusion('AirlineAd');
googletag.pubads().clearCategoryExclusions();

নতুন:

// Set category exclusion
googletag.setConfig({
  categoryExclusion: ['AirlineAd']
});

// Clear category exclusions
googletag.setConfig({
  categoryExclusion: null
});

মাঝখানে রাখা হচ্ছে

লিগ্যাসি:

googletag.pubads().setCentering(true);

নতুন:

googletag.setConfig({
  centering: true
});

খালি ডিভ আড়াল করুন

লিগ্যাসি:

googletag.pubads().collapseEmptyDivs(true); // Collapse before fetch
googletag.pubads().collapseEmptyDivs(false); // Collapse on no fill

নতুন:

// Collapse before fetch
googletag.setConfig({
  collapseDiv: 'BEFORE_FETCH'
});

// Collapse on no fill
googletag.setConfig({
  collapseDiv: 'ON_NO_FILL'
});

// Don't collapse
googletag.setConfig({
  collapseDiv: 'DISABLED'
});

প্রাথমিক লোড ও সিঙ্গেল রিকোয়েস্ট আর্কিটেকচার (SRA)

লিগ্যাসি:

googletag.pubads().disableInitialLoad();
googletag.pubads().enableSingleRequest();

নতুন:

googletag.setConfig({
  disableInitialLoad: true,
  singleRequest: true
});

ধীরে ধীরে লোড করা

লিগ্যাসি:

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

নতুন:

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.pubads().setLocation('10001,US');

নতুন:

googletag.setConfig({
  location: '10001,US'
});

SafeFrame

লিগ্যাসি:

googletag.pubads().setForceSafeFrame(true);
googletag.pubads().setSafeFrameConfig({sandbox: true});

নতুন:

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

লক্ষ্য করা

লিগ্যাসি:

googletag.pubads().setTargeting('interests', 'sports');
googletag.pubads().setTargeting('interests', ['sports', 'music']);
googletag.pubads().clearTargeting('interests');
googletag.pubads().clearTargeting();

নতুন:

// Set targeting
googletag.setConfig({
  targeting: {
    interests: 'sports'
  }
});

// Set multiple values
googletag.setConfig({
  targeting: {
    interests: ['sports', 'music']
  }
});

// Clear a specific key
googletag.setConfig({
  targeting: {
    interests: null
  }
});

// Clear all targeting
googletag.setConfig({
  targeting: null
});

ভিডিও বিজ্ঞাপন

লিগ্যাসি:

googletag.pubads().enableVideoAds();
googletag.pubads().setVideoContent('video123', 'cms456');

নতুন:

googletag.setConfig({
  videoAds: {
    enableVideoAds: true,
    videoContentId: 'video123',
    videoCmsId: 'cms456'
  }
});

স্লট-লেভেল কনফিগারেশন সেট করুন

নিচের সারণীতে পুরনো Slot কনফিগারেশন পদ্ধতিকে সেটির setConfig বিকল্পের সাথে ম্যাপ করা হয়েছে।

ফিচার পুরনো পদ্ধতি setConfigটি রিপ্লেসমেন্ট
AdSense অ্যাট্রিবিউট set(key, value) Slot.setConfig({ adsenseAttributes: { [key]: value } })
বিভাগ বাদ দেওয়া clearCategoryExclusions() Slot.setConfig({ categoryExclusion: null })
setCategoryExclusion(label) Slot.setConfig({ categoryExclusion: [label] })
ক্লিক URL setClickUrl(url) Slot.setConfig({ clickUrl: url })
খালি div আড়াল করুন setCollapseEmptyDiv(collapse, collapseBeforeFetch) Slot.setConfig({ collapseDiv: collapse ? (collapseBeforeFetch ? 'BEFORE_FETCH' : 'ON_NO_FILL') : 'DISABLED' })
SafeFrame setForceSafeFrame(force) Slot.setConfig({ safeFrame: { forceSafeFrame: force } })
setSafeFrameConfig(config) Slot.setConfig({ safeFrame: config })
টার্গেটিং clearTargeting(key) Slot.setConfig({ targeting: { [key]: null } })
setTargeting(key, value) Slot.setConfig({ targeting: { [key]: value } })
updateTargetingFromMap(config) Slot.setConfig({ targeting: config })

AdSense অ্যাট্রিবিউট

লিগ্যাসি:

const slot = googletag.defineSlot('/1234567/sports', [160, 600], 'div');
slot.set('adsense_background_color', '#FFFFFF');

নতুন:

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

slot.setConfig({
  adsenseAttributes: {
    adsense_background_color: '#FFFFFF'
  }
});

বিভাগ বর্জন

লিগ্যাসি:

const slot = googletag.defineSlot('/1234567/sports', [160, 600], 'div');
slot.setCategoryExclusion('AirlineAd');
slot.clearCategoryExclusions();

নতুন:

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

// Set category exclusion
slot.setConfig({
  categoryExclusion: ['AirlineAd']
});

// Clear category exclusions
slot.setConfig({
  categoryExclusion: null
});

ক্লিক URL

লিগ্যাসি:

const slot = googletag.defineSlot('/1234567/sports', [160, 600], 'div');
slot.setClickUrl('http://www.example.com?original_click_url=');

নতুন:

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

slot.setConfig({
  clickUrl: 'http://www.example.com?original_click_url='
});

খালি ডিভ আড়াল করুন

লিগ্যাসি:

const slot = googletag.defineSlot('/1234567/sports', [160, 600], 'div');
slot.setCollapseEmptyDiv(true, true); // Collapse before fetch

নতুন:

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

slot.setConfig({
  collapseDiv: 'BEFORE_FETCH'
});

SafeFrame

লিগ্যাসি:

const slot = googletag.defineSlot('/1234567/sports', [160, 600], 'div');
slot.setForceSafeFrame(true);
slot.setSafeFrameConfig({sandbox: true});

নতুন:

const slot = googletag.defineSlot('/1234567/sports', [160, 600], 'div');
slot.setConfig({
  safeFrame: {
    forceSafeFrame: true,
    sandbox: true
  }
});

লক্ষ্য করা

লিগ্যাসি:

const slot = googletag.defineSlot('/1234567/sports', [160, 600], 'div');
slot.setTargeting('allow_expandable', 'true');
slot.clearTargeting('allow_expandable');
slot.updateTargetingFromMap({
  color: 'red',
  interests: ['sports', 'music', 'movies']
});

নতুন:

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

// Set targeting
slot.setConfig({
  targeting: {
    allow_expandable: 'true'
  }
});

// Clear targeting
slot.setConfig({
  targeting: {
    allow_expandable: null
  }
});

// Update targeting (only specified KVs are set/modified).
slot.setConfig({
  targeting: {
    color: 'red',
    interests: ['sports', 'music', 'movies']
  }
});

পৃষ্ঠা-লেভেল কনফিগারেশন পান

নিচের সারণীতে পুরনো PubAdsService গেটার পদ্ধতিকে সেটির getConfig বিকল্পের সাথে ম্যাপ করা হয়েছে।

ফিচার পুরনো পদ্ধতি getConfigটি রিপ্লেসমেন্ট
AdSense অ্যাট্রিবিউট get(key) googletag.getConfig('adsenseAttributes')
getAttributeKeys() googletag.getConfig('adsenseAttributes')
প্রাথমিক লোড isInitialLoadDisabled() googletag.getConfig('disableInitialLoad')
টার্গেটিং getTargeting(key) googletag.getConfig('targeting')
getTargetingKeys() googletag.getConfig('targeting')

AdSense অ্যাট্রিবিউট

লিগ্যাসি:

const documentLanguage = googletag.pubads().get('document_language');
const adsenseAttributes = googletag.pubads().getAttributeKeys();

নতুন:

const adsenseConfig = googletag.getConfig('adsenseAttributes').adsenseAttributes;

// Get the value of a single AdSense attribute.
const documentLanguage = adsenseConfig.document_language || null;

// Get all configured AdSense attribute keys.
const adsenseAttributes = Object.keys(adsenseConfig);

প্রাথমিক লোড

লিগ্যাসি:

const isDisabled = googletag.pubads().isInitialLoadDisabled();

নতুন:

const isDisabled = googletag.getConfig('disableInitialLoad').disableInitialLoad;

লক্ষ্য করা

লিগ্যাসি:

const targeting = googletag.pubads().getTargeting('interests');
const keys = googletag.pubads().getTargetingKeys();

নতুন:

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

// Get targeting for a specific key.
const targeting = targetingConfig.interests || [];

// Get all targeting keys.
const keys = Object.keys(targetingConfig);

স্লট-লেভেল কনফিগারেশন পান

নিচের সারণীতে পুরনো Slot গেটার পদ্ধতিকে তার getConfig বিকল্পের সাথে ম্যাপ করা হয়েছে।

ফিচার পুরনো পদ্ধতি getConfigটি রিপ্লেসমেন্ট
AdSense অ্যাট্রিবিউট get(key) Slot.getConfig('adsenseAttributes')
getAttributeKeys() Slot.getConfig('adsenseAttributes')
বিভাগ বাদ দেওয়া getCategoryExclusions() Slot.getConfig('categoryExclusion')
টার্গেটিং getTargeting(key) Slot.getConfig('targeting')
getTargetingKeys() Slot.getConfig('targeting')

AdSense অ্যাট্রিবিউট

লিগ্যাসি:

const slot = googletag.defineSlot('/1234567/sports', [160, 600], 'div');
const bgColor = slot.get('adsense_background_color');
const adsenseAttributes = slot.getAttributeKeys();

নতুন:

const slot = googletag.defineSlot('/1234567/sports', [160, 600], 'div');
const adsenseConfig = slot.getConfig('adsenseAttributes').adsenseAttributes;

// Get the value of a single AdSense attribute.
const bgColor = adsenseConfig.adsense_background_color || null;

// Get all configured AdSense attribute keys.
const adsenseAttributes = Object.keys(adsenseConfig);

বিভাগ বর্জন

লিগ্যাসি:

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

নতুন:

const slot = googletag.defineSlot('/1234567/sports', [160, 600], 'div');
const exclusions = slot.getConfig('categoryExclusion').categoryExclusion || [];

লক্ষ্য করা

লিগ্যাসি:

const slot = googletag.defineSlot('/1234567/sports', [160, 600], 'div');
const targeting = slot.getTargeting('allow_expandable');
const keys = slot.getTargetingKeys();

নতুন:

const slot = googletag.defineSlot('/1234567/sports', [160, 600], 'div');
const targetingConfig = slot.getConfig('targeting').targeting;

// Get targeting for a specific key.
const targeting = targetingConfig.allow_expandable || [];

// Get all targeting keys.
const keys = Object.keys(targetingConfig);