You are here: Developers > Ad Request API > Iframe ad tags

Iframe ad tags

Last updated on March 21, 2017

An <iframe> 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. represents an inline frame within your webpage allowing you to position ads on the window without impacting the rest of the page layout.

This page covers the following topics:

How iframe ad tags work

When a user browses to a webpage where you have implemented an OpenX iframe ad tag:

  1. The browser invokes an ad requestCommunication from a web browser or app to an ad server to display an ad. for the ad unitThe smallest inventory component that represents the space on a site where ads display. referenced in the URL for the src attribute of the iframe tag.

  2. OpenX receives the request, performs the ad selection, and returns an HTML document with the embedded ad content.

  3. The browser renders the ad in the appropriate ad space.

  4. If the user's browser does not support iframes, it can use an image tag instead. For iframe ad tags that you generate through the OpenX UI, an optional image tag fallback mechanism is provided by default. You can include other tag types between the iframe tags (<iframe>fallback tag here</iframe>) and they will be ignored if the iframe is supported by the user's browser.

  5. Iframe ad tags employ a client-side counting mechanism: they log an 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. after the ad is rendered by the browser.

Benefits

Iframe ad tags have the following benefits:

  • Auto-refresh via ad request parameters.

  • Fallback tags can be included in case the user's browser does not support iframes.

  • Parallel execution, which minimizes page-load times.

  • You can hide source page information from downstream ad servers, such as the page and referring URLs.

  • Content styles are not influenced by the parent page CSS, so the ad in the iframe does not have to match the style of the rest of the page.

Limitations

Limitations associated with iframe tags include:

  • Each iframe tag is a standalone request for a single ad unit. They do not support ad unit groupA collection of ad units where related ads display together at the same time. or multi-ad unit requests. To fulfill multiple ad units on the same webpage, you can implement an iframe tag for each ad unit you want to serve.

  • Multiple ad units on a page using iframe tags cannot communicate with each other.

  • Iframe tags are not compatible with most contextual-analysis networks.

  • To display ads that expand outside the dimensions of an iframe window, you must implement an iframe-buster.

Structure

An iframe ad tag contains HTML tags and various parameters.

Sample iframe ad tag

<iframe id='a62ae7d3' name='a62ae7d3'
src='http://delivery_server_domain/w/1.0/afr?auid=
8635&cb=INSERT_RANDOM_NUMBER_HERE&rd=5&rm=3"
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?uid=8635&cs=acd22faf&cb=INSERT_RANDOM_NUMBER_HERE"
border='0' alt='' /></a></iframe>

This ad tag contains an ad request URL and a fallback mechanism. The parameter values that you select for the ad request URL and its fallback tags ultimately determine what ads are displayed for the ad unit.

Ad request URL

The ad request URL defines the iframe element, references the ad unit ID, and includes various ad request parameters.

<iframe id='a62ae7d3' name='a62ae7d3'
src='http://delivery_server_domain/w/1.0/afr?auid=8635&cb=INSERT_RANDOM_NUMBER_HERE&rd=5&rm=3'
frameborder='0' scrolling='no' width='728'
height='90'>

Where:

Fallback mechanism

The fallback mechanism is set such that, if the browser does not support iframes, OpenX uses an image ad tag to fulfill the request:

<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=8635&
cs=acd22faf&cb=INSERT_RANDOM_NUMBER_HERE' border='0' alt='' /></a>

Custom variables

You can also include custom variables in your iframe ad tags. For example, the URL for an iframe tag with custom variables for the user's gender, age, and keywords might look like the following:

http://d.example.com/w/1.0/ai?
auid=1234&cs=xyz&c.gender=m&c.age=40&c.keyword=coupons

How to implement an iframe ad tag

  1. Generate your iframe ad tag via the OpenX UI.

  2. Copy the iframe ad tag.

  3. Paste the ad tag in the website source code between the HTML body tags where you want the ad to display.

  4. Replace the value of the cb parameter with a random number (preferably a dynamically auto-generated number from your CMS) for cachebusting purposes.

Sample iframe ad tag implementation

<html>
<head></head>

<body>

Some content here.Ad goes here.

<!-- if the iframe doesn't work, serve an image tag. -->

<iframe id='a62ae7d3' name='a62ae7d3' 
src='http://delivery_server_domain/w/1.0/afr?auid=
8635&cb=INSERT_RANDOM_NUMBER_HERE&rd=5&rm=3"
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=8635&cs=
acd22faf&cb=INSERT_RANDOM_NUMBER_HERE"
border='0' alt='' /></a></iframe>

Some other content here.

</body>
</html>

Note: Replace the value of the cb parameter with a random number (preferably a dynamically auto-generated number from your CMS) for cachebusting purposes.

Feedback form