Serving Prebid into SafeFrames

Prebid and SafeFrames are compatible, but only with some tweaks. Get the required snippet to effectively use Prebid within a SafeFrame.

The SafeFrame 1.0 spec came into existence in 2014, as a way for publishers to serve interactive ads that were both full-featured, and also protective of the user’s sensitive information. The SafeFrame spec can prevent common issues among malicious creatives that degrade the user’s experiences and offer support for viewability, which is an increasingly prevalent metric within AdTech.

Despite the many benefits of SafeFrames, there have been difficulties in making them compatible with traditional ad tags that 3rd party vendors (such as Sovrn) provide. In fact, we recommend that publishers do not serve our display (or “waterfall”) tags through SafeFrames.

You will have to have your Prebid setup to version 3.22 to ensure that secure creatives use event.origin rather than a hard coded adServerDomain. We recommend that you stay up-to-date with the most recent Prebid changes, and you can find those releases here

Sovrn Solution

With Safeframe 2.0 becoming publicly available for comment, we want to make sure that publishers know that Prebid does support SafeFrame 2.0 as long as the universal creative is included. Sovrn does support this, and many of our publishers are able to successfully use SafeFrames with Prebid.

Here's a link to the Prebid documentation containing the different implementation instructions for the Universal Creative Code.

You can find the Universal Creative code below:

<script src = "https://cdn.jsdelivr.net/npm/prebid-universal-creative@latest/dist/creative.js"></script>
<script>
var ucTagData = {};
ucTagData.adServerDomain = "";
ucTagData.pubUrl = "%%PATTERN:url%%";
ucTagData.targetingMap = %%PATTERN:TARGETINGMAP%%;
ucTagData.hbPb = "%%PATTERN:hb_pb%%"; try {
ucTag.renderAd(document, ucTagData);
} catch (e) {
console.log(e);
}
</script>

If you get stuck, please remember that the Publisher Advancement team is here to help! Contact us with your questions by clicking here.