Google Publisher Tags Guide: Integration and Implementation

Since the very first ad was placed on a website in 1994, the advertising industry has used a specific Ad Technology to enable the monetisation of websites – the Ad Server. According to Datanyze, Google Ad Manager is the dominant ad server used by websites with a global market share of 33%. In 2018, Google merged DoubleClick for Publishers (DFP) and Google Ad Exchange to create Google Ad Manager. Which brings us nicely onto Google Publisher Tags.

This article will explain not only what GPT are but also how they work, how to generate them and the benefits they bring.

What are Google Publisher Tags

Google Publisher Tag (GPT) is an ad tagging library used for Google Ad Manager (GAM). Google Publisher Tags enable publishers to dynamically build the ad request and display the ad on web pages. With GPT, you can define inventory, initiate and bundle ad requests, and then render the matching demand.

Google Publisher Tags

How do Google Publisher Tags Work?

GPT is used to define your available ad slots. Placing GPT on a page creates a link between the ad server and a user’s browser. When a user visits a page containing GPT, the following happens:

  1. A request is made from the user’s browser to the ad server for gpt.js, the tag code built in JavaScript.
  1. The JavaScript builds and sends one or more requests to the ad server for ads tagged on the page.
  1. The ad server matches the ad units and any key-values contained within the request.
  1. The ad server runs an auction to select the best matching creative for the ad unit.
  1. The ad server returns the matching ad to the GPT JavaScript.
  1. The GPT JavaScript renders the ad on the page.

How do you generate Google Publisher Tags?

Generating and customizing Google Publisher Tags can be done easily through the Google Ad Manager interface:

  1. Sign in to Google Ad Manager.
  1. Navigate to Inventory and then Ad units.
  1. Find the ad unit for which you want to create an ad tag and click on its name to see its details.
  1. Select GPT and click Continue. 
  1. Select appropriate options:
    • Collapse empty divs: This enables the browser to automatically collapse ad units that are not filled so as not to leave a blank space on the page.
    • Ad sizes: This option is used to select the ad sizes for the ad tag, not including any out-of-page creatives
    • Out-of-page: This applies the ability to serve pop-under, pop-up, and floating ad creatives
    • Ad units: This sets custom attributes for specific ad units 
    • Single request: Single request architecture (SRA) means the browser is able to send one request for all ad units instead of multiple requests for each ad unit.
    • Page-level: This allows for page-level targeting, reducing the amount of code used by applying the same targeting attributes to all ad units on the page
    • Passback tag: This enables multiple demand partners to be set up to passback sequentially such as in a waterfall.

A few things to consider for effective use of Google Publisher Tags

  1. Place tags directly on the page

Where you can, implement tags directly on a page rather than inside another JavaScript file that needs to be downloaded as this can cause delays in the ad server flow and interfere with content loading.

  1. Call GPT early

Request the GPT library as early as possible to give the browser time to fetch and execute the dependent libraries

  1. Use asynchronous mode with single request architecture (SRA)

Asynchronous mode enables your content and ads to load independently, meaning each ad renders and is reserved on the page until the ad is ready to display. SRA enables ad requests for a page-view are sent at one time, which can improve page loading speed.

A Few Common Implementation Mistakes

  1. Mis-ordering calls to GPT

An incorrectly ordered call to GPT can break the workflow. A common example is setting page-level targeting after calling the GPT. To overcome this, ensure that targeting is done before calling the GPT:

INCORRECT: Setting page-level targeting after calling

googletag.enableServices().

googletag.enableServices();

googletag.defineSlot(…);

googletag.pubads().setTargeting(e, a);

CORRECT: Setting page-level targeting before calling

googletag.enableServices().

googletag.pubads().setTargeting(e, a);

googletag.defineSlot(…);

googletag.enableServices();

  1. Relying on the presence of the GPT. 

Relying on the presence of a googletag object alone does not mean the GPT API is available and ready and if it is not, it will cause errors. To avoid this, use the boolean flag googletag.apiReady so that GPT will populate as soon as the API is ready to be called:

INCORRECT: Relying on the presence of the googletag object as a check for the GPT API.

if (typeof googletag != ‘undefined’) {

 functionProcessingGPT();

}

CORRECT: Relying on googletag.apiReady as a check for the GPT API.

if (window.googletag && googletag.apiReady) {

 functionProcessingGPT();

}

  1. Overwriting a GPT. 

Overwriting any variable or function in GPT may break the code and result in incorrect behavior. To resolve this, always check GPT properties carefully, and never overwrite it:

INCORRECT: Haphazardly overwriting a googletag.* property.

googletag.cmd = [];

CORRECT: Never overwrite googletag.* properties if they already exist. Always check before assigning to them.

googletag.cmd = googletag.cmd || [];

What are the Benefits of Google Publisher Tags?

There are multiple benefits to GPT:

  1. Google Publisher Console is a built-in debugging and support tool for publishers available on all pages containing the Google Publisher Tag.
  2. Multi-level targeting allows for more granular targeting of ad units as well as at a page-level
  3. Asynchronous JavaScript fetch minimizes page load time impact. This means your webpage will render without having to wait for the JavaScript to be returned from the Ad servers. 
  4. Single request architecture (SRA) improves page load time as one request is sent to the ad server instead of sending individual requests for each ad unit.
  5. SafeFrame capability brings IAB standards to ad rendering. This capability enables transparent interactions between the page’s content and ads and prevents any external access to sensitive data through untrustworthy creatives and auto-redirects.
  6. Responsive design enables GPT to build ads that fit the browser your visitors use to view your website. This means that your ads look good on any device.
  7. SSL Protocol is automatically enabled with GPT, ensuring secure webpages whose URLs begin with https:// are supported. There’s no need to modify the tag in any way for serving on a secure page.

In Conclusion

As the dominant Ad Server, Google Ad Manager rightly has many useful features that make life easy. There are tons of walkthroughs and best practice guides available through Google Ads Manager help and support pages. Using Google Publisher Tags helps you get the best out of GAM and as long as you avoid some of the common mistakes and ensure you follow best practices as closely as you can, you should see the benefit of GPT.