Forum Moderators: phranque
// where "12345" represents my Ad Manager ID
googletag.cmd.push(function() {
googletag.defineSlot('/21849154601,12345/Ad.Plus-300x250', [300, 250], 'atf_unit')
.addService(googletag.pubads());
googletag.enableServices();
googletag.display('atf_unit');
}); googletag.defineSlot('/21849154601,12345/Ad.Plus-300x250', [300, 250], 'atf_unit')]/code]
the [i],12345[/i] defines the passback Ad Manager account. That much makes sense.
But beyond that? I have no idea. I [i]think[/i] that the ad unit on their end is named "Ad.Plus-300x250", so do I need to create the same ad unit in my Ad Manager?
I also came across a setting that claims to be important, but it doesn't appear to have had an impact for me. I modified this line:
[code].addService(googletag.pubads()); $URL = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
.addService(googletag.pubads()
.set('page_url', '$URL')
); <!-- in my case, this is already at the top so it's not necessary again -->
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
// same here; this is defined at the top so it's not actually needed here again
window.googletag = window.googletag || {cmd: []};
// trigger this 500ms after the document is complete
var interval = setInterval(function() {
if (document.readyState === 'complete') {
clearInterval(interval);
altFunc();
}
}, 500);
function altFunc() {
var i, unit;
for (unit in ['atf_unit', 'btf_unit']) {
if (
(i = document.getElementById(unit)) &&
i.style.display !== 'none' &&
// my active ad units have at least 300px width set in CSS, so if it's
// under 300px then ignore it
i.clientWidth > 200 &&
// if the height isn't greater than 50px then it must be empty
i.clientHeight < 50) {
// my Ad Manager ID
var slot = '/12345/',
size;
googletag.cmd.push(function() {
googletag.pubads().collapseEmptyDivs();
// atf
if (unit === 'atf_unit') {
slot += '300x250_ATF_Adsense';
size = '[[300, 600], [300, 250]]';
}
// btf
if (unit === 'btf_unit') {
slot += '300x250_BTF_Adsense';
size = '[[300, 600], [300, 250]]';
}
googletag.defineSlot(slot, size, unit)
.addService(googletag.pubads()
// no idea if this helps, but it doesn't hurt
.set('page_url', '{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}')
);
googletag.pubads().enableSingleRequest();
googletag.enableServices();
googletag.display(unit);
});
}
}
}