Link Search Menu Expand Document

PDF

Implementing Standalone Ad Tags

Publishers

Last updated on January 16, 2019


Regardless of the standalone ad tag implementation that you use (that is, using static methods, using instance methods, or for tags running on another server), the way that you include the ad tag in your website source code is the same.

To implement a standalone ad tag:

  1. Generate your ad tag in the OpenX UI, via the OpenX API, or manually using the information in this help section.
  2. Copy the ad tag.
  3. Paste the ad tag in your website source code. You need to paste your ad tag between the HTML body tags, where you want the ad to display.

Requirements

The JavaScript request structure must:

  • Include the method and required parameters.
  • Contain only one method (send a separate request for each operation you want to perform).
  • Include the full case-sensitive method name using the following pattern: OBJECT_NAME.method_name.

    For example, to request an ad for an ad unit, call the addAdUnit method using the following format: OX_random_string.addAdUnit(auid)

To include an optional parameter for JavaScript tags to avoid potential namespace collisions, see Avoiding namespace collisions.


Implementation Examples

Click to expand the following examples:

Standalone synchronous JavaScript ad tag
<html>
<head></head>

      <body>

      Some content here

      Ad goes here

      <!-- Try a script tag.
      If that does not work, use an iframe tag.
      If that does not work, use an img tag. -->

      <script type="text/javascript">
      if (!window.OX_ads) OX_ads = [];
      OX_ads.push({"auid":"12345", "r":"INSERT_CLICK_URL_HERE"});
      </script>
      <script src="http://delivery_server_domain/w/1.0/jstag"></script>

      <noscript>
      <iframe id='a62bc7d3' name='a62bc7d3'
      src='http://delivery_server_domain/w/1.0/afr?auid=12345&cb=INSERT_RANDOM_NUMBER_HERE'
      frameborder='0' scrolling='no' width='728' height='90'>
      <a href='http://delivery_server_domain/w/1.0/rc?cs=acd22faf&cb=INSERT_RANDOM_NUMBER_HERE
      'target='_blank'>
      <img src='http://delivery_server_domain/w/1.0/ai?auid=12345&cs=acd22faf&cb=INSERT_RANDOM_NUMBER_HERE'
      border='0' alt='' />
      </a>
      </iframe>
      </noscript>

      Some content here

      </body>
  </html>
Standalone ad tag implementation using requestAd method
<html>
<head></head>

<body>

Some content here

Ad goes here

<!-- Fallback: first try a script tag.
If that does not work, use an iframe tag.
If that does not work, use an img tag. -->

<script type="text/javascript"
 src="http://delivery_server_domain/w/1.0/jstag"></script>

<script type="text/javascript">
OX.requestAd({"auid":"8"});
</script>

<noscript>
<iframe id="4cb4e94bd5bb6" name="4cb4e94bd5bb6"
 src="http://delivery_server_domain/w/1.0/afr?auid=8&target=_blank&cb=INSERT_RANDOM_NUMBER_HERE"
 frameborder="0" scrolling="no" width="728"
 height="90">
<a href="http://delivery_server_domain/w/1.0/rc?cs=4cb4e94bd5bb6&cb=INSERT_RANDOM_NUMBER_HERE"
 target="_blank">
<img
 src="http://delivery_server_domain/w/1.0/ai?auid=8&cs=4cb4e94bd5bb6&cb=INSERT_RANDOM_NUMBER_HERE"
 border="0" alt="">
</a>
</iframe>
</noscript>

Some content here

</body>
                </html>
Asynchronous JavaScript ad tag implementation
<html>
<head></head>

<body>

Some content here

Ad goes here

<!-- Preserve space while the rest of the page loads.
Set style attributes. -->

<div id="placeholderId" style="width:728px;height:90px">

<!-- Fallback mechanism to use if unable to load the script tag. -->

<noscript>
<iframe id="4cb4e94bd5bb6" name="4cb4e94bd5bb6"
 src="http://delivery_server_domain/w/1.0/afr?auid=8&target=_blank&cb=INSERT_RANDOM_NUMBER_HERE"
 frameborder="0" scrolling="no" width="728"
 height="90">
<a href="http://delivery_server_domain/w/1.0/rc?cs=4cb4e94bd5bb6&cb=INSERT_RANDOM_NUMBER_HERE"
 target="_blank">
<img src="http://delivery_server_domain/w/1.0/ai?auid=8&cs=4cb4e94bd5bb6&cb=INSERT_RANDOM_NUMBER_HERE"
 border="0" alt="">
</a>
</iframe>
</noscript>
</div>

<!--Async ad request with multiple parameters.
OX_ads is a global array to store ad request details.
OX_ads.push adds a new ad unit to the ad request queue.
-->

<script type="text/javascript">
var OX_ads = OX_ads || [];
OX_ads.push({
    "slot_id":"placeholderId",
    "auid":"8",
    "tid":"4",
      "tg":"_blank",
      "r":"http://redirect.clicks.to.here/landing.html",
      "rd":"120",
      "rm":"2",
      "imp_beacon":"HTML for client-side impression beacon",
      "fallback":"HTML for client-side fallback",
      "vars":{"key1":"value1","key2":"value2"}
    });
</script>

<!-- Fetch the OpenX JavaScript tag library -->

<script type="text/javascript" src="http://delivery_server_domain/w/1.0/jstag"></script>

Some content here

</body>
</html>