- Prerequisites
- Installation
- Insert the Teads parameters in the bid request
- Teads bid response
- Ad rendering & Ad listeners
- Ad Resizing
- Ad Formats
- AdPlacementSettings & AdRequestSettings
- Prebid Server setup
- Check list
This article shows you how to deliver Teads ads on your application using a standalone Prebid integration where you don't use the official Prebid SDK but you do have your own integration with a Prebid Server.
This integration requires you to integrate the Teads Adapter on server side and the Teads SDK on mobile side as well.
Teads SDK is still relevant in this sort of integration since the Teads Prebid Adapter will serve non-standard demand which requires a dedicated player.
Sample Teads App on GitHub
Teads inApp SDK Sample App
Prerequisites
Installation
CocoaPods
If your project is managing dependencies through CocoaPods, you just need to add this pod to your Podfile.
It will install the Teads adapter along with the Teads inApp SDK.
- Add the following Pod in your Podfile:
pod 'TeadsSDK', '~> 5.1.2'
- Run the following console command to install it in your project.
$ pod install --repo-update to install
Insert the Teads parameters in the bid request
Teads needs additional parameters in the bid request in order to process the bidding on its adapter.
Below you can see the part of the bid request JSON that concerns these additional parameters while other parts are omitted.
{
"imp":*,
"ext": {
"prebid": {
"sdk": {
"renderers": [
{
"name": "teads",
"version": "5.1.0",
"data": {
"extra1": true,
"extra2": "189"
}
}
]
}
}
}
}
Notice that such values are not static and you must retrieve it with the Teads SDK and embed the content in the node ext.prebid.sdk
by yourself.
So in order to retrieve such values use the TeadsPrebidAdPlacement
class as below. Do it at least once per app session.
import TeadsSDK
let adPlacementSettings = TeadsAdPlacementSettings { setting in
settings.enableDebug() // remove in production
}
let placement = Teads.createPrebidPlacement(settings: settings.adPlacementSettings, delegate: self)
let teadsBidRequestExtraData = prebidAdPlacement.getData(requestSettings: settings.adRequestSettings)
// result is a JSONObject with the renderers list, see a sample below
// e.g. {"renderers":[{"name":"teads","version":"5.1.0","data":{"extra2":"189","extra1":true}}]}
Teads bid response
See below a simplified sample about what would be the bid response once Teads win the auction with the data that characterizes Teads as the winner of the auction:
{
"id": "f34bbf12-18c8-463d-80f1-1eba20e8f4bf",
"seatbid": [
{
"seat": "teads",
"bid": [
{
"id": "imp-video-300x250",
"impid": "f34bbf12-18c8-463d-80f1-1eba20e8f4bf",
"price": 3.91,
"nurl": "https://dummy.nurl.teads.tv",
"adm": "<html><body><p>Dummy creative content</p></body></html>",
"adid": "625187",
"adomain": ["teads.com"],
"cid": "1088501",
"crid": "625187",
"cat": ["IAB12"],
"ext": {
"prebid": {
"meta": {
"rendererName": "teads",
"rendererVersion": "5.1.2"
},
"targeting": {
"hb_pb": "3.91",
"hb_bidder": "teads"
}
}
},
"h": 250,
"w": 300
}
]
}
],
"cur": "USD"
}
Ad rendering & Ad listeners
Once Teads wins the auction, delegate the ad rendering to Teads SDK by passing to it the winning bid response and subscribing to the ad lifecycle as below.
See that an instance of AdRequestSettings
is necessary with the key TeadsAdapterSettings.prebidStandaloneKey
with value "1"
to enable this sort of integration.
import TeadsSDK
class MyViewController : UIViewController, TeadsInReadAdPlacementDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let adRequestSettings = TeadsAdRequestSettings { settings in
// Ensure to inform your article url or domain url for brand safety matters
settings.pageUrl("https://www.your.url.com")
// Add this extra to enable your standalone integration
settings.addExtras("1", for: TeadsAdapterSettings.prebidStandaloneKey)
}
let placement = Teads.createPrebidPlacement(settings: settings.adPlacementSettings, delegate: self)
placement.loadAd(adResponse: stringfiedWinningBidJSON, requestSettings: adRequestSettings)
}
override func didReceiveAd(ad: TeadsInReadAd, adRatio: TeadsAdRatio) {
inReadView.bind(ad)
ad.delegate = self
resizeTeadsAd(adRatio: adRatio)
}
override func didUpdateRatio(ad: TeadsInReadAd, adRatio: TeadsAdRatio) {
resizeTeadsAd(adRatio: adRatio)
}
override func didFailToReceiveAd(reason: AdFailReason) {
super.didFailToReceiveAd(reason: reason)
}
override func adOpportunityTrackerView(trackerView: TeadsAdOpportunityTrackerView) {
super.adOpportunityTrackerView(trackerView: trackerView)
inReadView.addSubview(trackerView)
}
func resizeTeadsAd(adRatio: TeadsAdRatio) {
slotHeightConstraint.constant = adRatio.calculateHeight(for: inReadView.frame.width)
}
}
Ad Resizing
This part is a must and not implementing it will drastically affect the fill rate from Teads demand.
Having the ad creative correctly rendered is crucial to ensure great user experience and good performance measurement.
Allowed by VPAID standard; ads can adopt modular dimensions and ratios in place of pre-defined fixed sizes making it necessary to be able to dynamically adapt the size and ratio of the ad view depending on the loaded creative.
Even though resize requests occur generally in the ad initialization steps, it is necessary to be able to satisfy them all throughout the ad experience.
It is mandatory to programmatically adapt the size of the Ad container.
The Teads inApp SDK will notify you of each resize request coming from the creative.AdRatio contains all the information to calculate the corresponding height for the requested width.
Use calculateHeight to ease the calculation.
As shown before, see the sample below where the containerAdView
is the view group that encapsulates your InReadAdView
import TeadsSDK
class MyViewController : UIViewController, TeadsInReadAdPlacementDelegate {
@IBOutlet weak var teadsAdView: TeadsInReadAdView!
@IBOutlet weak var slotHeightConstraint: NSLayoutConstraint! // set to 0 in InterfaceBuilder
func didReceiveAd(ad: TeadsInReadAd, adRatio: TeadsAdRatio) {
teadsAdView.bind(ad)
ad.delegate = self
resizeTeadsAd(adRatio: adRatio)
}
func didUpdateRatio(ad: TeadsInReadAd, adRatio: TeadsAdRatio) {
resizeTeadsAd(adRatio: adRatio)
}
func resizeTeadsAd(adRatio: TeadsAdRatio) {
slotHeightConstraint.constant = adRatio.calculateHeight(for: teadsAdView.frame.width)
}
Ad Formats
Currently this integrations supports InRead
only.
ℹ️ Notice that InRead could serve image and video as well.
AdPlacementSettings & AdRequestSettings
Find the full settings list here
Prebid Server setup
Notice that in order to turn your Standalone integration fully functional and leverage from Teads demand you need to wire the Teads Adapter to your Prebid Server, please find more here.
The following configuration for each of your ad slots name is required:
{
"name": "imp-300x250-banner"
}
A placement id provided by your publisher manager is required as the sample below:
{
"ext": {
"teads": {
"placementId": 204344
}
}
}
Check list
- ✅ Insert the Teads parameters in the bid request
- ✅ Load your ad by informing the winning bid JSON
- ✅ Subscribe to the event listeners
- ✅ Implement ad view resizing
- ✅ Setup your Prebid Server with the Teads Adapter
- ✅ Ensure Brand Safety is enabled
- ✅ Ensure you comply with privacy legal requirements (GDPR/CCPA).
- ✅ Comply with app-ads.txt