question
I'm working on a bid adapter which will receive ad markup which I can't pass back directly within the Prebid bid, since it's a JSON that looks like this:
img: {
url: 'http://host/static/ad.jpg',
w: 320,
h: 50,
ctaurl: 'http://host/track/ctaurl'
},
impressiontrackers: [
'http://host/track/imp/1',
'http://host/track/imp/2'
],
clicktrackers: [
'http://host/track/click/1'
]
}
So I'm thinking I will have to generate HTML (an img tag for the ad, pixel images for the impression trackers) and pass it in bid.ad. How would I go about adding event handlers to img tags or setting e.g. .style.display='none'. I'm assuming I can't change the DOM directly and the HTML returned has to be self contained. So would I add JavaScript to my markup that adds event handlers, or would this have to be an iframe?
Would be nice to know if I'm thinking into the right direction or if you could point me to adapters that already do something simular.
So basically you need a custom 'renderer' to parse the JSON and make something that can be displayed. This is a topic we've discussed, and our draft position is detailed in https://docs.google.com/document/d/1kK0ifXV-vzyV7VchPKoyGuz375H7fzbTJFt_oWeCiRo/edit#
One adapter we're aware of that does something along these lines is astraoneBidAdapter.js. We caution against copying this adapter's approach directly because we're going to make them change it in a future release. (heads up @astraone-ssp ). Specifically, references to external code (https://st.astraone.io/prebidrenderer.js) will have to change so that they're better controlled and transparent.
Below is the most relevant section about loading external code. If you can get away with something lighter and built right into the adapter, that would be better.
The originator gave a thumbs up on the explanation, so closing this. Thanks.
Most helpful comment
So basically you need a custom 'renderer' to parse the JSON and make something that can be displayed. This is a topic we've discussed, and our draft position is detailed in https://docs.google.com/document/d/1kK0ifXV-vzyV7VchPKoyGuz375H7fzbTJFt_oWeCiRo/edit#
One adapter we're aware of that does something along these lines is astraoneBidAdapter.js. We caution against copying this adapter's approach directly because we're going to make them change it in a future release. (heads up @astraone-ssp ). Specifically, references to external code (https://st.astraone.io/prebidrenderer.js) will have to change so that they're better controlled and transparent.
Below is the most relevant section about loading external code. If you can get away with something lighter and built right into the adapter, that would be better.