Examples of JavaScript, iframe, and image DART ad tags

The following code examples include the various attributes that you use to create JavaScript, iframe, and image DART ad tags. The attributes that you use to construct your ad tags determine which ads are targeted to your website.

For information about Google Publisher Tags (GPT), see the Google Publisher Tag Help Center topic.

Guidelines and limitations

  • Ad tags and their individual components are not case-sensitive.

  • As a best practice, we recommend putting the ord key-value at the end of your ad tags; this value will help you defeat browser caching.

  • The maximum length of a URL in an ad request is 2,000 characters; any additional characters will be truncated.

Please note that dynamically serving creatives into HTML email or newsletters is not supported by DoubleClick.

Determine which tag to use

Use the following table to determine when to use a standard image, JavaScript, or iframe DART ad tag.

DART ad tag type Creative types served Multiple sizes in same ad unit Browser support Restricts ad to a frame Page load issues Loads ad before rest of page Ad elements in same domain as site
GIF (static or animated), JPG Redirects Rich or entertaining content (Flash, third-party, custom) Expandable/ floating
Standard image tag Yes Yes No No No All No No Yes Yes
JavaScript Yes Yes Yes Yes Yes All No Yes Yes Yes
Iframe Yes Yes Yes No No Renders differently depending on the browser Yes, unless you implement an iframe buster Yes Can isolate ad from rest of page No
Definitions of standard DART ad tag attributes


a href

An HTML anchor element and hyperlink target attribute; this tag is a hypertext link to DFP.

img src

An HTML image element and source attribute; defines the location of a graphic file and requests a creative from DFP.


The generic address of the ad server; ad.doubleclick.net, is the address used for ads served from U.S. data centers. A data center is a collection of ad servers in one location.


Indicates the code for the DFP network in which this ad is booked. The network code can be found in the Admin tab of your DFP network. Ex: N1234.

For networks that upgraded from DART: All ads that you trafficked in DART will continue to serve to your current tags. Any new line items that are trafficked to sites or zones that you created in DART will continue to serve to those tags.

However, if you are generating ad tags for ad units that were created in DFP after you upgraded, those ad tags must have the network code in them.


A command, passed to the ad servers, that is used for counting clicks. This command is substituted dynamically with the click-through URL of the creative.


Indicates the type of creatives that an ad tag can serve.

The code:

Indicates an ad tag:


Can only accept image creatives.


Can accept Flash, rich content, or image creatives in a frame.


Can accept Flash, rich content, or image creatives in a layer.


Can accept Flash, rich content, or image creatives in an iframe.


Can accept Flash, rich content, or image creatives and will serve them by JavaScript.


Can accept Flash, rich content, or image creatives and will serve them using streaming technologies.


The code of a first level ad unit in your DFP network. For information about ad units, see Define and build your website's inventory.


The code of a second level ad unit in your DFP network. For information about ad units, see Define and build your website's inventory. Note that every tag must have a first-level ad unit, but including a second-level ad unit is optional.


A more granular way of defining your inventory than ad units. For more information about key-values, refer to Define key-values.


Indicates the dimensions of an ad slot (in pixels). You must always include the sz=widthxheight value in your ad tags. There’s no limit on the number of creative sizes that you can include. Dimensions are separated by commas (,).

For example: sz=468x60,728x90,100x100,120x600


A tile value is used to specify the order of an ad slot on a webpage. Without tile values properly implemented, you may find that roadblocks (creatives that are supposed to serve together) don’t always serve together, or that competitive exclusion doesn’t work properly. Tile values can also help prevent duplicate creatives from serving on the same page.

The top tag on the page should have tile=1 and the tags beneath should have tile=2, tile=3 and so on in descending order. Tile values are included in the ad tags of your website to enable DART to distinguish ad slots in the same webpage. Tile values range from 1-16, meaning that you cannot have more than 16 ad tags on a page.


The ord value is used for cache-busting; to ensure that a fresh call is made to the ad server every time a page loads. Without the ord value properly implemented, you may experience impression counting discrepancies.

