Google Publisher Tag (GPT) Basics for AdSense Publishers

Published · 8 min read

If you have only ever used AdSense, your ad code is probably one script in the page header and a few ad blocks, or just Auto ads doing the work. Google Ad Manager works differently. Instead of AdSense code, your pages use the Google Publisher Tag, usually called GPT. It is more flexible, it gives you more control, and it is the ad tag library Google provides for Ad Manager on websites. This guide explains what GPT does, how to generate Google Ad Manager tags, how passbacks work, why the script must come from Google, and how your tag choice affects billing.

AdSense code vs Ad Manager tags

The difference is mostly about who decides.

With AdSense code, AdSense makes most of the decisions. You place an ad unit or turn on Auto ads, and AdSense chooses the ads, sizes and styles.

With Ad Manager tags, you define the inventory and Ad Manager runs the decision. Your tag tells Ad Manager which ad unit is being requested, which sizes fit, and any targeting details. Ad Manager then picks the best ad from everything competing for that slot: Ad Exchange, AdSense, direct campaigns, other networks.

That does not mean AdSense disappears. Google says that once AdSense is set up in Ad Manager, AdSense line items can be delivered through your Google Publisher Tags, with no need for separate AdSense tags on your site. AdSense can also be enabled at network or ad unit level in Ad Manager, where it automatically selects ad styles. Our guide to AdSense backfill in Ad Manager covers how that works and why MCM setup asks you to switch it off before enabling AdX.

What GPT does (define slots, build requests, render)

Google describes GPT as an ad tag library that lets publishers define inventory, initiate and bundle ad requests, and render matching demand. In plain terms, GPT does three jobs:

  1. Define slots. It tells Ad Manager which ad units exist on the page, with their codes and sizes.
  2. Build and send requests. It takes the ad unit code, the ad size and any key-values, builds the request and sends it to the ad server.
  3. Render the ad. It receives the winning ad and displays it on the page.

Google lays out the sequence when a page with GPT loads:

  • The browser requests gpt.js, the JavaScript library, from Google.
  • The library builds and sends one or more ad requests for the slots on the page.
  • The ad server matches the ad units and key-values in the request.
  • The ad server runs an auction to pick the best matching creative.
  • The ad is returned to GPT, which renders it on the page.

Google also lists several benefits of GPT, including asynchronous loading (so the page renders without waiting for ads), multi-level inventory hierarchy, SafeFrame support to protect your page from untrustworthy creatives, responsive ads, and formats such as web interstitial, anchor and rewarded ads. GPT can also work with IAB consent management platforms to respect users' consent choices.

For how ad units, codes and key-values should be structured before you tag anything, see our guide to ad units and inventory structure.

Generating tags in Ad Manager

You do not need to write GPT code from scratch. Ad Manager generates it for you:

  1. Sign in to Google Ad Manager.
  2. Click Inventory, then Ad units.
  3. Click the name of the ad unit you want to tag.
  4. Select the Tags tab.
  5. Choose the tag type and click Continue.
  6. Make your selections and click Continue again.
  7. Copy the code from Tag results.

The tag types Google offers include the Google Publisher Tag for display ads, a mobile application tag, an AMP tag, Google Publisher Tag for video and audio, and Ad Exchange tags, which have their own generation process. For a normal website, you will mostly use the Google Publisher Tag.

One warning from Google: do not pick video sizes (such as "300x250v") when generating GPT tags, because the tool will then output tags meant for the IMA SDK, Google's video ads library, instead.

Your tags will contain your network code, a numeric identifier for your network that Google says is not confidential precisely because it appears in your tags. Under MCM, the tags depend on the delegation type. With Manage Account, the child uses its own Ad Manager tags. With Manage Inventory, the child uses the parent's tags with an identifier for the child account. If you work with a partner, use the tags they give you rather than mixing in older ones.

Single request and page-level targeting

Two options in the tag generator are worth understanding before you copy anything.

Single request architecture (SRA). Instead of sending a separate request for each ad unit, GPT can send one request telling the ad server about all the ad units on the page. Google calls this the recommended request mode, because it supports roadblocking (showing related ads together on one page) and improves page load time.

Page-level targeting. GPT lets you set shared settings, such as key-values, once for the whole page instead of repeating them on each ad slot. The tag generator has an option for page-level key-values that apply to all ad slots. For example, you could set a "section" key-value once and every ad on the page carries it.

Other options include collapsing empty divs, so slots that rarely fill do not leave blank space, and marking a tag for out-of-page creatives such as interstitials.

Passback and third-party tags

Sooner or later, you may work with an ad network or exchange outside Google. Two concepts come up.

Third-party tags in Ad Manager. Google says any third-party ad network or exchange that provides a suitable ad tag can be set up as a non-guaranteed line item in Ad Manager, competing on a price you enter. In that case, the other party's tag is the creative, and it runs inside Ad Manager's decision.

Passback tags. Google describes a passback tag as one to use in any situation where an ad request to a third party should ultimately be filled by an ad trafficked in your own network. In other words, if another network cannot fill a slot, a passback hands the impression back to Ad Manager so it can serve something else. You generate passback tags in the same Tags tab.

