Use Ad Exchange and AdSense line items

You can create line items for your AdSense or Ad Exchange ads and target them to specific inventory units and audiences just as you would any other line item in DoubleClick for Publishers.

After you link your DoubleClick for Publishers account to your AdSense or Ad Exchange account, you’ll see a list of ad units created in those products, filtered by size, when you create a new AdSense or Ad Exchange creative in DoubleClick for Publishers. You need only select the ad unit to link it to the creative. You also have the option to copy, paste and edit code snippet from the ad unit if you want to override certain elements, such as size.

Create AdSense or Ad Exchange line items

  1. Link your AdSense or Ad Exchange products to your DoubleClick for Publishers account.
  2. Create an AdSense or Ad Exchange line item and set its targeting criteria.

    If your DFP ad unit has multiple sizes, create one line item containing multiple creatives, one per desired size.

    For example, if a publisher has an ad unit that supports 300x250 and 300x600, and wants to make that inventory available to Ad Exchange, the publisher should target that ad unit with a single Ad Exchange line item that contains both creative sizes.

  3. Click Add creatives and select new creative.

    If you're creating an Ad Exchange line item, you can click Automatically generate creative in the "Creatives" section to bypass this step.

    If you have multiple AdSense or Ad Exchange accounts associated with your DFP network, you can't change the AdSense or Ad Exchange account linked to the line item after a creative has been assigned to the line item (even if the creative is later removed from the line item). You need to create a new line item if you wish to associate a different AdSense or Ad Exchange account with the line item.

    Once you add creatives, you cannot change the priority type for Ad Exchange or AdSense line items.

  4. Click Select dynamic allocation ad unit by name. Click or begin typing to see a list of available AdSense or Ad Exchange ad unit or tags that match the size(s) of the line item.
  5. Select the AdSense or Ad Exchange ad unit or tag to which you want to target the line item.

    If you’re working with an AdSense property, you can select Import dynamic allocation ad unit code snippet and paste the code snippet from your AdSense account into the "Code snippet" box. This is also useful if you require other ad attributes, such as background, border or text color, or if you want to edit creative size.

    See an example of an AdSense code snippet
    <script type="text/javascript"><!--
    google_ad_client = "ADSENSE_PUBLISHER_ID";
    google_ad_slot = "AD_SLOT_NUMBER";
    google_ad_width = WIDTH;
    google_ad_height = HEIGHT;
    <script type="text/javascript" src="">
    <noscript> <img height=1 width=1 border=0 src=""/>

    google_ad_slot is optional for publishers that have Ad Exchange Rules enabled.
    google_ad_client acts as an override if specified; default is read from the line item.
    google_ad_width and google_ad_slot act as overrides if specified; defaults are read from the creative (required) or the line item creative association (if specifically overridden there).

    You can also add the following optional attributes to the line after google_ad_height = HEIGHT;:

    google_ad_border = 
    google_ad_bg = 
    google_ad_link = 
    google_ad_text = 
    google_ad_url  = 

    When you paste a code snippet into the “Code snippet” box, DFP extracts the parameters detailed above and ignores everything else at the time of ad serving. This means any additional code, such as click-tracking macros, are also ignored.

    Even if the same creative always displays when you preview the line item in DoubleClick for Publishers, please note that when the line item delivers on the actual website it might display a different creative. This is because AdSense uses contextual targeting, which means that it uses the actual webpage content to determine which creative to serve.

    If you see an error: "Web property in snippet does not match web property in line item", when saving your AdSense or Ad Exchange line item, the web property ID included in the ad unit code snippet you pasted into the creative window does not match the account associated with your DFP account. If you have multiple AdSense or Ad Exchange accounts, make sure you're copying the ad unit code from the one associated with your DFP account.

  6. Enter a Name for the creative.
  7. Click Save.
  8. (Optional) Review individual Ad Exchange ads and choose whether to let them show on your pages.
  9. Report on your AdSense or Ad Exchange line items.
If you have multiple AdSense or Ad Exchange line items that have the same priority level, you should ensure that they have different targeting criteria to become eligible to compete.

If you pick the exact same targeting criteria and priority level for all of them, DFP will pick one at random to compete, which may not earn you the most money. Higher priority line items will be selected over lower priority line items.

Inventory-level versus line item-level dynamic allocation

All DoubleClick for Publishers Small Business users can use dynamic allocation at the inventory level. For those also eligible to use dynamic allocation at the line item level (via Ad Exchange or AdSense line items), this article explains how to decide which one you should use. If you are not enabled for dynamic allocation line items but would like to be, please contact your account manager.

