Skip to content

Instantly share code, notes, and snippets.

@tdukart
Created May 7, 2021 19:14
Show Gist options
  • Save tdukart/1f66069ae3d0ed16d423ba05c06d5eba to your computer and use it in GitHub Desktop.
Save tdukart/1f66069ae3d0ed16d423ba05c06d5eba to your computer and use it in GitHub Desktop.
Shows the order ID for all DFP-served ads.
(() => {
const slots = googletag.pubads().getSlots();
slots.forEach((slot) => {
const domId = slot.getSlotId().getDomId();
const campaignId = slot.getResponseInformation().campaignId;
const element = document.getElementById(domId);
const campaignSpan = document.createElement('span');
campaignSpan.innerHTML = campaignId;
element.parentNode.insertBefore(campaignSpan, element);
})
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment