What Is an Ad Tag, and What Happens When It Fires
Written for the publisher who has been told to paste something into their template and would rather know what it does first.
The short version
- An ad tag is a small piece of code you paste into your page once, which asks an ad server for an ad and puts the answer in the slot.
- It is usually a script tag with a zone identifier in it, and that identifier is what tells the server which slot is asking.
- The tag goes exactly where you want the ad to appear, inside the body of the page.
- One tag per slot. The same tag in two places creates two slots that report as one.
- Nothing about your site changes when you add one. It is additive, and removing it puts everything back.
An ad tag is a small piece of code you paste into your page. When somebody opens the page, the tag asks an ad server for an advertisement and puts whatever comes back into that spot.
That is the whole thing. It is usually three or four lines, it goes in once, and the rest of this post is what happens inside those lines.
What one looks like
Different platforms word it differently, and every one of them is a version of the same two ideas: here is an empty box, and here is the code that fills it.
<div id="pb-zone-4821"></div>
<script src="https://yournetwork.example.com/serve.js" async></script>
The div is the empty box, and it is where the ad will appear. The number in it is the zone identifier: the thing that tells the server which of your slots is asking. The script is the code that does the asking.
What happens when it fires
Usually under 100 milliseconds. It happens once per slot, not once per page.
What the tag sends
Less than people assume. To choose an ad the server needs to know which slot is asking, what size it is, roughly where the reader is, what kind of device they are on, and what the page is about.
For a contextual setup that is the complete list. It does not send who the reader is, because it does not choose on who the reader is.
What comes back
A creative, or nothing. Nothing is a real answer: if no campaign cleared the floor price for that slot, the server says so and the fallback takes over. See what a passback does.
Where to put it
Three rules, and the third is the one people get wrong
-
1
Exactly where the ad should appear
Inside the body of the page, at the point in your template where you want the box. Not in the head.
-
2
Once per slot
One tag, one zone, one place in the template.
-
3
A new zone for each new position
If you want an ad in the sidebar and another in the article, those are two zones with two tags, not the same tag twice.
Putting it in without fear
The thing publishers actually worry about is breaking their site, so it is worth saying plainly what a tag can and cannot do.
- It is additive. It adds a box. It does not modify your layout, your styles or anything else on the page.
- It is asynchronous. The
asyncattribute means your page carries on loading while the ad is being fetched, so a slow ad server cannot hold up your article. - Removing it undoes it. Delete the two lines and your page is exactly as it was.
Where it goes depends on your platform: a Custom HTML block in WordPress, a theme template in Shopify, or directly into the page for plain HTML. If you use a caching plugin, clear the cache afterwards, which is the single most common reason somebody thinks the tag did not work.
When nothing appears
In rough order of likelihood:
Check these before asking anybody
- Cache cleared, on both your site and your CDN.
- The tag is on the published page, not only in a draft. View source and search for the zone id.
- Your ad blocker is off. This catches more people than everything else combined.
- The zone has something to serve: a campaign, or a fallback set.
- The domain is approved. Pyrobid approves the first hostname a zone serves on by itself, some platforms make you verify first.
An empty slot with no fallback set looks identical to a broken tag, which is why setting a fallback before you paste anything is worth the extra minute.
Keep reading
Your own ad sales portal, live in five minutes
Advertisers sign up, add funds and build their own campaign. You approve the creative before it runs. Your existing ads keep running underneath as the fallback, so nothing comes down while you try it.
Start free trial14 days free. Your existing ads keep running. Cancel anytime.