What is Google Publisher Tag?

  • 27 / 05 / 2024
  • Alicja Graczyk
What is Google Publisher Tag?

A publisher exploring monetization may encounter a range of concepts. Google Publisher Tag is one of them, especially for those seeking solutions to monetize Internet content through Google and their wide range of digital profit-generating tools. Here, you will find a comprehensive guide on this topic!

Google Ad Manager tags

To put it simply, an ad tag is a piece of code that helps to serve ads. There is a variety of ad tags serving different purposes that can be used in the GAM environment. What’s more, there are many ways to create them within Google Ad Manager. Here are some examples of ad tags worth knowing about:

  • Mobile Application Tags are ad tags that need to be known by the application developers so that ads can be implemented in your mobile app. Once you’ve selected this ad type, there are no further customization choices available;
  • VAST ad tags facilitate communication between ad servers and video players. If you wish to display ads in video players, you have to place this kind of code on your website. However, it’s wise to protect yourself in case some issues arise, so be sure to check out our article for further information on VAST errors;
  • Google Publisher Tag for Video and Audio is basically the same thing as the VAST ad tag. It carries data that contains necessary details for requesting a video or audio ad, such as information on any additional companion ads;
  • and finally, Google Publisher Tag (GPT) that aims at building and serving ad requests. We will explain more regarding this one in the next paragraphs!

Google Publisher Tag

Google Publisher Tag (GPT) is an ad tagging library. It’s a solution available for Google Ad Manager users that lets them define ad inventory, as well as initiate and build ad requests. GPT tags are needed to display ads on web pages. They hold information about ad size, ad unit, and possible required targeting. Importantly, these tags play a vital role in enhancing page loading speed.

How Google Publisher Tag works:

  1. A user visits a publisher’s website. It triggers an ad request for a GPT JavaScript tag code from the user’s browser;
  2. Once the GPT ad tag code is triggered, it generates one or more ad requests and sends them to the Google ad server;
  3. After that, the ad server matches the ad units and, optionally, key values specified in the ad request;
  4. Then, the auction takes place, during which the best “contestant” (the winning ad creative) is chosen;
  5. The winning ad is sent to the GPT JavaScript;
  6. With the tag’s help (through rendering), the ad is displayed.

Benefits of Google GPT

  • Custom targeting, with which you can establish more precise targeting criteria based on your site’s content and set targeting preferences for both the entire page and individual ad slots;
  • Minimized page latency thanks to asynchronous rendering, which means your webpage loads without requiring JavaScript to be retrieved from the Ad Manager servers, reducing waiting time. What’s more, Google gives up on sending one ad request to a server if it’s possible to send multiple of them at the same time;
  • Responsive ad units are effortlessly handled by the Google Publisher Tag, enabling ad requests for diverse devices, including desktop and mobile;
  • Google supports people who utilize the GPT tag. You can have access to Google Publisher Console on pages that include the tag;
  • GPT respects the user’s choices as it communicates with CMPs compliant with the Interactive Advertising Bureau (IAB). Thanks to GPT’s API, publishers can adjust privacy settings to steer ad display options;
  • Your ad format choice can be broad with that tag, for instance, you can go for rewarded, top anchor, or web interstitial;
  • You have control over your ad inventory and protection from potentially harmful creatives and auto-redirects;
  • As a result of the connection between GPT and the server, it’s known what ads are served. This way, you can, for instance, go for competitive exclusions (when, for example, one advertiser that sells perfumes doesn’t want his ad to be displayed next to his competitor’s creative). It’s in advertisers’ interest to ask for it, but if you agree, your collaboration with them can be more solid! Your third option is the use of roadblocks, which lets you display several ads for the same ad request.

Get started with Google Publisher Tag

The process consists of three steps:

  1. Generating an ad tag;
  2. Setting up a test ad;
  3. Displaying the ad.

To generate an ad tag in GAM:

1. Sign in to your Google Ad Manager account;

2. Go to “Inventory” and later “Ad units” and pick the specific ad unit for which you want to create the ad tag. This way, you will be able to see all the details;

3. Next, choose the “Tags” tab on the details page;

4. Now it’s time to select Google Publisher Tag type from the list and click “Continue”;

5. After selecting the tag type, you can make further selections and then proceed by clicking the “Continue” button;

6. You can now copy and save for later the tags generated from “Tag results” (so they can be incorporated into the website’s source code).

