Google Publisher Tags offer flexibility in how you request ads from Ad Manager, and you'll then render those ads on your page. Developers can view example tags to learn how to specify request and rendering modes in your code.
Request modes
Single request architecture (SRA)
When you use SRA, all defined ad slots are requested from Ad Manager when the first call for an ad to display executes. Using SRA can improve your page’s loading speed and makes it possible to guarantee roadblocks. All Ad Manager creative types and line item types are supported by SRA, except Studio Dynamic ads. This is the recommended request mode.
Trafficking nonexistent networks using SRA causes the entire ad request to fail.
To enable SRA, include enableSingleRequest()
in your GPT code, before enableServices()
or display()
. This line calls all ad slots on the page at once and allows for guaranteed roadblocks.
Create one SRA request with all ad slots to best serve guaranteed roadblocks or competitive exclusions, instead of sending single ad requests with one ad slot at a time.
Multi-request mode
With a multi-request tag, each ad slot defined is sent to Ad Manager separately from the body of your content. Unlike with SRA, multi-request tags don't guarantee roadblocks or exclusions (including competitive, same advertiser and same creative). This is the default request mode.
Rendering mode
GPT only supports asynchronous rendering. This allows your content and ads to load independently.
Each ad renders within a space that’s reserved on the page until the ad is ready to display. This ensures that requesting and rendering ads does not block loading content
SafeFrames and friendly iframes for GPT
SafeFrame is a cross-domain iframe that enables transparent and rich interactions between page content and ads, while preventing ads from accessing publisher data. We recommend using SafeFrames and creatives compatible with SafeFrame for expansion instead of friendly iframes.
To minimize the chances of malicious creatives serving, we recommend enabling SafeFrame whenever possible, in conjunction with the HTML5 sandbox
attribute (which are enabled by default) to prevent top-level navigation.
SafeFrame is supported in Ad Manager and enabled by default when using Google Publisher Tags. AMPHTML ads do not serve into SafeFrames, and use friendly iframes instead. Learn more about SafeFrame and AMP
Some creatives, such as expandable ads or creatives that access your page’s DOM elements, might not render correctly in SafeFrames or other cross-domain iframes. We recommend updating these creatives to make them SafeFrame-compatible, in order to retain SafeFrame’s security benefits. If this is absolutely not an option, there are a few things you can do to allow reservation ads of this type to render properly:
- Disable rendering in a SafeFrame and thus use a friendly iframe.
- Convert custom templates to work with friendly iframes.
- Follow the IAB's best practices for iframe-friendly rich content ads.
- Use an iframe buster to serve expandable creatives.