What happens when an ad tag loads
Every ad tag turns an empty slot into a request an ad server can answer:
- The browser reads the tag. The publisher's snippet retrieves an ad from the ad server.
- The tag builds a request. It packages the slot's ad unit code, ad size and any custom targeting.
- The ad server picks an ad. It serves the appropriate advertisement and measures what it served. When programmatic demand competes, the server may also send a bid request to buyers.
- The ad renders. The tag places the creative in the container reserved for it.
Each served ad counts as an ad impression. A slot the tag never calls stays empty, and that ad inventory goes unsold.
Anatomy of a Google Publisher Tag, line by line
The Google Publisher Tag (GPT) is the ad tagging library for Google Ad Manager. Google's sample tag for one banner, trimmed:
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js" crossorigin="anonymous"></script>
<script>
window.googletag = window.googletag || { cmd: [] };
googletag.cmd.push(() => {
googletag.defineSlot("/6355419/Travel/Europe/France/Paris", [300, 250], "banner-ad")
.addService(googletag.pubads());
googletag.enableServices();
});
</script>
<div id="banner-ad" style="width: 300px; height: 250px"></div>
<script>googletag.cmd.push(() => { googletag.display("banner-ad"); });</script>What each part does:
async src=".../gpt.js"loads the library in parallel with the rest of the page, so the page keeps rendering.window.googletag =...creates thegoogletagobject and its command queue.cmd.push(...)queues the setup to run once the library has loaded.defineSlot(path, size, id)names the slot:/6355419is the publisher's network code,/Travel/Europe/France/Paristhe ad unit path,[300, 250]the size in pixels and"banner-ad"the element that holds the ad.addService(googletag.pubads())attaches the slot to the publisher ads service.enableServices()switches the ad services on.<div id="banner-ad">is the container; its ID and size must match the slot.display("banner-ad")sends the request and renders the ad in that container.
Reading a VAST video ad tag URL
A video player calls a tag URL and receives an XML response in VAST, the IAB Tech Lab's universal schema for serving ads to digital video players, whose newest core version is 4.3 (2022). In Google Ad Manager the URL starts with https://pubads.g.doubleclick.net/gampad/ads? and carries the slot as parameters:
| Parameter | Example | What it tells the ad server |
|---|---|---|
iu |
iu=/6062/videodemo |
The ad unit |
sz |
sz=400x300 |
The video slot size |
env |
env=vp |
The request comes from a video player |
output |
output=xml_vast4 |
Return the ad as VAST 4 |
unviewed_position_start |
unviewed_position_start=1 |
The impression may be delayed |
url |
url=https%3A%2F%2Fwww.example.com%2Fvideo.html |
The page the request came from |
description_url |
description_url=...golf.html |
A page describing the video |
The url parameter is required for programmatic monetization and description_url for Ad Exchange or AdSense demand, so a stripped-down video tag quietly loses paying buyers. See in-stream video for formats.
Ad tags, tracking pixels and the rest of the tag stack
"Tag" covers several kinds of page code, and searchers often mix them up. An ad tag requests and delivers an ad. A tracking pixel reports what a shopper did afterward, such as a purchase, back to an ad platform. Both often sit on the same site.
Advertisers have tags too. A third-party ad server such as Campaign Manager 360 issues placement tags, which call URLs on the doubleclick domain. The publisher traffics that placement tag as the creative: the publisher's tag calls the publisher's ad server, which returns the advertiser's tag, which serves and counts the advertiser's creative in the advertiser's own system. For measurement that leaves the browser entirely, see server-side tracking.
Where ad tags sit in retail media campaigns
Sponsored product ads on a retailer's own site and app are built in the network's console, and the retailer serves them inside its own pages. Offsite campaigns work like the rest of programmatic: a brand uses a retailer's audiences to buy display or video on other sites. There, a publisher's tag retrieves the ad from an ad server.
That offsite path runs through a demand-side platform on the buy side and a supply-side platform on the publisher side, as laid out in onsite vs offsite advertising. For a brand, a broken tag on a publisher page shows up as lost offsite delivery. Each network's formats are profiled on the retail media networks hub.
When an ad tag fails to fire
If a tag doesn't fire, it can't track or return creative content as intended. The common faults follow from the anatomy above:
- Mismatched IDs. The slot's element ID differs from the
<div>ID, so the ad has nowhere to render. - Edited tags. Someone trimmed or retyped the code; compare the implemented tag against the tag as it exports.
- Blocking scripts. A library loaded without
asyncholds up the page until it finishes loading. - Missing parameters. A video tag without
urlordescription_urlcuts out programmatic buyers.
Chrome Developer Tools shows each case: the Elements tab for the container, and the Network and Console tabs for the request and any errors it threw. Recheck the live page after every template change.
Frequently asked questions
What is an HTML ad tag?
An HTML ad tag is the block of HTML and JavaScript a publisher places where an ad should appear. It loads an ad library, defines the slot's ad unit and size, and reserves a <div> container. On page load, the returned ad renders in that container.
What does an asynchronous ad tag do?
An asynchronous ad tag loads its library in parallel with the page. With the async keyword on its script, the browser keeps rendering content while the ad library downloads, and queued commands run once it is ready. A slow ad server then delays only the ad.
Is an ad tag the same as a tracking pixel?
No. An ad tag asks an ad server for an ad and displays it in a slot. A tracking pixel reports an event, such as a page view or purchase, back to an ad platform for measurement and audience building. People group both as advertising tags.
Who creates the ad tag, the publisher or the advertiser?
The publisher's ad server generates the tag that sits in the page and defines the slot. An advertiser with its own ad server issues a placement tag, which the publisher traffics as the creative. That tag returns the advertiser's creative and tracks delivery in the advertiser's own system.
What is a VAST tag?
A VAST tag is the video version of an ad tag: a URL that a video player calls to request an ad. The ad server replies with XML in the IAB Tech Lab's VAST format, which describes how the player should handle the ad.

















