You are here: Developers > Ad Request API > Javascript ad tags > OX instance methods

OX instance methods

Last updated on May 4, 2017

An OX instance manages the ad requestCommunication from a web browser or app to an ad server to display an ad. for a subset of ad units on a web page and is created by calling OX().

Use OX instance methods to set distinct configuration or ad request parameters for a given instantiation of an OX object. You can create multiple instances of an OX object in a single page view.

When building your JavaScript tags, determine the location in the source code of your ad space where specific methods must be placed and the order in which they must be called. For example, you must use the addAdUnit method before the fetchAds method, so you might place addAdUnit in the header of a webpage and fetchAds in the body.

Use a constructor to create a new OX object, which is assigned to a local variable. To protect against global namespace collisions, the OpenX tag generator creates a variable that has a random string appended to its name. For example, var OX_string = OX();.

The following OX instance methods are all void operations (they return an empty response with no data).

OX instance methods

Method name Description Placement in HTML source Order
addAdUnit Request an ad for an ad unitThe smallest inventory component that represents the space on a site where ads display.. Header Before fetchAds
addContentTopic The content topicDescribes the main subject of the online content surrounding the ad space, such as sports or automotive. of the current page view Header Before fetchAds and load
addOpenRTBParameter Adds OpenRTB data to the ad request so that it can be passed to buyers in the OpenX Ad Exchange Header Before fetchAds and load
setAdvertiserID Set the user's advertising ID and whether or not the user has requested for ad tracking to be limited. Body Before fetchAds
addPage Set the predefined ad unit groupA collection of ad units where related ads display together at the same time. to request ads for Header Before fetchAds and setAdUnitSlotId
addVariable A key-value pair to add to ad requests for the ad tagA small piece of code that defines the ad space where ads display on a website. It includes parameters that describe the inventory advertising campaigns can target, which may in turn display ads in the ad space. Header Before fetchAds and load
disableMarket Disable OpenX Ad Exchange for the current ad request Body Before fetchAds
disableSegmentation Disable audience segmentation for the ad request Body Before showAdUnit
enableMarket Enable OpenX Ad Exchange for the current ad request Body Before showAdUnit
enableSegmentation Enable audience segmentation for the ad request Body Before showAdUnit
fetchAds For synchronous ad tags, invoke an ad request based on other OX instance methods and queues selected ads. Header Before showAdUnit
frameCreatives Set the default behavior for ads loaded in the current page. This can be over-ridden for specific instances or requests. Body Before showAdUnit and load
load For an asynchronous ad tag, invoke an ad request based on other OX instance methods and queues and displays selected ads. Body After setAdUnitSlotId
setAdUnitFallback A fallback ad to serve for an ad unit if an ad request returns an empty ad Body Before showAdUnit and load
setAdUnitImpBeacon Set a third-party impressionA single display of an ad on a web page, mobile app, or other delivery medium. For deals, impression is a metric to relay the total number of ads that have served. See also billable impression, forecasted impressions. beaconAn element on a publisher’s website that is invisible to users while it gathers information. AKA “tracking pixels.” for the ad request. Body Before showAdUnit and load
setAdUnitMarketFloor Set the floorThe minimum price a publisher is willing to accept for a given impression. price for an ad unit in this ad request. Body Before showAdUnit
setAdUnitNGFloor Set the non-guaranteed market floor for an ad unit in this ad request. Body Before showAdUnit
setAdUnitSlotId For an asynchronous ad tag, match the ad unit with the placeholder element defined for it. Body Before load
setAnchorTarget Set the window target for clicks on the current page view. Header Before fetchAds and load
setAPIFrameworks Set the API frameworks supported by the mobile appSynonymous with mobile. Refers to the use of an app via a mobile device, specifically to differentiate from mobile web.. Body Before fetchAds
setAppBundleID Set the bundle ("packageA bundle of targeting criteria for similar inventory segments which you can offer at a predetermined price (typically to facilitate regular sales efforts) and automatically create line items from in OpenX.") ID of the mobile app in which the tag is running. Body Before fetchAds
setAppName Set the name of the mobile app in which the tag is running. Body Before fetchAds
setAppStoreURL Set the app store URL from which the mobile app can be downloaded. Body Before fetchAds
setClickRedirectURL Set the click redirect URL for the ad request. Header Before fetchAds
setCoords Set the geolocation for the ad request. Body Before fetchAds
setGateway Set the base URL for the ad gateway to use for the ad tag object. Header Before fetchAds
setOpenRTBParameters Specify a JSON string to pass OpenRTB-compliant data to Ad Exchange buyers Header Before fetchAds and load
setRefererURL Set the referring URL for the ad request. Header Before fetchAds and load
setRefreshDelay Set the refresh delay or primary trigger for refreshing an iframe. Body Before showAdUnit
setRefreshMax Set the maximum number of refreshes for ads displayed through the ad tag. Body Before showAdUnit and load
setUserID Set the customer-provided user ID in the request. Header Before fetchAds and load
showAdUnit Display specified ads in the anchor locations. Body After fetchAds

Feedback form