Under MCM there is a related setup: Google describes an option where a child books direct deals in its own account and reaches its parent's Ad Exchange through passback tags or video redirect tags. Your partner would set that up with you.

Keep passbacks simple. Long chains of networks passing impressions to each other add delay and make problems hard to trace. Google's Ad Manager Partner Guidelines also set a limit: once you have made an ad call for Google monetization of an impression, you may not pass that impression through any other system that allocates ad calls based on real-time pricing.

Why GPT must load from Google

Google is direct about this: the JavaScript files that implement GPT are served by Google, and you should not serve them from your own server or load them from an unofficial source.

People sometimes want to self-host scripts to speed up their site or to bundle everything into one file. With GPT, don't. Google updates the library, and a copied version can fall behind, break, or behave in ways Google did not intend.

This connects to a wider rule. Google's Ad Manager Partner Guidelines say ad code may not be altered, and the standard behavior, targeting or delivery of ads may not be manipulated in any way Google has not explicitly permitted. Use the code the tag generator gives you, change only the parts Google documents as configurable, and load gpt.js from Google every time.

How tag choice affects Ad Manager billing

The standard Ad Manager account is free up to monthly impression thresholds. Your choice of tag affects what counts toward them.

According to Google's billing page:

  • With Google Publisher Tag, Ad Manager bills both filled and unfilled impressions, including instances that use third-party ad serving.
  • With Ad Exchange tags, which can only serve Ad Exchange impressions, Ad Manager does not bill filled or unfilled impressions.
  • Impressions filtered as invalid traffic are never billed, whatever the tag.

In practice, this means slots that request ads but rarely fill still count when you use GPT. Tidy up ad units you no longer use and avoid requesting ads for slots that are never shown. Our guide to Ad Manager vs Ad Manager 360 lists the thresholds and explains what happens if you pass them.

Testing tags without clicking ads

After you place new tags, you will want to check they work. Do it without ever clicking your own ads.

Google is firm on this. Its advice on preventing invalid traffic says not to click your own ads, even if you think it is okay, and that if you want to check the ads appearing on your site, you can do it safely through the Ad review center. Invalid traffic covers clicks or impressions that artificially inflate advertiser costs or publisher earnings, whether intentional or accidental, and the publisher is ultimately responsible for it. Our guide to invalid traffic explains the risks.

Safe ways to test:

  • Use the Google Publisher Console. Google says GPT comes with this built-in debugging and support tool, available on every page that contains GPT. It shows which slots were requested and what came back.
  • Check across browsers and devices. Google's invalid traffic guidance recommends checking your implementation in different browsers and platforms to be sure it works as you expect.
  • Look at the page, not the ad. Confirm slots load, sizes fit, empty slots collapse and nothing covers your content or navigation.
  • Watch reports for a few days. Compare ad requests and impressions per ad unit. A slot with requests but no impressions often points to a tag or size problem.

Next step

Clean, correctly loaded GPT tags are part of being ready for AdX through MCM, along with approved sites and a good policy record. When your tags, ad units and account are in order, review the requirements to confirm the rest. If everything checks out, Get AdX access and request a review through our MCM partner network.

Frequently asked questions

Auto ads is an AdSense feature that runs from your AdSense code, not from Ad Manager tags. Inside Ad Manager, Google says AdSense line items can be delivered through your Google Publisher Tags, so you do not need separate AdSense tags for that demand. If you keep both on the same pages during a transition, check ad density and placement carefully.

Go to Inventory > Ad units, open the ad unit, and select the Tags tab. Choose the tag type, such as Google Publisher Tag, make your selections, and copy the code from Tag results.

Google describes a passback tag as one to use in any situation where an ad request to a third party should ultimately be filled by an ad trafficked in your own network. It hands the impression back to Ad Manager when the other party does not fill it.

No. Google says the JavaScript files that implement GPT are served by Google, and you should not serve them from your own server or load them from an unofficial source. Always load GPT from Google's official location.

Sources

  1. https://support.google.com/admanager/answer/181073?hl=en
  2. https://support.google.com/admanager/answer/177207?hl=en
  3. https://support.google.com/admanager/answer/7438540?hl=en
  4. https://support.google.com/admanager/answer/1670087?hl=en
  5. https://support.google.com/admanager/answer/6214526?hl=en
  6. https://support.google.com/admanager/answer/9059370?hl=en
  7. https://support.google.com/admanager/answer/7674889?hl=en
  8. https://support.google.com/admanager/answer/177279?hl=en
  9. https://support.google.com/admanager/answer/10751915?hl=en
  10. https://support.google.com/admanager/answer/11130475?hl=en
  11. https://support.google.com/adsense/answer/1112983?hl=en
  12. https://support.google.com/admanager/answer/12331294?hl=en

Related guides

Ready for AdX? Get access

Coming from AdSense? Set up your Ad Manager network, then apply with its code. Eligible publishers may receive an invitation from our MCM partner network, subject to Google's policies.

Get AdX access