The DFP code I've been using on my site has been working for some time, but on fixing another issue, I noted a warning in the console for each ad slot defined:
Incorrect usage of googletag.Slot defineSizeMapping: Size mapping has to be an array
var mobileMapping = googletag.sizeMapping().
addSize([0, 0], [320,50]).
addSize([0, 0], [320,100]).
addSize([0, 0], [320,150]).
build();
adSlots.ad_mobile_1 = googletag.defineSlot( '/6129006/ad_mob_1',
[[320, 50], [320, 100], [320, 150]],
'ad_mob_1')
.defineSizeMapping(mobileMapping)
.addService(googletag.pubads())
.setCollapseEmptyDiv(true);
Which follows Google's own responsive tutorial for how implement a sizeMapping in a defineSizeMapping call.
The warning suggested that defineSizeMapping
expects an array, whereas sizeMapping
seems to be outputting an object.
I've tried various implementations of the code but can't see what's wrong.... can any DFP experts shed a little light?
As you set the mapping for the same resolution three time in a row, try adding the ad sizes in an array :
var mobileMapping = googletag.sizeMapping().
addSize([0, 0], [[320,50],[320,100],[320,150]]).
build();