You’ll need to add the ord value to the ad tags as per the examples above, and you’ll also need to have a piece of code in the top ad tag that generates a random number to populate the ord value on every tag. Make sure that you do not have more than one random number generator on the page. In the examples above, the random number generator is var ord = Number(ord) || Math.floor(Math.random()*10e12);

About image ad tags

Image ad tags serve standard images such as GIFs (static or animated) and JPGs, as well as standard images hosted on DoubleClick servers trafficked as "DoubleClick tags" or hosted by a third party trafficked as "Third party" creatives. Image tags require minimal coding, but they render only a single image. They can’t serve rich content of any kind, such as Flash, and they can't trigger third-party impression trackers.

If you want to serve both images and Flash or other types of rich content creatives, you must use the "Flash" or "Third party" creative type along with a JavaScript adj or aid ad tag.
Example of an image ad tag

The following HTML code example includes the various attributes that you use to create image ad tags. The attributes that you use to construct your image ad tags determine which ads are targeted to your website.

<script type="text/javascript">
var ord = Number(ord) || Math.floor(Math.random()*10e12);
document.write('<a href="http://ad.doubleclick.net/Nnetwork_code/jump/first_level_ad_unit/second_level_ad_unit;pos=top;tile=tile_number;sz=widthxheight;ord=' + ord + '?" target="_blank" ><img="" src="http://ad.doubleclick.net/Nnetwork_code/ad/first_level_ad_unit/second_level_ad_unit;pos=top;tile=tile_number;sz=widthxheight;ord=' + ord + '?" ></a>');<="" br=""> </script>
<a href="http://ad.doubleclick.net/Nnetwork_code/jump/first_level_ad_unit/second_level_ad_unit;pos=top;tile=tile_number;sz=widthxheight;ord=1234567890?" target="_blank">
<img src="http://ad.doubleclick.net/Nnetwork_code/ad/first_level_ad_unit/second_level_ad_unit;pos=top;tile=tile_number;sz=widthxheight;ord=1234567890?" />
About JavaScript and iframe tags

JavaScript and iframe ad tags enable rich content creatives such as Flash and backup static images to be served to ad slots. The creative files for rich content ads are developed with advanced multimedia technologies such as scripts (for example, HTML, CGI, JavaScript, and Java), animation and video (such as Shockwave, Shockwave Flash, and RealVideo), or audio (such as RealAudio).

JavaScript and iframe ad tags are configured using JavaScript, frames, an iframe/layer-ilayer combination, or an iframe/JavaScript combination.

Example of a JavaScript ad tag
<script type="text/javascript">
  var ord = window.ord || Math.floor(Math.random() * 1e16);
  document.write('<script type="text/javascript" src="http://ad.doubleclick.net/Nnetworkcode/adj/first_level_ad_unit/second_level_ad_unit;sz=WidthxHeight;ord=' + ord + '?"><\/script>');
<a href="http://ad.doubleclick.net/Nnetwork_code/jump/first_level_ad_unit/second_level_ad_unit;pos=top;tile=tile_number;sz=widthxheight;ord=1234567890?" target="_blank">
<img src="http://ad.doubleclick.net/Nnetwork_code/ad/first_level_ad_unit/second_level_ad_unit;pos=top;tile=tile_number;sz=widthxheight;ord=1234567890?" />
Example of an iframe ad tag
<script type="text/javascript">
var ord = Number(ord) || Math.floor(Math.random()*10e12);
document.write('<iframe src="http://ad.doubleclick.net/Nnetwork_code/adi/first_level_ad_unit/second_level_ad_unit;key=value;tile=tile_number;sz=widthxheight;ord=' + ord + '?" width="specified_width" height="specified_height" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>');
<a href="http://ad.doubleclick.net/Nnetwork_code/jump/first_level_ad_unit/second_level_ad_unit;key=value;tile=tile_number;sz=widthxheight;ord=1234567890?" target="_blank">
<img src="http://ad.doubleclick.net/Nnetwork_code/ad/first_level_ad_unit/second_level_ad_unit;key=value;tile=tile_number;sz=widthxheight;ord=1234567890?" />
Was this article helpful?