ORTB
OMID chapter navigation

AdSession & session construction

API

The listings on this page are generated by scripts/gen-omid-spec.mjs from official IAB Tech Lab sources, with descriptions in the original English; see the page footer for the collection baseline.

On this page

Role & scope

AdSession is the main object of the session client: creation, start / finish, impression and creative-loaded declarations, error reporting, event registration and element bounds updates. The objects needed to construct it — Context / Partner / VerificationScriptResource / OmidVersion — are listed alongside, with the corresponding iOS / Android names. UniversalAdId and VastProperties are referenced by a Context constructor parameter and by AdEvents.loaded(); the JS source exports both (packageExport onto OmidSessionClient) but the official JSDoc site publishes no page for either, so this chapter shows them only as parameter types rather than in their own tables.

Client
Session client
Platform
JavaScript
Library version
1.6.10
Public members
12

API surface

AdSessionjs · 12

The JS ad session API enabling the integration partner to contribute to an existing native ad session. This is also responsible for communicating to the OM SDK JS service and will also handle scenarios with limited access to the OM SDK JS service - i.e. cross-domain iFrames. This API is commonly used in the following scenarios; - video ad session relying on the HTML5 video player for injecting verification script resources and/or publishing OMID video events. - display ad session relying on a separate JS component to handle the impression event.

NameSignatureReturnsOfficial description
AdSessionnew AdSession(context, communication, sessionInterface)void(no official description provided)
  • context: Contextthat provides the required information for initialising the JS ad session.
  • communication: Communication<?>This parameter is for OM SDK internal use only and should be omitted.
  • sessionInterface: OmidJsSessionInterfaceThis parameter is for OM SDK internal use only and should be omitted.
errorerror(errorType, message)voidNotifies that an error has occurred on the ad session. All verification clients will be notified via the 'sessionError' session observer event.
  • errorType: ErrorTypeHigh level error type.
  • message: stringDescription of the session error.
finishfinish()voidIf there is a currently active ad session, this notifies all session observers that the ad session has finished with a SESSION_FINISH event. This ceases ad view tracking and message sending to verification scripts injected for the ad session. This method has no effect if called if there is no active ad session or in a mobile app environment.
getAdSessionIdgetAdSessionId()stringGet the ID of this ad session.
isSupportedisSupported()booleanReturns true if OMID is available, false otherwise.
registerAdEventsregisterAdEvents()voidRegisters the existence of an AdEvent instance.
registerMediaEventsregisterMediaEvents()voidRegisters the existence of an MediaEvents instance.
registerSessionObserverregisterSessionObserver(functionToExecute)voidSubscribes to all session events ('sessionStart', 'sessionError', and 'sessionFinish'). The event handler will be called with a single argument that has the following fields: 'adSessionId': string, 'timestamp': number, 'type': string, 'data': object
  • functionToExecute: function(Event)An event handler which will be invoked on session events.
setCreativeTypesetCreativeType(creativeType)voidSpecifies the type of creative to be rendered in this session. Requires that the native layer set the creative type to DEFINED_BY_JAVASCRIPT.
  • creativeType: CreativeTypeThe type of creative.
setElementBoundssetElementBounds(elementBounds)voidSet the DOM element's geometry relative to the geometry of either the slotElement or the cross domain iframe the creative's DOM element is in.
  • elementBounds: Rectangle
setImpressionTypesetImpressionType(impressionType)voidSpecifies the type of impression to be triggered in this session. Requires that the native layer set the impression type to DEFINED_BY_JAVASCRIPT.
  • impressionType: ImpressionTypeThe type of impression.
startstart()voidIf there is no currently active ad session, this notifies all session observers that an ad session has started with a SESSION_START event. This starts ad view tracking and makes video and ad events available to send to verification scripts injected for this ad session. This method has no effect if called after the ad session has already started or in a mobile app environment.
docs.iabtechlab.com/omsdk-1.6/js/AdSession.html

Members the official source marks as friend scoped (not to be exported beyond obfuscation) are filtered out of this table; the public path for impression and creative load is AdEvents.

Session construction

Contextjs · 11

Holds information provided into the ad session context by the JavaScript layer.

NameSignatureReturnsOfficial description
Contextnew Context(partner, verificationScriptResources, contentUrl, customReferenceData, universalAdId)voidCreate a new ad session context providing reference to partner and a list of script resources which should be managed by OM SDK service.
  • partner: PartnerThe integration's partner ID and version.
  • verificationScriptResources: Array<VerificationScriptResource>The verification resources to load.
  • contentUrl: stringOn web, the URL of top-level web page. In apps, an optional content URL of the screen within the app that is showing the ad, such as an Android deep link or iOS universal link. Defaults to null.
  • customReferenceData: stringArbitrary reference data the integrator can share with verification scripts. Has no effect in mobile app environment. Defaults to null.
  • universalAdId: UniversalAdId- The UniversalId tag used for creative ID validation. Defaults to null.
