All of this work should be isolated to the bulbs-public-ads-manager.
This custom criteria key they use is amznslots
. We do use async
mode, e.g. amznads.setTargetingForGPTAsync
<script type='text/javascript'>
var amznads = amznads || {};
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
amznads.asyncParams = {
'id': '3076',
'callbackFn': function() {
try {
amznads.setTargetingForGPTAsync('amznslots');
} catch (e) { /*ignore*/ }
/* Continue your DFP call here (optional) */
},
'timeout': 2e3
};
(function() {
var a, s = document.getElementsByTagName("script")[0];
a = document.createElement("script");
a.type = "text/javascript";
a.async = true;
a.src = "http://c.amazon-adsystem.com/aax2/amzn_ads.js";
s.parentNode.insertBefore(a, s);
})();
</script>
When ad library is initialized, call:
1. amznads.getAds('3076'); // in `initGoogleTag` logic
2. amznads.setTargetingForGPTAsync('amznslots'); // in `setSlotTargeting` method
Need to use this call back with changes to refreshSlot
amznads.getAdsCallback(id, callbackFunction, timeout, size)
Should remember to clear:
googletag.pubads().clearTargeting('amznslots'); // clear custom targeting value by key