Enable Open Measurement (iOS)
Enable third-party viewability, verification measurement, and vendor restrictions through the Open Measurement Interface Definition (OMID).
The iOS SDK includes the Open Measurement (OM) SDK. By default, the Open Measurement functionality is disabled. When enabled, the OM SDK supports several ad-related features for VAST ads:
- Third-party viewability
- Verification measurement
- Vendor restrictions
If instead you are interested in utilizing the OM SDK for use with Google IMA, please refer to the documentation on Open Measurement in the Google IMA SDK.
Requirements
Item | Notes |
---|---|
JWPlayerKit | 4.1.0+ |
Google IMA SDK | 3.9.0+ |
Ads configured to trafficAdVerifications in their VAST |
|
Enable Open Measurement
Refrain from covering the
JWPlayerView
with any overlays (transparent or opaque). These will be flagged as obstructions by the OM SDK and reduce viewability.
Use the following steps to enable the Open Measurement functionality:
- (Optional) Create an array of vendors allowed to execute scripts within the
AdVerifications
. If a verification script from an unauthorized vendor is found within an ad, theverificationNotExecuted
script will be executed for the ad as per Open Measurementβs standard. If not defined, all vendors are assumed to be approved. - Use
JWOMIDConfigBuilder()
to create an Open Measurement config,JWOMIDConfig
. If defined in the previous step, be sure to pass the array of vendor allowed to execute scripts. - Use
JWPlayerConfigurationBuilder()
to add theJWOMIDConfig
to the player config.
do {
// Create a JWP VAST ad config
let adConfig = try JWAdsAdvertisingConfigBuilder()
.tag(URL(string: "ad_tag_url")!)
.build()
// Create an Open Measurement config
let vendors: [String] = [
"allowed.vendor.01",
"allowed.vendor.02"
]
let omidConfig = try JWOMIDConfigBuilder()
.allowedVendors(vendors)
.build()
// Create a player item
let item = try JWPlayerItemBuilder()
.file(URL(string: "video_url")!)
.build()
// Initialize the JWPlayerConfiguration
let config = try JWPlayerConfigurationBuilder()
.playlist([item])
.advertising(adConfig)
.adTracker(omidConfig)
.build()
// Configure the player
player.configurePlayer(with: config)
}
catch {
// Handle errors
}
// Create a JWP VAST ad config
NSError *error = nil;
JWAdvertisingConfig *adConfig = [[[JWAdsAdvertisingConfigBuilder new]
tag: [NSURL URLWithString:@"ad_tag_url"]]
buildAndReturnError:&error];
if (error != nil) {
// Handle error
}
// Create an Open Measurement config
NSArray *vendors = @[@"allowed.vendor.01",
@"allowed.vendor.02"];
JWOMIDConfig *omidConfig = [[[JWOMIDConfigBuilder new]
allowedVendors:vendors]
buildAndReturnError:&error];
if (error != nil) {
// Handle error
}
// Create a player item
JWPlayerItem *item = [[[JWPlayerItemBuilder new]
file:[NSURL URLWithString:@"video_url"]]
buildAndReturnError:&error];
if (error != nil) {
// Handle Error
}
// Initialize the JWPlayerConfiguration
JWPlayerConfiguration *config = [[[[[JWPlayerConfigurationBuilder new]
playlist:@[item]]
advertising:adConfig]
adTracker:omidConfig]
buildAndReturnError:&error];
if (error != nil) {
// Handle error
}
// Configure the player
[player configurePlayerWith:config];
Manage friendly obstructions
If you use JWPlayerViewController
, friendly obstructions within the interface are reported and handled. However, if you do not use JWPlayerViewController
or want to prevent other UIViews
from affecting ad viewability, you should register these obstructions as friendly.
The following examples apply to JWP VAST and Google IMA/DAI ad clients.
Register a friendly obstruction
- Create a list of one or more
JWFriendlyObstruction
. Be sure to supply thepurpose
(using predefined constants) and thereason
the obstruction is friendly.let playButton = UIButton() // Assume this is a UIButton you have a reference to let countdownLabel = UILabel() // Assume this is a UILabel you have a reference to let obstructions = [ JWFriendlyObstruction(view: playButton, purpose: .mediaControls, reason: "Play button"), JWFriendlyObstruction(view: countdownLabel, purpose: .other, reason: "Ad countdown") ]
UIButton *playButton = [UIButton new]; UILabel *countdownLabel = [UILabel new]; NSArray *obstructions = @[ [[JWFriendlyObstruction alloc] initWithView:playButton purpose:JWFriendlyObstructionPurposeMediaControls reason:@"Play button"], [[JWFriendlyObstruction alloc] initWithView:countdownLabel purpose:JWFriendlyObstructionPurposeOther reason:@"Ad countdown"] ];
- Use
func register(_ obstructions: [JWFriendlyObstruction])
to register the obstructions with the player.player.friendlyObstructions.register(obstructions)
[player.friendlyObstructions register:obstructions];
Deregister a friendly obstruction
To deregister friendly obstructions, use one of the following approaches:
- Deregister a defined list of friendly obstructions when calling
func register(_ obstructions: [JWFriendlyObstruction])
player.friendlyObstructions.deregister(obstructions)
[player.friendlyObstructions deregister:obstructions];
- Deregister all registered
JWFriendlyObstruction
objects.player.friendlyObstructions.deregisterAllObstructions()
[player.friendlyObstructions deregisterAllObstructions];
Updated about 1 year ago