JavaScript OX Instance Methods
Last updated on January 16, 2019
An OX instance manages the ad request for a subset of ad units on a webpage 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).
Method name | Description | Placement in HTML source | Order |
---|---|---|---|
addAdUnit | Request an ad for an ad unit. | Header | Before fetchAds |
addContentTopic | The content topic 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 group to request ads for. | Header | Before fetchAds and setAdUnitSlotId |
addVariable | A key-value pair to add to ad requests for the ad tag. | 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 impression beacon for the ad request. | Body | Before showAdUnit and load |
setAdUnitMarketFloor | Set the floor 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 app. | Body | Before fetchAds |
setAppBundleID | Set the bundle (“package”) 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 |
Instance Methods Reference
This section contains reference documentation of all OX instance methods listed above.
addAdUnit
Click to expand section
Use this method to tell the tag library to fetch an ad for the specified ad unit when the fetchAds
method is called. You can call this method multiple times using the same or different ad unit IDs (for example, for a multi-ad unit request).
If you call this method multiple times, ads are requested for each ad unit specified. If you specify the same ad unit multiple times, multiple ads are requested for the same ad unit.
Parameters
Parameter | Description | Required? |
---|---|---|
auid | The ID for the ad unit that you want to request an ad for. | Yes |
Example
OX_string.addAdUnit("auid");
Where 12345
is a random string and auid
is the ad unit ID.
addContentTopic
Click to expand section
Use this method to indicate the ID of the node in the predefined content topic taxonomy that matches the content in the current page view. Frequently, it may be implemented dynamically by a content management system. The ID is included with each ad request made from the instance of the OX object, as the tid
parameter.
You need to call this method before the fetchAds
method is called.
Parameters
Parameter | Description | Required? |
---|---|---|
topic_ID | The ID for the content topic of the current page. | Yes |
Example
OX_string.addContentTopic("51")
Where 51
is the node ID for the content topic of the current page.
addOpenRTBParameter
Click to expand section
This method adds OpenRTB data to the ad request so that it can be passed to buyers in the OpenX Ad Exchange. Specify OpenRTB values as a key path, such as app.ver
, where app
represents the App object of the BidRequest and ver
is an App object field representing the version of the mobile app.
You must pass this method before the fetchAds
and load
methods.
Parameters
Parameter | Description | Required? |
---|---|---|
key | The OpenRTB JSON key path. | Yes |
value | The OpenRTB value. | Yes |
Example
OX_string.addOpenRTBParameter("imp[0].banner.w", 320);
OX_string.addOpenRTBParameter("imp[0].banner.h", 50);
OX_string.addOpenRTBParameter("app.ver", "1.0");
OX_string.addOpenRTBParameter("app.paid", 0);
OX_string.addOpenRTBParameter("app.keywords", "games");
Where:
string
: A random string."imp[0].banner.w"
,320
: The path to the Imp object’sw
field, which expresses the width of the ad unit in pixels."imp[0].banner.h"
,50
: The path to the Imp object’sh
field, which expresses the height of the ad unit in pixels."app.ver"
,"1.0"
: The path to the App object’sver
field, which provides the mobile app’s version string."app.paid"
,"0"
: The path to the App object’s paid field, where0
means the app is free and1
means the app is a paid version."app.keywords"
,"games"
: The path to the App object’s keywords field, which provides a comma-delimited list of keywords for the app.
setAdvertiserID
Click to expand section
Set the user’s advertising ID and whether or not the user has requested for ad tracking to be limited.
Parameters
Parameter | Description | Required? |
---|---|---|
ifa | String value of the OS’s advertising ID. | Yes |
lmt | Boolean noting whether or not limit ad tracking is enabled. | Yes |
Example
OX_12345.setAdvertisingID("43043FE3-6BA9-4515-8209-6E0AC6AE1ADF", false);
addPage
Click to expand section
This method is similar to the addAdUnit
method, but instead of queuing a request for a single ad unit, it queues a request for all of the ad units referenced by the predefined ad unit group via its pgid
(page ID) value.
The addPage
method tells the OpenX JavaScript tag library to fetch ads for all of the ad units in the specified ad unit group when the fetchAds
(for synchronous tags) or load
method (for asynchronous tags) is called.
You can call addAdUnit
multiple times to fetch ads for multiple ad units for a given pgid
.
This method does not actually fetch ads, it queues a pgid
to fetch ads for when fetchAds
or load
is finally called.
Parameters
Parameter | Description | Required? |
---|---|---|
pgid | The ID for the predefined ad unit group that you want to request ads for. | Yes |
Example
OX_12345.addPage("123");
Where 123
is the pgid
for the predefined ad unit group that you want to request ads for.
addVariable
Click to expand section
Use this method to add a custom variable to the ad requests that come from the OX object instance. You must pass this method before the fetchAds
method.
Parameters
Parameter | Description | Required? |
---|---|---|
key , value | The custom variable KVP. | Yes |
Setting custom variables
A request to set a custom variable for the user’s gender might look like the following:
OX_12345.addVariable("gender","male");
Where gender
is the custom key and male
is the custom value.
addVariable in standalone tags
A standalone synchronous JavaScript ad tag with the addVariable
method might look like the following:
<script type="text/javascript"
src="http://delivery_server_domain/w/1.0/jstag">
</script>
<script>
var OX_4d6552943f5a4 = OX();
OX_4d6552943f5a4.addAdUnit("54321");
OX_4d6552943f5a4.addVariable("gender", "male");
OX_4d6552943f5a4.fetchAds();
</script>
<script type="text/javascript">
OX_4d6552943f5a4.showAdUnit("54321");
</script>
Where:
src="http://delivery_server_domain/w/1.0/jstag
: A request to fetch the OpenX JavaScript tag library.var OX_4d6552943f5a4 = OX();
: Create a new OX object and assign it to a global variable with a pseudo-random name..>OX_string
: A variable, which is included in some tags by the OpenX tag generator. You should replace this string with an identifier of your choosing.OX_4d6552943f5a4.addVariable("gender","male");
: TheaddVariable
method specifying a custom KVP.OX_4d6552943f5a4.fetchAds();
: ThefetchAds
method, which must be passed afteraddVariable
.OX_4d6552943f5a4.showAdUnit("54321");
: TheshowAdUnit
method, which shows the ads returned to thefetchAds
method.
Setting multiple custom variables
You can set custom variables for an ad unit group request or a multi-ad unit request ad tag. To do this, repeat the addVariable
method for each custom variable you want to set for the request. For example, to set custom variables for an ad unit group request ad tag (in this case, gender, age, and keyword), your request might look like the following:
...
OX_random_string.addVariable("gender","f");
OX_variable_string.addVariable("age","40");
OX_variable_string.addVariable("keyword","coupon");
...
Ad unit group requests
The header portion of an ad unit group request (using the addPage
method) ad tag might look like the following:
<script type="text/javascript"
src="http://delivery_server_domain/w/1.0/jstag">
</script>
<script type="text/javascript">
var OX_12345 = OX();
OX_string.addPage("3");
OX_string.addVariable("gender","f");
OX_string.addVariable("age","40");
OX_string.addVariable("keyword","coupon");
OX_string.fetchAds();
</script>
Multi-ad unit requests
A multi-ad unit request ad tag might look like the following:
<script src="http://delivery_server_domain/w/1.0/jstag">
</script>
<script>
var OX_12345 = OX();
OX_string.addAdUnit("54321");
OX_string.addAdUnit("98765");
OX_string.addVariable("gender","f");
OX_string.addVariable("age","40");
OX_string.addVariable("keyword","coupon");
OX_string.fetchAds();
</script>
Multiple values for the same custom variable
You can use this format to set multiple values for the same custom variable:
OX_string.addVariable("keyword","coupon,discount,rebate");
disableMarket
Click to expand section
Use this method to disable market (OpenX Ad Exchange) for the ad request. This allows you to opt out of the Ad Exchange on a per-impression basis.
Example
OX_string.disableMarket();
disableSegmentation
Click to expand section
Use this method to disable audience segmentation for the ad request. This method sets the ns
parameter of the requestAd
method.
Example
OX_string.disableSegmentation();
enableMarket
Click to expand section
Use this method to enable market (OpenX Ad Exchange) for the ad request.
Example
OX_string.enableMarket();
enableSegmentation
Click to expand section
Use this method to enable audience segmentation for the ad request. This method sets the ns
parameter of the requestAd
method to null
.
Example
OX_string.enableSegmentation();
fetchAds
Click to expand section
For synchronous JavaScript ad tags, use the this method to invoke an ad request to OpenX using all inputs from other methods. The ads returned from OpenX are not immediately displayed, but are stored by the OpenX JavaScript tag library for display later.
Example
OX_string.fetchAds();
frameCreatives
Click to expand section
Use this method to enable framing (true
) or disable it (false
) for all creatives of an OX object instance. If not set, it defaults to that set for the instance.
If set at both the page and instance levels, the OpenX JavaScript tag library uses the instance setting. This affects all ad units associated with the instance.
These settings are overridden by features that automatically add iframes, such as auto-refresh.
Example
OX_string.frameCreatives(true);
load
Click to expand section
For asynchronous ad tags, use this method to invoke and ad request to OpenX and to display the selected ads using all of the inputs set via other methods.
Call this method after all of the placeholder elements have loaded for the webpage. That is, the script block that contains this call cannot go in <head>
.
Example
OX_string.load();
setAdUnitFallback
Click to expand section
Use this method to set a fallback ad to serve for a specific ad unit, when OpenX has no ad to serve for an ad request.
For synchronous calls, you must call this method before showAdUnit
. Otherwise, it will not work.
NOTE
Macro expansion is not supported in third-party fallback tags set in the ad tag.
Parameters
Parameter | Description | Required? |
---|---|---|
auid | The ad unit ID for the ad to be displayed | Yes |
fallback | The HTML content to serve if the ad request returns an empty ad. | Yes |
Example
OX_string.setAdUnitFallback("999999","<iframe src='http://www.mywebsite.com'></iframe>");
setAdUnitImpBeacon
Click to expand section
Use this method to set a third-party impression beacon for the ad request. The third-party impression beacon is only triggered when OpenX delivers an actual ad (that is, not a fallback ad).
You cannot pass undefined as a value for the imp_beacon parameter for this method, so you cannot remove a third-party impression beacon after it is set.
For synchronous calls, you must call this method before showAdUnit
. Otherwise, it will not work. Furthermore, macro expansion is not supported in third-party impression beacons set in the ad tag.
Parameters
Parameter | Description | Required? |
---|---|---|
auid | The ad unit ID for the ad to be displayed. | Yes |
imp_beacon | The third-party impression beacon to set in the ad request. | Yes |
Example
OX_string.setAdUnitImpBeacon( "12345","<iframe src='example.com'></iframe>");
setAdUnitMarketFloor
Click to expand section
Use this method to set the aumf
parameter of the ad request, which is a combination of the ad unit ID (auid
) and the floor price. The aumf
parameter can also be set via the ad request initialization object.
setAdUnitMarketFloor(auid, floor)
Parameters
Parameter | Description | Required? |
---|---|---|
auid | The auid (ad unit ID) to set. | Yes |
floor | The market floor to set. This parameter must be set as a micro dollar (micro). CPM micros is $1.00 = 1,000,000 CPI micros is $1.00 = 1,000 Examples 1000 : Sets the ad unit market floor to 1000 micros ($1.00 CPM).1589 : Sets the ad unit market floor to 1589 micros ($1.589 CPM). Up to 3 decimal points can be leveraged.Note: The floor price must be in whole numbers (not floating point). | Yes |
Example
The following example sets the ad unit market floor for ad unit 538156269
to 1000
micros ($1.00 CPM).
OX_string.setAdUnitMarketFloor(538156269, 1000);
setAdUnitNGFloor
Click to expand section
Use this method to set the floor for non-guaranteed line items for a specific ad unit. This method sets the aungf
parameter of the ad request. When set, it filters out all other market floors as well as any non-guaranteed line items that do not meet this floor.
setAdUnitNGFloor(auid, floor)
Parameters
Parameter | Description | Required? |
---|---|---|
auid | The auid (ad unit ID) to set. | Yes |
floor | The line item floor to set. This parameter must be set as a micro dollar (micro). CPM micros is $1.00 = 1,000,000 CPI micros is $1.00 = 1,000 Examples 1000 : Sets the ad unit non-guaranteed line item floor to 1000 micros ($1.00 CPM).1589 : Sets the ad unit non-guaranteed line item floor to 1589 micros ($1.589 CPM). Up to 3 decimal points can be leveraged.Note: The floor price must be in whole numbers (not floating point). | Yes |
Example
The following example sets the ad unit non-guaranteed line floor for ad unit 538759143
to 12000
micros ($12.00 CPM).
OX_string.setAdUnitNGFloor(538759143, 12000);
Use this method to set the non-guaranteed market floor for a specific ad unit. This method sets the aungf
parameter of the ad request.
OX_string.setAdUnitNGFloor();
setAdUnitSlotId
Click to expand section
For asynchronous ad tags, use this method to associate the ID for the placeholder element (<div>
) with the ad unit.
Parameters
Parameter | Description | Required? |
---|---|---|
auid | ID for the ad unit where you want to display an ad. | Yes |
slot_id | ID for the placeholder element defined for the ad tag. | Yes |
Example
OX_string.setAdUnitSlotId("98765","exampleAd1");
setAnchorTarget
Click to expand section
Use this method to set the desired browser window target for ad clicks in the page.
Parameters
Parameter | Description | Required? |
---|---|---|
target | The browser window target when a user clicks an ad on the webpage. This can be one of the following: • _blank : New window• _parent : Parent window• _self : Current window• _top : Top window | Yes |
Example
OX_string.setAnchorTarget("_blank");
setAPIFrameworks
Click to expand section
Set the API frameworks supported by a mobile app, such as MRAID 2.0. This method supports an array of parameters representing the supported API frameworks.
Parameters
If you use this method, you must specify at least one of its supported parameters.
Parameter | Description | Required? |
---|---|---|
2 | VPAID 2.0 (video player-ad interface definitions) | No |
3 | MRAID 1.0 (mobile rich-media ad interface definitions) | No |
4 | ORMMA (open rich media mobile advertising) | No |
5 | MRAID 2.0 | No |
6 | MRAID 3.0 | No |
7 | OMID-1 (OpenMeasurement Interface Definition) | No |
Examples
Setting the API frameworks supported by mobile app:
OX_string.setAPIFrameworks([3,5]);
Alternatively, you can use the following standalone JavaScript ad tag to set the af
(API frameworks) parameter:
OX.requestAd({
"auid":"12345",
"af":[3,5]
});
setAppBundleID
Click to expand section
Set the bundle (“package”) ID of the mobile app in which the tag is running.
Parameters
Parameter | Description | Required? |
---|---|---|
appBundleID | The ID of the app’s bundle. | Yes |
Examples
Setting mobile app bundle IDs:
OX_12345.setBundleID("com.openx.openxdemo");
Alternatively, you can use the following standalone JavaScript ad tag to set the appBundle
parameter:
OX.requestAd({
"auid":"12345",
"appBundle":"com.openx.openxdemo"
});
setAppName
Click to expand section
Set the name of the mobile app in which the tag is running.
Parameters
Parameter | Description | Required? |
---|---|---|
appName | The name of the mobile app. | Yes |
Examples
Setting mobile app names:
OX_string.setAppName("OpenX Demo");
Alternatively, you can use a standalone requestAd
JavaScript ad tag to set the appName
parameter:
OX.requestAd({
"auid":"12345",
"appName":"OpenX Demo"
});
setAppStoreURL
Click to expand section
Set the app store URL from which the mobile app can be downloaded.
Parameters
Parameter | Description | Required? |
---|---|---|
appStoreURL | The app store URL for the app. | No |
Examples
Setting the app store URL for mobile apps:
OX_string.setAppStoreURL("http://itunes.apple.com/us/app/bee-leader/id580743157?mt=8");
Alternatively, you can use the following standalone JavaScript ad tag to set the appStoreURL
parameter:
OX.requestAd({
"auid":"12345",
"appStoreURL":"http://itunes.apple.com/us/app/bee-leader/id580743157?mt=8"
});
setClickRedirectURL
Click to expand section
Use this method to set the click redirect URL for an ad request. This method sets the r
parameter of the ad request (which represents the click redirect URL).
Example
OX_string.setClickRedirectURL();
setCoords
Click to expand section
Set the geolocation for the ad request. This method is useful for mobile web or mobile apps, where the publisher may have access to accurate GPS location data.
Parameters
Parameter | Description | Required? |
---|---|---|
coords | A geolocation coordinates object, which provides latitude , longitude , and (optionally) other properties. | No |
Examples
Setting geolocation for ad requests:
OX_string.setCoords({
"latitude":"34.1496085",
"longitude":"-118.1330328"
});
Alternatively, you can use the following standalone JavaScript ad tag to set the coords (API frameworks) parameter:
OX.requestAd({
"auid":"12345",
"coords":{
"latitude":"34.1496085",
"longitude":"-118.1330328"
}
});
setGateway
Click to expand section
Use this method to set the base URL of the delivery gateway to use for this ad request. The OpenX JavaScript tag library will append the appropriate strings to this URL that are necessary to call the gateway. Typically, you do not have to call this method because the ad tags generated by the system will provide this configuration.
Parameters
Parameter | Description | Required? |
---|---|---|
url | Base URL for the OpenX web ad gateway (delivery server). | Yes |
Example
OX_string.setGateway("http://delivery_server_domain/w/1.0/");
Where:
string
: A random string.http
: The protocol. If your ad space uses SSL/TLS, use https instead.delivery_server_domain
: The hostname of your OpenX delivery server./w
: Indicates the web delivery medium./1.0
: Indicates version 1.0 of the OpenX JavaScript tag protocol.
setOpenRTBParameters
Click to expand section
This method specifies OpenRTB-compliant data passed to Ad Exchange buyers via the ad request. Depending on your use case, you can specify the data in a JavaScript object literal or as a JSON string. You must pass this method before the fetchAds
and load
methods.
Parameters
Parameter | Description | Required? |
---|---|---|
openrtb | An object literal or JSON string representing an OpenRTB bid request | Yes |
Examples
setOpenRTBParameter
object literal:
OX_string.setOpenRTBParameters({
auid: "12345",
openrtb: {
imp: [
{ banner:
{ w: 320, h: 50 } }
],
app: {
ver: "1.0",
paid: 0,
keywords: "games",
}
}
});
Where:
string
: A random string of your choosing.auid
: The ad unit ID for the ad to be displayed.openrtb
: Indicates OpenRTB parameters.imp
: Corresponds to the OpenRTB Imp object.banner
: Corresponds to the OpenRTB Banner object.{ w: 320, h: 50 }
: Specifies the width and height of the ad unit in pixels.app
: Corresponds to the OpenRTB App object.ver: "1.0"
: The version string of the mobile app.paid: 0
: The App object’spaid
field, where0
means the app is free and1
means the app is a paid version.keywords: "games"
: The App object’skeywords
field, which provides a comma-delimited list of keywords for the app.
setOpenRTBParameters JSON string
This string corresponds to the object literal above.
OX_12345.setOpenRTBParameters('{"auid":"12345","openrtb":{"imp":[{"banner":{"w":320,"h":50}}],"app":
{"ver":"1.0","paid":0,"keywords":"games"}}}');
OpenRTB parameters in a standalone tag
Alternatively, you can use the requestAd
method to send OpenRTB parameters to Ad Exchange buyers.
Object literal:
OX.requestAd({
auid: "12345",
openrtb: {
imp: [
{ banner:
{ w: 320, h: 50 } }
],
app: {
ver: "1.0",
paid: 0,
keywords: "games",
}
}
});
JSON string:
OX.requestAd({
auid: "12345",
openrtb: '{"auid":"12345","openrtb":{"imp":[{"banner":{"w":320,"h":50}}],"app":{"ver":"1.0","paid":0,"keywords":"games"}}}'
});
setRefererURL
Click to expand section
Use this method to indicate the referring URL of the page (HTTP referrer) if it is not normally detectable using JavaScript. In most cases, the OpenX JavaScript tag library detects the referring URL. However, you can call setRefererURL
directly as necessary or use it as an override.
Parameters
Parameter | Description | Required? |
---|---|---|
url | The referring URL of the page. | Yes |
Example
OX_string.setRefererURL("http://www.example.com?q=abc");
setRefreshDelay
Click to expand section
Set the interval (in seconds) at which to refresh ads.
This value must be an integer ≥ 1. If you explicitly pass this parameter in an ad tag, OpenX ignores any server-side refresh delay setting for this ad unit, as set when creating or editing the ad unit or its container site. This affects all ad units associated with the instance.
Parameters
Parameter | Description | Required? |
---|---|---|
rd | The refresh delay, in seconds (integer ≥ 1). | Yes |
Example
OX_string.setRefreshDelay(60);
setRefreshMax
Click to expand section
Use this method to set the maximum number of refreshes for ads displayed through the ad tag. This must be a positive integer. For example, setting this parameter to a value of 5
results in the display of a total of 6 ads, including the initial display (non-refresh) and 5 subsequent displays (refreshes).
If you explicitly pass this parameter in an ad tag, OpenX ignores any server-side refresh max setting for this ad unit, as set when creating or editing the ad unit or its container site. This affects all ad units associated with the instance.
Parameters
Parameter | Description | Required? |
---|---|---|
rm | The maximum number of refreshes (integer ≥ 1) | Yes |
Example
OX_string.setRefreshMax(5)
setUserID
Click to expand section
You may use this method to set a specific user ID for the request after reviewing your ID management strategy with OpenX.
Parameters
Parameter | Description | Required? |
---|---|---|
xid | The user ID to set in the request. | Yes |
Example
OX_string.setUserID("ABC");
showAdUnit
Click to expand section
Use this method to show the ads returned to the fetchAds
method. If you place an anchor tag in the correct location in your webpage and call showAdUnit
, the ad rendering is initiated using document.write()
to write the ad content into the browser document object model (DOM).
You must call this method after fetchAds
. Otherwise, it will not work.
Parameters
Parameter | Description | Required? |
---|---|---|
auid | The ad unit ID for the ad to be displayed. | Yes |
Example
OX_string.showAdUnit("12345");