How to Serve Ads with Google Publisher Tags?

Updated on: January 9, 2024
Are you new to Google Publisher Tag (GPT)? Then, here's a primer. From what is GPT tag to how to set it up for success, learn everything here.

Google Ad Manager (formerly known as Google DFP) is one of the most reliable ad servers for publishers. This article aims to simplify one of its ad tag types, ‘Google Publisher Tag,’ which is an overhaul of how usual ad tags work. 

Before explaining what Google Publisher Tag is, let’s get a brief overview of the different types of ad tags available in Google Ad Manager. 

Google Ad Manager allows publishers to generate any of the above-mentioned ad tags for a website. However, the goal of this article is to help you to understand Google Publisher Tag. So, let’s start with the basics of it and understand how to set it up step by step.

What Is Google Publisher Tag (GPT)?

Google Publisher Tag is an ad tagging library that helps publishers dynamically build ad requests. Publishers can get better control over creating and serving ads on the inventory through Google GPT. It enables a publisher to define ad settings in the code and sets targeting options for different ad slots.

A Google Publisher Tag generally consists of key details such as ad unit size, size, and other key-values to display ads on mobile apps or web pages. A simple GPT tag looks like as follows: 

Sample GPT Tag

In the above GPT sample,

“6355419” is the network code, and “Travel/Europe/France/Paris” is the targeted ad unit. If you’re confused about finding your network code, go to the Ad Manager home page, and click Admin > Global settings > Network code. [300,250] is the ad unit size of the targeted slot. 

How Does Google Publisher Tag (GPT) Work?

Google Publisher Tag enables a publisher to create a communication path between the Google Ad Manager (DFP) and the user’s browser. This is how Google Publisher Tags work:

  1. A visitor comes to the publisher’s web page. The user’s browser calls the Ad Manager for a  GPT (consisting of JavaScript code).
  2. This GPT ad tag builds and sends one or more than one ad request to the Ad Manager (DFP) for ads tagged on that particular web page.
  3. With the details provided in the GPT, the ad server recognizes the ad units and associated key values.
  4. Then, it selects the best-matching ad and delivers it through the Google publisher tag.
  5. After this, the help of key values associated with the GPT helps the ad server to display the ad on the page. 

Now that we’ve understood how GPT works, let’s look at the steps to set up Google Publisher Tags in the ad server.

How to generate Google Publisher Tag in Ad Manager (DFP)?

Following are the steps to generate GPT in Google Ad Manager (DFP) – 

  1. Sign in to the Google Ad Manager account.
  2. Go to Inventory > Ad Units. And select the ad unit for which you want to create the ad tag.
  3. Click on Generate tags. Then, select the ad tag type as Google Publisher Tag.
  4. And then click Continue.
  5. Select the appropriate options to define the functioning of Google Publisher Tag (GPT) i.e.
  • Enable single request – This will enable the user’s browser to send one request for all ad units instead of sending multiple requests to individual ad units.
  • Create a passback tag – This can be chosen for setting up multiple demand partners in the waterfall method.
  • Collapse empty divs – On selecting this option, the browser automatically collapses the ad slots that don’t get filled and don’t leave a blank space on the page.
  • Page-level targeting – With this option, you can set custom attributes across all ad slots and utilize page-level targeting.
  • Out-of-page – Use this option to serve pop-up, pop-under, or floating ads through GPT.
  • Inventory unit sizes – Here, you can select the inventory sizes for the ad tag
  • Inventory unit level targeting – This option is used to set custom attributes across the selected ad inventories to target.
  1. And, then click continue.

At last, send the generated tag to your developer to paste the tag on the source code of the web page where ads will be displayed.

Benefits of Google Publisher Tags (GPT) Over Google Ad Manager Tags

Configuring Google Ad Manager with GPT could be beneficial to a publisher as it offers the following: 

  • Asynchronous rendering  – This allows the browser to load an ad without blocking the page rendering, improving page load time.
  • Single request mode – All ad units can be retrieved simultaneously via a single ad request, enabling advanced roadblocking. Thus, reducing latency.
  • SSL support – GPT automatically works with HTTPS:// and HTTP://. A publisher doesn’t have to modify GPT for secured or unsecured pages.
  • Multi-level Custom targeting – You can target ads based on slot-level/inventory-level as well as page-level.
  • Google Publisher Console – Via GPT, you can take advantage of Google Publisher Console, which consists of its own in-built debugging and support tools for publishers.
  • SafeFrame Capabilities – GPT enables publishers to render ads using SafeFrame which enables transparent interactions between the page’s content and ads and prevents external access to sensitive data. Hence, publishers’ ads render according to IAB standards.

Troubleshoot Common GPT Errors:

When there is an error in the GPT code, it’s time to troubleshoot Ad Manager. So, based on our experience, we’ve put together a couple of common errors and suggestions on how to resolve them.

Error 1 – Mis-ordered calls to Google Publisher Tags. An incorrectly ordered call to GPT can break the code and workflow. For example, if an Ad Manager user sets the page-level key-value targeting after calling the GPT.

GPT Error

Solution – Make sure that key-value targeting is done before calling the GPT. 

Error 2 – Undesirable reflow or unexpected behavior of GPT. A GPT may show unexpected behavior when the user/developer moves or inserts the slotted container in the DOM after calling the display.

Undesirable flow error in GPT

Solution – Ensure that DOM order changes happen before calling the display.

Error 3Haphazardly overwriting a GPT. Overwriting any variable or function in GPT may break the code and cause incorrect behavior.

Haphazard flow error in GPT

Solution – Always check GPT properties carefully, and never overwrite them.

Error 4 – Relying on the presence of the GPT. If a Google Ad Manager user checks the availability of GPT API before it isn’t ready, it may cause errors. 

Sample GPT Tag

Solution – Ensure the GPT API is ready and the GPT code is completely loaded. 

What’s Next?

Google Ad Manager comes with a bundle of features. However, we suggest you avoid a few common GPT implementation errors discussed in the previous section to get the most out of any feature or technology. 

If you’re still worried about how to get started with GPT or are stuck with some other issues, we’re here to help. Let’s know your doubts/issues in the comments section.

Frequently Asked Questions (FAQs)

Q.1. How Does Google Publisher Tag Work?

This GPT ad tag builds and sends one or more ad requests to the Ad Manager (GAM) for ads tagged on that particular web page. With the details provided in the GPT, the ad server recognizes the ad units and associated key values. Then, it selects the best-matching line items, decides the winner, and delivers the ad through the Google publisher tag to display the creative on the page.

Q.2. Can I Create Google Publishers Tags for Video & Audio?

Yes, Publishers can create Google Publishers Tags for Video & Audio. But, When you create an ad tag for live stream video, make sure you enable Live traffic to ensure the ability to handle heavy live traffic volumes, where all ad breaks are delivered at the same time. 

Q.3. What are the Benefits of Google Publisher Tags (GPT) Over Google Ad Manager Tags?

Asynchronous rendering allows the browser to load an ad without blocking the page rendering, improving page load time. Single request mode enables advanced roadblocking. Thus, reducing latency. GPT automatically works with HTTPS:// and HTTP://. A publisher doesn’t have to modify GPT for secured or unsecured pages.

News and Tips for Publishers

Get the inside scoop on publishing and programmatic with our 5-minute newsletter.