← Back to list

Improving Ad Performance on Modern Websites: A Practical Guide with Prebid, GAM, and Amazon

Digital advertising performance is no longer just about CPMs. It is a careful balance between user experience, latency, auction dynamics…

Andrei Lopatin · 2026-01-07 19:05 · 7 claps · 3.5 min read
#advertising #typescript #prebid #amazon-ads #google-ad-manager
Open on Medium ↗
Wiki topics: UX · UI/UX Design MKT · Marketing · General 🌐 · Web Development

Improving Ad Performance on Modern Websites: A Practical Guide with Prebid, GAM, and Amazon

Digital advertising performance is no longer just about CPMs. It is a careful balance between user experience, latency, auction dynamics, and revenue optimization. In this article, we’ll walk through proven, production-tested techniques to improve ad performance on your website, with a strong focus on Prebid.js, Google Ad Manager (GAM), and Amazon Publisher Services (APS).

This guide is written for engineers, ad-tech leads, and performance-minded publishers, and includes real code examples you can adapt directly.

1. What Does “Ad Performance” Really Mean?

Before optimizing, it’s important to define success. Ad performance usually combines:

  • Revenue metrics: CPM, RPM, fill rate, bid density
  • Latency metrics: time-to-first-ad, time-to-interactive (TTI)
  • User experience: CLS, LCP, page responsiveness
  • Auction efficiency: bid competition without timeout inflation

A common mistake is optimizing for CPM alone. Higher CPMs often come with longer auctions, which can reduce page views and overall revenue.

2. High-Level Principles for Better Ad Performance

Regardless of stack, strong ad setups follow these rules:

  1. Async everything — never block rendering
  2. Limit auction participants — more bidders ≠ more revenue
  3. Control timeouts aggressively
  4. Load ads dynamically, not all at onceMeasure continuously — every change must be observable

3. Prebid.js Best Performance Practices

3.1 Optimal Number of Bidders

One of the most misunderstood questions:

What is the optimal number of bidders in Prebid?

Short answer: usually 5–8 high-quality bidders per ad unit.

Why?

  • Each bidder adds network latency
  • Diminishing returns after top bidders
  • More JS execution and memory usage

Observed reality in production:

Focus on bidder quality, not quantity.

3.2 Use Global Bidder Timeouts

pbjs.setConfig({
  bidderTimeout: 800, // milliseconds
  enableSendAllBids: false
});

Best practice:

  • Desktop: 700–1000ms
  • Mobile: 500–700ms

Anything above 1200ms almost always hurts UX more than it helps revenue.

3.3 Use Floors (But Smart Floors)

Static floors often fail. Use dynamic or bucketed floors:

pbjs.setConfig({
  floors: {
    data: {
      currency: 'USD',
      values: {
        'banner|300x250': 0.50,
        'banner|728x90': 0.80
      }
    }
  }
});

Floors reduce low-quality bids and speed up auctions by cutting wasted responses.

4. Making Bids Async Between Prebid, Amazon, and GAM

4.1 The Goal

You want Prebid, Amazon APS, and GAM to:

  • Load in parallel
  • Respect a global timeout
  • Trigger GAM only once

The biggest anti-pattern is: Waiting for each system sequentially

4.2 Recommended Architecture

Page Load
 ├─ Load Prebid.js (async)
 ├─ Load Amazon APS (async)
 ├─ Load GPT (async)
 └─ Trigger GAM once all bids are ready or timeout

4.3 Example: Async Prebid + Amazon + GAM

window.googletag = window.googletag || { cmd: [] };
window.pbjs = window.pbjs || { que: [] };  

let PREBID_TIMEOUT = 800;
let AMAZON_TIMEOUT = 800;
let prebidBidReady = false;
let amazonBidReady = false;

function sendAdServerRequest(force = false) {
  if (force || (prebidBidReady && amazonBidReady)) {
    googletag.cmd.push(function () {
      pbjs.setTargetingForGPTAsync();
      apstag.setDisplayBids();
      googletag.pubads().refresh();
    });
  }
}

// Fail-safe timeout
setTimeout(() => {
  sendAdServerRequest(true)
}, 1200);

// Prebid
pbjs.que.push(function () {
  pbjs.requestBids({
    bidsBackHandler: () => {
      prebidBidReady = true
      sendAdServerRequest()
    },
    timeout: PREBID_TIMEOUT
  });
});

// Amazon APS
apstag.fetchBids({
  slots: window.amazonSlots,
  timeout: AMAZON_TIMEOUT
}, () => {
   amazonBidReady = true
   sendAdServerRequest()
});

Key points:

  • Single sendAdServerRequest()
  • Global fail-safe timeout
  • Do not send only one of the bidders before fail-safe timeout

5. What Should Load First?

5.1 Critical Rendering Path Rules

Never block:

  • HTML parsing
  • CSS rendering
  • Core JS execution

Ads are non-critical content.

5.2 Recommended Load Order

  1. Core page content
  2. Analytics (lightweight)
  3. Prebid & APS (async)
  4. GPT
  5. Lazy-load below-the-fold ads

5.3 Dynamic Ad Loading with Intersection Observer

const observer = new IntersectionObserver(entries => {
  entries.forEach(entry => {
    if (entry.isIntersecting) {
      googletag.cmd.push(() => {
        googletag.display(entry.target.id);
      });
      observer.unobserve(entry.target);
    }
  });
});
document.querySelectorAll('.ad-slot').forEach(slot => {
  observer.observe(slot);
});

Benefits:

  • Faster initial page load
  • Higher viewability
  • Better Core Web Vitals

6. Prebid + Lazy Loading: The Right Way

Do not run one giant auction for the whole page.

Instead:

  • Run initial auction for above-the-fold
  • Trigger new auctions as slots appear
pbjs.requestBids({
  adUnitCodes: ['top-banner'],
  timeout: 700
});

This reduces bid waste and improves bidder efficiency.

7. Monitoring & Continuous Optimization

You can’t optimize what you don’t measure.

Key Metrics to Track

  • Auction time distribution (p50, p95)
  • Bidder timeout rate
  • CPM vs latency correlation
  • CLS impact from ads

Tools

  • Prebid Analytics adapters
  • GAM Query Tool
  • Web Vitals (LCP, CLS)

8. Common Mistakes to Avoid

❌ 15+ bidders per unit ❌ 2000ms+ timeouts ❌ Blocking GPT load ❌ No fail-safe refresh ❌ Loading all ads on page load

9. Final Thoughts

Improving ad performance is not about hacks — it’s about engineering discipline.

The best-performing ad stacks:

  • Treat ads as async systems
  • Respect users first
  • Optimize auctions like distributed systems
  • Continuously measure and iterate

When done right, you get faster pages, happier users, and higher long-term revenue.

Andrei — Senior Frontend Engineer specializing in large-scale web applications, ad performance optimization, and scalable React architectures. andreilopatin.com, L*inkedin.*


메타데이터
post_id
71ce0ad1bbbc
slug
improving-ad-performance-on-modern-websites-a-practical-guide-with-prebid-gam-and-amazon-71ce0ad1bbbc
url
https://medium.com/@andrey93077/improving-ad-performance-on-modern-websites-a-practical-guide-with-prebid-gam-and-amazon-71ce0ad1bbbc
canonical_url
https://medium.com/@andrey93077/improving-ad-performance-on-modern-websites-a-practical-guide-with-prebid-gam-and-amazon-71ce0ad1bbbc
author_url
https://medium.com/@andrey93077
status
ok
fetched_at
2026-07-13 14:28:48