While you can employ both, we recommend that you use only one type actively, as it will make it easier to manage your dynamic allocation revenue. See below for information on the two types, and how they interact.

Inventory-level dynamic allocation

Dynamic allocation at the inventory level is the simplest way to allow AdSense to dynamically compete for remnant impressions. (There is no way for Ad Exchange to compete via inventory-level dynamic allocation.) You can quickly set inventory-level dynamic allocation for each ad unit, and enable it for all ad units by default. Learn more

Before serving an ad to an AdSense ad unit, DoubleClick for Publishers checks with AdSense inventory to see if it can get more for an impression than is offered by any of its booked network, bulk, or price priority line items. This method is easy to manage and implement, but affords less control than line item-level dynamic allocation. Learn about the benefits.

Line item-level dynamic allocation

Line item-level dynamic allocation affords granular control over when remnant inventory is served to your network, and each dynamic allocation line item can be linked to an existing Ad Exchange accounts in addition to your AdSense accounts. You can set multiple ad sizes per line item, and also target the line item to most of the standard criteria, such as geography, keywords, etc. Learn about Ad Exchange or AdSense line items.

How inventory-level and line item-level dynamic allocation interact

We recommend that you not employ both inventory-level and line item-level dynamic allocation for your DoubleClick for Publishers network. If you employ both, there may be an overlap in which a dynamic allocation line item competes for an AdSense-enabled ad unit. In this case, the dynamic allocation line item will override the AdSense-enabled ad unit.

If a dynamic allocation line item competes for a given ad call, DFP doesn't run a price competition at the ad unit level--even if the dynamic allocation line item does not win the competition.

Frequently-asked questions

How are AdSense or Ad Exchange line items picked for delivery?

AdSense and Ad Exchange line items can compete with all line items other than sponsorships. (Learn more about dynamic allocation.)

If two AdSense or Ad Exchange line items of equal numerical priority are eligible to serve to an impression, then DFP chooses one at random.

DoubleClick for Publishers then sends the selected line item to AdSense or Ad Exchange, which evaluates the line item against its inventory. If AdSense or Ad Exchange has an ad with a price that is greater than or equal to the price of the line item picked by DoubleClick for Publishers, then the AdSense or Ad Exchange line item will deliver. If the line item from DoubleClick for Publishers has the higher price, then that line item will deliver. Remember that enhanced dynamic allocation calculates a temporary CPM value for each line item, rather than using the user-entered value from DFP.

Can I check available inventory for AdSense or Ad Exchange line items?

Since AdSense and Ad Exchange line items are non-guaranteed inventory, you can’t forecast their inventory.

However, for Ad Exchange line items, you can predict the number of queries that will be available. Learn how to forecast queries for an Ad Exchange line item.

Do I have to add AdSense or Ad Exchange tags to my website?

No. Once you traffic AdSense and Ad Exchange line items in DoubleClick for Publishers, the AdSense or Ad Exchange line items can be delivered through DoubleClick for Publisher tags. There is no need to put AdSense or Ad Exchange tags directly onto your website.

How is web page layout affected?

AdSense and Ad Exchange line items delivered through DoubleClick for Publishers aren't aware of other AdSense or Ad Exchange line items on your webpage. The function that AdSense and Ad Exchange use to lay out a full page, and to prevent duplicate delivery of a single ad, is disabled by the AdSense and Ad Exchange in DoubleClick for Publishers feature.

How do I serve an AdSense ad inside an iframe?

When an ad, such as one for AdSense or the Ad Exchange, is served inside a nested iframe, browser security features prevent the ad from detecting the page URL or domain to use for targeting. As a result, the most relevant ad is not served and ad revenue is lower than it could be.

See Detect a page URL or domain in iframes to learn how to prevent this problem.

Upgraded from DFP Small Business? You might also have inventory-level dynamic allocation.

If you've upgraded from a DoubleClick for Publishers Small Business account, then you might also be using inventory-level dynamic allocation. Learn about dynamic allocation in our Small Business help center, and understand how inventory-level and line-item level dynamic allocation can interact.

Can I traffic an Ad Exchange snippet in a Price Priority line item?

This is not recommended. There are a few considerations to keep in mind:

  • When your Ad Exchange Price Priority line item competes with Ad Exchange in dynamic allocation, sophisticated buyers can detect the unusual configuration and might bid lower or not bid at all. 
  • If your Ad Exchange Price Priority line item can't win the impression, a manual passback solution to DFP is required. This involves complicated, unreliable configurations that lead to latency and confusion in reporting. 
  • Information passed by DFP through Ad Exchange line items to improve ad serving and reporting is lost.
Was this article helpful?
How can we improve it?