Kemal Yılmaz front-end developer
⚠️ This post might be outdated!

GPT's Event Lifecycle

From requesting ads to counting them as impressions, Google Publisher Tag (GPT) Library triggers a set of events to inform page about current display ad slot statuses. This page is a preliminary reading for the demo page I built for this event lifecycle.

Google Publisher Tag (GPT) is a JavaScript library to show digital ads controlled & served by Google Ad Manager on web pages. It is a fairly complex and closed source library maintained and served by Google. Simply put, you add a JavaScript Library and some additional html tags (ad tags) to your web page and Google gives you back display ads from a huge network of privacy eating partners, including themselves.

Switching back to technical mode here.

After playing around for a while, I decided to create a demo page to observe each GPT event and GPT option that change event behaviour. As I add extra features one by one, demo page gone bigger than I expected. So I split it up to a demo page and a blog post which is you’re reading right now.

To make some terms clear; ad tags are a bunch of html tags that help to define and show ads on your web page, ad slots are the representations of actual ads defined in your network. We use ad tags to define ad slots.

On the other hand, it is possible to define and show ads on a page without any ad tag. Tagging is the documented and recommended way by Google to define slots on a page.

Terms might be interchanged in different contexts. I’ll use “slot” or “ad slot” to point a specific ad and the JavaScript object represents that ad on a page.

GPT Events

Each ad slot has an event lifecycle controlled by GPT Library. Before listing events and their description, some visualization might be helpful.

A Sample Timeline

This is a sample timeline and network activity for a single slot on a page:

GPT's Event Lifecycle Timeline

Grey boxes are the network requests that represent event lifecycle. /ads?, /view? and /activeview? requests are the requests made by GPT to save different slot activity. You can use these strings to filter network requests to see slot activity. Use /ads? to see initial ad requests made by GPT, use /view? to see when the impression is recorded and /activeview? to see when the impression viewable info is sent to the server.

There are three /view? requests visualized in the graph. These do not necessarily exist in a single ad request alltogether. First two impressions that recorded between slotRenderEnded and slotOnLoad events are GPT’s built-in impression pixel and a custom creative pixel added by a user. (Named gpt and custom in the image. User-defined pixel have to be manually added to creative by an Ad Managed user.) Third impression pixel is -not sure a hundred per cent with that- an AMP impression pixel for AMP pages. Some creatives are served both standard pages and not-so-standard AMP pages. So these creatives have two different impression pixels; one for standard web and one for AMP which is the third pixel labelled “amp” in the image.

Event Details

Here are the events triggered by GPT Library and some details:

GPT Options that Change Event Behaviour

End Notes

I hope you find something useful in the content. Again, it is not a common topic for all but still, it may help some. “Digital advertising” and “working for sales people” weren’t my future plans and I thought I couldn’t handle it but yet I’m here writing posts on the topic.


GPT features related to these events might change by time. Always refer to the docs and reference for up-to-date content.