contentUrlcontentUrl: stringstring(no official description provided)
customReferenceDatacustomReferenceData: stringstring(no official description provided)
serviceWindowserviceWindow: WindowWindowIf not null, the window to which service communication should be directed, overriding the default search algorithm.
slotElementslotElement: HTMLElementHTMLElement(no official description provided)
underEvaluationunderEvaluation: booleanbooleanWhether or not this ad session is under evaluation, as defined by "Evaluation Flag" in the Open Measurement License for Web Video, V 1.0. Ignored in app environments. Defaults to false.
universalAdIduniversalAdId: UniversalAdIdUniversalAdId(no official description provided)
videoElementvideoElement: HTMLVideoElementHTMLVideoElement(no official description provided)
setServiceWindowsetServiceWindow(serviceWindow)voidBy default, the OM SDK Session Client Library will assume the Service Script is present in the same frame the library is loaded in, or top. Call this method to override this default and point the library to the give window instead.
  • serviceWindow: WindowThe window containing the OMID Service Script.
setSlotElementsetSlotElement(slotElement)voidSpecifies the ad creative HTML element within the WebView.
  • slotElement: HTMLElementThe ad creative DOM element.
setVideoElementsetVideoElement(videoElement)voidSpecifies the video element within the WebView.
  • videoElement: HTMLVideoElementThe video element.
docs.iabtechlab.com/omsdk-1.6/js/Context.html

Partnerjs · 1

Holds information about the integration partner that is using the session client.

NameSignatureReturnsOfficial description
Partnernew Partner(name, version)voidCreates a new partner instance given a name and a version.
  • name: stringThe partner ID of the integration.
  • version: stringThe version of the integration's session script.
docs.iabtechlab.com/omsdk-1.6/js/Partner.html

VerificationScriptResourcejs · 6

Represents a verification script resource that comes in a VAST extension for VAST versions <= 3 or a verification node for VAST versions >= 4

NameSignatureReturnsOfficial description
VerificationScriptResourcenew VerificationScriptResource(resourceUrl, vendorKey, verificationParameters, accessMode)voidCreates new verification script resource instance which requires vendor specific verification parameters.
  • resourceUrl: string
  • vendorKey: string
  • verificationParameters: string
  • accessMode: AccessModeThe level of access this verification script will have when executed.
accessModeaccessMode: AccessModeAccessMode(no official description provided)
resourceUrlresourceUrl: stringstring(no official description provided)
vendorKeyvendorKey: string(string|undefined)(no official description provided)
verificationParametersverificationParameters: string(string|undefined)(no official description provided)
toJSONtoJSON()Object(no official description provided)
docs.iabtechlab.com/omsdk-1.6/js/VerificationScriptResource.html

OmidVersionjs · 1

Represents the Version of OMID Session Client.

NameSignatureReturnsOfficial description
OmidVersionnew OmidVersion(semanticVersion, apiLevel)void(no official description provided)
  • semanticVersion: string
  • apiLevel: string
docs.iabtechlab.com/omsdk-1.6/js/OmidVersion.html

Cross-platform naming

ConceptJavaScriptiOSAndroid
ad-sessionAdSessionOMIDAdSessionAdSession
ad-session-configurationOMIDAdSessionConfigurationAdSessionConfiguration
ad-session-contextOMIDAdSessionContextAdSessionContext
contextContext
omid-versionOmidVersion
partnerPartnerOMIDPartnerPartner
verification-script-resourceVerificationScriptResourceOMIDVerificationScriptResourceVerificationScriptResource
  • ad-session-configurationNo JS counterpart: creativeType/impressionType are set through AdSession.setCreativeType()/setImpressionType(), and the event-owner concept (impressionOwner/mediaEventsOwner) does not exist on the JS side.
  • ad-session-contextCorresponds to Context on JS: JS folds partner, verificationScriptResources, contentUrl, customReferenceData, universalAdId and the slot/video element into Context plus the AdSession constructor arguments, while the native side splits them into AdSessionContext (iOS additionally has AdSessionConfiguration).
  • contextNo class of this name on iOS/Android: the JS Context is split on the native side into AdSessionContext + AdSessionConfiguration (see the ad-session-context / ad-session-configuration entries).
  • omid-versionPublished on JS only: the top of the source file omid-version.js carries TODO(OMSDK-715) noting that the class seems unused and should be removed in the next major version, yet the JSDoc site still publishes it.

Class names for the same concept on each of the three platforms; a blank cell means that platform provides no corresponding class. On the JS side session configuration is folded into Context and the constructor arguments, while iOS / Android split it into separate configuration and context classes.

Common failure modes

  • universal-ad-id

    Published on iOS only: the JS source has UniversalAdId (exported via packageExport onto OmidSessionClient.UniversalAdId, added in 1.5.5) but the official JSDoc site has no page for it; Android's createNativeAdSessionContext(...)/getUniversalAdId() reference the UniversalAdId type in their signatures, and the javadoc site has no such page either (verified 404).

  • vast-properties

    VastProperties on JS (src/common/vast-properties.js, marked @public and listed in jsdoc.json's include list) is not published on the official JSDoc site (VastProperties.html verified 404), so js is recorded as null; AdEvents.loaded(vastProperties) therefore references a type that is undocumented on the site.

Content is taken from official IAB Tech Lab sources (the OM SDK JS repository, the three platforms' official API docs, the OpenRTB support advisory and the VAST specification); spec data is kept in the original English and site-written prose is bilingual. See data/omid-spec/PROVENANCE.json for provenance.