Now, it’s time for some coding!

To set up a test ad:

1. Generate a basic HTML document (named “hello-gpt.html”):

<!doctype html>

<html>

  <head>

    <meta charset="utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1" />

    <meta name="description" content="Display a fixed-sized test ad." />

    <title>Display a test ad</title>

    <style></style>

  </head>

  <body>

    <script>

      googletag.cmd.push(() => {

        // Request and render an ad for the "banner-ad" slot.

        googletag.display("banner-ad");

      });

    </script>

  </body>

</html>

2. Now, it’s time to load the GPT library by including the code below in the <head> section:

<head>

  <meta charset="utf-8" />

  <meta name="viewport" content="width=device-width, initial-scale=1" />

  <meta name="description" content="Display a fixed-sized test ad." />

  <title>Display a test ad</title>

  <script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>

  <style></style>

</head>

3. To define the ad slot and initialize GPT, you can use the googletag.enableServices() method. Change the code in appropriate places:

define_ad_slot_gpt
source: https://developers.google.com/publisher-tag/guides/get-started

<head>

  <meta charset="utf-8" />

  <meta name="viewport" content="width=device-width, initial-scale=1" />

  <meta name="description" content="Display a fixed-sized test ad." />

  <title>Display a test ad</title>

  <script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>

  <script>

    window.googletag = window.googletag || { cmd: [] };


    googletag.cmd.push(() => {

      // Define an ad slot for div with id "banner-ad".

      googletag

        .defineSlot("/6355419/Travel/Europe/France/Paris", [300, 250], "banner-ad")

        .addService(googletag.pubads());


      // Enable the PubAdsService.

      googletag.enableServices();

    });

  </script>

  <style></style>

</head>

4. Now, decide on the exact localization of the ad. Remember that this <div>’s ID matches the one specified when defining the ad slot. Add the code adjusted to your needs to the <body> section of your HTML document:

<body>

  <div id="banner-ad" style="width: 300px; height: 250px"></div>

  <script>

    googletag.cmd.push(() => {

      // Request and render an ad for the "banner-ad" slot.

      googletag.display("banner-ad");

    });

  </script>

</body>

5. After saving the “hello-gpt.html” file, you can preview the test page by opening it in a web browser.

To display the ad:

1. Open your “hello-gpt.html” file;

2. Find the ad tag you previously generated in Ad Manager;

3. Replace the corresponding code in the <head> section of your HTML document with your GAM-generated ad tag code (remember to complete the .defineSlot element with appropriate information regarding your ad’s path, width, height, and id):

<head>

 <meta charset="utf-8">

 <title>Hello GPT</title>

 <script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>

 <script>

   window.googletag = window.googletag || {cmd: []};

   googletag.cmd.push(function() {

     googletag

         .defineSlot(

             "ad-unit-path", [width, height], "div-id")

         .addService(googletag.pubads());

     googletag.enableServices();

   });

 </script>

</head>

4. After all the revisions, save the updated version of your “hello-gpt.html” file and then launch it in a web browser.

However, you should remember some dos and don’ts while implementing your GPT code. Before delving in, you can also read more on general Google Publisher Tag’s best practices.

Congratulations!

If you carefully followed the above-described steps, you just implemented your first Google Publisher Tag! However, if you need assistance, we’re more than happy to help – our optAd360 AI Engine automates the whole monetization process, so you don’t need to deal with troublesome tags all by yourself! What’s more, we support our publishers throughout the whole ad revenue-generating journey, from ad implementation through inventory optimization all the way to trouble-free payments. If you’d like to join the optAd360 network, please get familiar with our requirements, and fill in the registration form!

Read also

Web performance optimization – tips for digital publishers
Web performance optimization – tips for digital publishers

Web performance optimization – tips for digital publishers

Are you a digital publisher who wants to optimize your website? Let us provide you with some helpful tips!

Read more
What is banner blindness?
What is banner blindness?

What is banner blindness?

Extensive exposure to digital advertising can sometimes be overwhelming, making ad creations less visible or noticeable, ultimately leading to a drop in your ad revenue. Learn more about banner blindness and how you can prevent it!

Read more

Find the best solutions
for your business

Benefit from expert knowledge

Start earning more

Registration to the optAd360 network

Increase your ad revenue!

Join satisfied publishers who, thanks to the optimization of their advertising space
with our technology, started to generate greater profits.

Sign up