Google Publisher Tags: The Ultimate Guide

Brock Munro
May 31, 2021
March 20, 2024
Google Publisher Tags: The Ultimate Guide

Since the inception of digital advertising in 1994, when the first-ever ad was placed on a website, the industry has been using the same technology to serve ads to web pages- The Ad server. Google Ad Server is the most popular ad server,  with 80% of the U.S. market for search ads, accounting for the bulk of its $116.3 billion in total ad revenue last year. 

Ad tags are an integral part of the ad serving process. They are a snippet of code that reserves a space on a website for ad creative until the ad is served. Ad tags facilitate communication between publishers, advertisers, and ad exchanges. 

 

There are several types of ad tags available in Google Ad Manager, including:

  • Accelerated Mobile Page Tags for use with AMP pages
  • Mobile Application Tags for serving ads on mobile app inventories
  • Ad Exchange Tags for publishers integrating Ad Exchange with Google Ad Manager; and 


According to Google Developer, Google Publisher Tag (GPT) ‘ is an ad tag library which allows publishers to define inventory, initiate and bundle ad requests, and render matching demand’. For digital publishers working with ads to monetize their website, it is essential to understand how the GPT library works and how they can leverage google publisher tag GPT to generate maximum return on their advertising investment. 

What is Google Publisher Tag?

 

Google Publisher Tag is an ad tagging library that enables publishers to dynamically build ad requests for ad units. It allows publishers to define ad settings within the code and set targeting options for different ad slots, giving publishers control in creating and serving ads on the inventory.

Google Publisher Tags consists of vital details about the ad unit, including the ad unit size, ad size, and other information to enable key-value targeting.

A simple GPT defining the ad size  will appear as such:

GPT code defining key values such as ad size

How Does Google Publisher Tag Work?

 

GPT works by providing a communication channel for ad calls between the ad server and the user’s browser, allowing the site to render ads from the Google Ad Server.

 

Here’s how Google Publisher Tags work:

  1.  A visitor navigates to the publisher’s web page. The user’s browser then makes a request to the ad server looking for the GPT javascript code.
  1. Next, the GPT ad tag code generates one or more requests and forwards them to the Google ad server.
  1. The ad server then reads the request, recognizing all the relevant key values contained in the ad unit, such as the ad layout, size, and targeting.
  1. The ad server then evaluates the best matching ad and returns the ad code to tagging JavaScript.
  1. Finally, GPT takes key details tagging Javascript file and the ad server runs the in the available ad slots.

 

Benefits of Google Publisher Tag

Google Publisher Tags offer several benefits, such as:


Access to Google Publisher Console

GPT enables publishers to access the Google Publisher Console, a support tool consisting of built-in debugging tools that help publishers troubleshoot any issues they are experiencing as they build ads.


Asynchronous Rendering

Google Publisher Tag also facilitates asynchronous rendering, whereby the GPT javascript renders without blocking the page rendering and vice-versa. This leads to reduced page latency and improved page load time. Publishers also have the option to render their page’s content synchronously if they so choose.


Cache Busting

Google Publisher Tag GPT also offers a cache-busting element meaning that the ad server returns ads from the server rather than the browser cache.


Multi-Level Inventory Hierarchy

Multi-level inventory hierarchy allows publishers to set multiple line items with desired granularity for custom targeting. Publishers can use page-level targeting and inventory level targeting. 

Responsive Ads

Google publisher tag works with responsive ad units, allowing ad requests for multiple devices such as desktop and mobile, regardless of ad size. This means ads are served with optimal resolution without needing multiple line item setups.

Single Request Architecture (SRA)

Single request architecture allows GPT to bundle ad requests, sending multiple requests to the ad server simultaneously and consequently improving page load time.

SSL support

GPT offers SSL support, so whether URLs begin with HTTPS:// or HTTP://, publishers don’t have to modify their GPTs. Regardless of whether they are secure webpages and unsecured webpages, there is no need to change the tag in any way for serving on a secure page.


Getting Started with GPT in Google Ad Manager

Getting started with Google Publisher tags is simple once you have access to an Ad Manager account.  

The following steps will allow publishers to generate GPT in Google Ad Manager.


  1. Firstly, sign in to the Google Ad Manager account
  2. From here, navigate to Inventory > Ad units and select the ad unit for which you wish to generate the ad tag
  3. On the right-hand side of the page, click on Generate tags, and select the ad tag type Google Publisher Tag.
  4. Click continue
  5. Set custom attributes you want to define the functioning of your GPT. Ensure you check GPT properties carefully before the next step.
  6. Click Continue
  7. Finally, save your settings which will give you the tag to paste into your web page's source code.


Some Common GPT Errors

While GPT is relatively straightforward to implement, as with any tag code built, publishers may encounter some issues along the way. Here are some common errors as defined by Google Developers, and some suggested solutions.


Error 1: Relying on Gpt.js Script Tag Listeners

As we can see in the following example, relying in any way (including frameworks) on the API from within event listeners attached to the script tag is incorrect.


GPT error relying on gpt.js script tag listeners


Solution:

Ensuring that the googletag.cmd  exists  (as you can see in the below code)  should fix this scenario. This is because the googletag.cmd maintains a list of commands that will be run as soon as GPT is ready, meaning your callback is run when GPT has loaded.


Solution to Gpt.js Script Tag Listeners issue in GPT



Error 2 –Misusing Closures and JavaScript Variable Scoping

This error occurs when the code script contains incorrect assumptions about Javascript variable scoping and the value of the variables passed to googletag.cmd.push.

 

Error Misusing Closures and JavaScript Variable Scoping in GPT

 

 

Solution: When working with javascript, closures capture variables by reference rather than by value. Therefore, if a variable is reassigned, its new value will be used when the function closure that captured it is later executed. This can cause problems in the case of asynchronously loaded GPT. TO avoid any issues with the above situation, care should be taken with  regards to scoping rules of JavaScript. The code should also be written without the assumption that functions placed on the command queue will execute immediately, as seen below.


Solution to Misusing Closures and JavaScript Variable Scoping



Google Ad Manager comes with various functions and features to assist multiple demand partners in serving ad units and monetizing their site content. With GPT, publishers can define inventory, initiate and bundle ad requests, and then render specifically targeted ads tagged with their desired key values.


Google GPT offers many benefits over other ad tags, including the ability to render ads asynchronously and serve up dynamic ads in multiple sizes for a range of different devices.


Fuse Platform- One Tag to Solve All Your Ad-Unit Problems


As demonstrated above, even the most experienced web admins may encounter problems when using a GPT ad tag to create an ad request for their web pages.

Publift's Fuse platform is the ultimate all-in-one programmatic advertising solution for web and app publishers.

To start experiencing the power of Fuse on your site, simply replace your current AdSense, Ad Manager, AdMob or third-party tag/ SDKs with our Fuse technology. Once your tags are on the page, our expert team will be able to test, analyze and optimize your setup to maximize revenue. 

If you’re making more than $2,000 in monthly ad revenue, contact us today to learn more about how Publift can help increase your ad revenue and best optimize the ad space available on your website or app.

Grow with us

Grow your business with a sustainable, long term partnership. If you're making more than $2,000 in monthly ad revenue, contact us today to boost your revenue with our all-in-one solution.
Laptop screen with web page open

Success Stories