Monetize Premium
Back to Blog
Technical Implementation Guides

Ad Refresh Implementation: Technical Guide and Best Practices

Implement ad refresh strategies for increased revenue while maintaining user experience. Learn about viewability requirements, timing optimization, and technical implementation.

Michael Rodriguez
December 6, 2024(Updated: August 5, 2025)
12 min read
Ad Refresh Implementation: Technical Guide and Best Practices

Ad Refresh Implementation: Technical Guide and Best Practices

In the ever-evolving landscape of digital publishing, the quest for revenue maximization is a constant battle. Simply adding more ad units to a page is a strategy of diminishing returns, often leading to cluttered user experiences and lower overall ad performance. A more sophisticated and effective approach is to increase the value of existing ad inventory. This is where ad refresh, a powerful technique for dynamically loading new ads into existing slots without a full page reload, comes into play. When implemented correctly, ad refresh can significantly boost impressions, increase revenue, and capitalize on user engagement. However, a misstep can lead to policy violations, decreased advertiser trust, and a poor user experience.

This comprehensive guide will walk you through the technical intricacies and strategic best practices of implementing ad refresh. We'll cover everything from the non-negotiable viewability requirements and optimal timing strategies to detailed code examples and common pitfalls to avoid. By the end, you'll have a clear roadmap for implementing a smart, compliant, and profitable ad refresh strategy that enhances, rather than detracts from, your digital property.

The What and Why of Ad Refresh: A Modern Revenue Strategy

At its core, ad refresh (also known as ad auto-refresh) is the process of loading a new ad creative into an ad slot that is already on the page, based on specific triggers. Instead of one ad per slot for the entire duration of a page view, a single slot can serve multiple, sequential ads to an engaged user.

The business case for this is compelling. The industry is shifting its focus from the simple pageview to more meaningful metrics like "engaged time." A user might spend several minutes reading a long-form article, playing a game, or browsing a photo gallery. During this time, the initial ads served become "stale." Ad refresh allows you to capitalize on this sustained attention by serving fresh, relevant ads, effectively creating new impression opportunities on the same page.

Industry data supports this shift. For publishers with long user sessions, such as news sites, forums, and content-rich blogs, ad refresh can increase total ad impressions by 15-25% or more. This translates directly into a potential revenue lift. It's a method of working smarter, not harder, by making your most valuable, high-engagement pages work more efficiently for you.

However, the power of ad refresh comes with great responsibility. Major demand sources like Google have strict policies to prevent abuse. The entire strategy hinges on one critical factor: viewability.

The Cornerstone of Success: Viewability Requirements

Before you write a single line of code, you must understand and embrace viewability. An ad is considered "viewable" according to the IAB (Interactive Advertising Bureau) and MRC (Media Rating Council) standards when at least 50% of its pixels are in the user's viewport for at least one continuous second for display ads. For larger formats and video ads, the requirements can be stricter (e.g., 50% for two continuous seconds for video).

Why is viewability non-negotiable for ad refresh?

Refreshing an ad that the user cannot see is the cardinal sin of this practice. It's a fraudulent impression that provides zero value to the advertiser. Engaging in this practice will quickly damage your reputation, lead to clawbacks from demand partners, and can result in your account being penalized or banned by networks like Google AdSense/AdX.

Therefore, the golden rule is: Only refresh an ad slot when it is currently in view.

You can monitor your viewability using tools built directly into your ad server, such as Google Ad Manager's Active View reporting, or by employing third-party verification services. Before implementing refresh, you should have a firm grasp on which ad units on your site have high viewability rates. These are your prime candidates for a refresh strategy. Units with low viewability (e.g., footer ads) should almost never be refreshed.

Ad Refresh Strategies: Choosing Your Triggers

A successful ad refresh strategy is not a one-size-fits-all solution. It should be tailored to your content, user behavior, and revenue goals. The "trigger" is the event that initiates the refresh. Let's explore the most common strategies.

1. Time-Based Refresh

This is the simplest approach: an ad refreshes after a set period, such as every 30, 60, or 90 seconds.

  • Pros: Easy to implement and understand.
  • Cons: It's a "dumb" trigger. It doesn't account for user engagement. An ad could refresh on a tab that's open in the background, or while a user is idle on the page, which provides little value.
  • Best Practice: If using a time-based approach, set a conservative interval (60 seconds is a safer starting point than the absolute minimum of 30 seconds). More importantly, combine it with other triggers, as we'll see below.

2. User-Action Based Refresh

This strategy ties the refresh to specific user actions, which are strong indicators of active engagement.

  • Triggers: Clicking a navigation element, interacting with a photo gallery (e.g., clicking "next"), submitting a form, or even significant scrolling.
  • Pros: Ensures the user is active and paying attention to the page content when the refresh occurs, leading to higher-value impressions.
  • Cons: Can be more complex to implement. On some page types, these actions may not occur frequently enough to generate a significant number of refreshed impressions.

3. Event-Based Refresh (or Content-Change Refresh)

This is particularly relevant for modern web experiences like Single Page Applications (SPAs) or pages with infinite scroll.

  • Triggers: A new "page" or view loading within an SPA, new content being loaded via infinite scroll, or a new video playing in a playlist.
  • Pros: Perfectly aligns the ad refresh with the delivery of new content, which is a natural point for a user to see a new ad. This is often the best user experience.
  • Cons: Requires a more sophisticated technical implementation tied into your site's specific framework (e.g., React, Angular, Vue).

4. The Hybrid Approach (The Gold Standard)

The most effective and safest strategy combines the above elements. It creates a set of conditions that must all be met for a refresh to occur.

Example Hybrid Logic: Refresh an ad slot if:

  • At least 60 seconds have passed since the last ad was loaded in that slot.
  • AND the ad slot is currently viewable.
  • AND the user has been active on the page (e.g., moved their mouse or scrolled) in the last 20 seconds.

This hybrid model ensures you're not refreshing too frequently, you're only refreshing viewable ads, and you're only doing it when the user is actively engaged. This is the approach we strongly recommend.

Technical Implementation: A Practical Guide with GPT

For the vast majority of publishers, implementation will involve Google Publisher Tag (GPT). The following examples assume you are using GPT for ad serving.

Warning: Always consult the latest version of your ad network's policies before implementing ad refresh. Google's policies are particularly important to follow to the letter.

Step 1: The Basic GPT refresh() Function

The core of ad refresh in GPT is the pubads().refresh() function. You can call this function to trigger a new ad request for specific ad slots.

Here is a very basic, time-based implementation. Note: This example is for demonstration only and is NOT recommended for production as it lacks viewability and activity checks.

// Define your ad slot
let adSlot;
googletag.cmd.push(function() {
  adSlot = googletag.defineSlot('/1234567/your_ad_unit', [300, 250], 'div-gpt-ad-1234567-0').addService(googletag.pubads());
  googletag.enableServices();
  googletag.display('div-gpt-ad-1234567-0');
});

// Basic time-based refresh every 60 seconds
setInterval(function() {
  // IMPORTANT: This is a naive implementation.
  // Production code MUST check for viewability and user activity.
  googletag.cmd.push(function() {
    googletag.pubads().refresh([adSlot]);
  });
}, 60000); // 60000 milliseconds = 60 seconds

Step 2: Integrating Viewability (The Right Way)

GPT provides a powerful event, the ImpressionViewableEvent, which fires when an ad slot becomes viewable. We can use this to build a much smarter refresh logic.

// This is a more robust, viewability-aware implementation
googletag.cmd.push(function() {
  const adSlot = googletag.defineSlot('/1234567/your_ad_unit', [300, 250], 'div-gpt-ad-1234567-0').addService(googletag.pubads());
  
  // Refresh interval in milliseconds
  const REFRESH_INTERVAL = 60000;
  
  let refreshTimer;

  // Listen for the ImpressionViewableEvent
  googletag.pubads().addEventListener('impressionViewable', function(event) {
    const slot = event.slot;
    if (slot === adSlot) {
      // Slot is viewable, start a timer to refresh it
      console.log('Ad slot is viewable, starting refresh timer.');
      // Clear any existing timer to avoid multiple refreshes
      if (refreshTimer) {
        clearTimeout(refreshTimer);
      }
      refreshTimer = setTimeout(function() {
        console.log('Refreshing ad slot.');
        googletag.pubads().refresh([slot]);
      }, REFRESH_INTERVAL);
    }
  });

  // It's also good practice to clear the timer if the user navigates away
  // or the slot becomes non-viewable, though GPT's event listener is the primary control.

  googletag.enableServices();
  googletag.display('div-gpt-ad-1234567-0');
});

This is much better. The refresh is only scheduled after the ad becomes viewable.

Step 3: Adding User Activity Checks (The Gold Standard)

Now, let's build our hybrid model by adding a user activity check. We'll create a simple "idle timer" that tracks mouse movement and scrolling.

googletag.cmd.push(function() {
  const adSlot = googletag.defineSlot('/1234567/your_ad_unit', [300, 250], 'div-gpt-ad-1234567-0').addService(googletag.pubads());
  
  // --- User Activity Tracking ---
  let userIsActive = true;
  let activityTimeout;
  
  function setUserActive() {
    userIsActive = true;
    clearTimeout(activityTimeout);
    activityTimeout = setTimeout(() => {
      userIsActive = false;
      console.log('User is now idle.');
    }, 20000); // User considered idle after 20 seconds of inactivity
  }
  
  // Listen for activity events
  window.addEventListener('mousemove', setUserActive);
  window.addEventListener('scroll', setUserActive);
  setUserActive(); // Set user as active on page load

  // --- Ad Refresh Logic ---
  const REFRESH_INTERVAL = 60000; // 60 seconds
  let refreshTimer;

  function scheduleRefresh(slot) {
    console.log('Ad slot is viewable, scheduling refresh...');
    if (refreshTimer) {
      clearTimeout(refreshTimer);
    }
    refreshTimer = setTimeout(function() {
      // FINAL CHECK: Before refreshing, confirm user is still active
      if (userIsActive) {
        console.log('User is active. Refreshing ad slot.');
        googletag.pubads().refresh([slot]);
      } else {
        console.log('Refresh cancelled. User is idle.');
        // Optional: We can try to schedule the refresh again later
      }
    }, REFRESH_INTERVAL);
  }

  // --- GPT Event Listener ---
  googletag.pubads().addEventListener('impressionViewable', function(event) {
    if (event.slot === adSlot) {
      scheduleRefresh(event.slot);
    }
  });

  googletag.enableServices();
  googletag.display('div-gpt-ad-1234567-0');
});

This code combines all our best practices: it uses a reasonable time interval, it's triggered by viewability, and it performs a final check for user activity before initiating the refresh.

A Note on Header Bidding

If you're using a header bidding wrapper like Prebid.js, the process is more complex. You can't just call googletag.pubads().refresh(). Doing so would only request a new ad from Google Ad Manager, bypassing all your header bidding demand partners.

The correct process involves:

  1. Triggering your refresh logic (time, viewability, activity).
  2. Calling the Prebid.js function to request new bids for the specific ad unit(s) you want to refresh (e.g., pbjs.requestBids()).
  3. In the callback function when bids are received, passing the new targeting keys to Google Ad Manager.
  4. Finally, calling googletag.pubads().refresh() for those ad units.

This ensures a full, fair auction takes place for each refreshed impression, maximizing your yield.

Best Practices for Optimization and Profitability

Implementation is only half the battle. To truly succeed, you need to optimize and monitor your strategy continuously.

  • Start Small and A/B Test: Don't enable ad refresh across your entire site at once. Select a few pages with high user engagement and high ad viewability. Run an A/B test where 50% of users see the refreshed ads and 50% (the control group) do not.
  • Optimize Your Timing: 30 seconds is Google's minimum, but it's often too aggressive. Test longer intervals like 60, 90, or even 120 seconds. Slower refreshes can sometimes lead to higher overall CPMs as advertisers don't feel their ads are being cycled through too quickly.
  • Segment Your Inventory: Not all inventory is created equal. A "Contact Us" page with a 20-second average session duration is a terrible candidate for ad refresh. A 3,000-word article with a 7-minute average read time is a perfect candidate. Use your analytics to identify these opportunities.
  • Be Transparent with Buyers: Create separate ad units or use key-value targeting (e.g., refresh=true) to identify refreshed impressions in Google Ad Manager. This allows you to track their performance separately and gives buyers transparency, which builds trust. Some buyers may even specifically target or avoid refreshed inventory.
  • Monitor Core Metrics Relentlessly: After implementation, keep a close eye on your data. Our analytics guide can help you focus on the right metrics.
    • Viewability %: Did it go up or down?
    • CPM: Did the average CPM for the refreshed slots decrease? A slight dip is normal (the first impression is often the most valuable), but a major drop indicates your strategy is too aggressive.
    • CTR (Click-Through Rate): A significant drop in CTR can signal that users are experiencing "ad blindness" from seeing too many ads.
  • Prioritize User Experience (UX): A refreshed ad should never cause the content on your page to jump or shift. This is known as Cumulative Layout Shift (CLS) and is a negative Core Web Vitals signal that can harm your SEO. Ensure your ad slots have a fixed size. A comprehensive ad layout optimization strategy is crucial for success.

Common Mistakes to Avoid

Steer clear of these common pitfalls that can undermine your ad refresh efforts.

  1. Refreshing Non-Viewable Ads: We can't say it enough. This is the #1 mistake. It devalues your inventory and puts your accounts at risk. Always use a viewability-based trigger.
  2. Refreshing Too Frequently: An overly aggressive refresh cycle (e.g., every 30 seconds on every page) can lead to lower CPMs, poor UX, and potential policy flags. Respect the user's attention span.
  3. Ignoring User Experience: If your ad refresh is distracting, causes layout shifts, or plays auto-playing video/audio, you are creating a negative experience that will drive users away.
  4. A "Set It and Forget It" Mentality: Ad refresh is not a passive strategy. It requires ongoing monitoring, testing, and adjustment based on performance data and changes in user behavior.
  5. Disregarding Privacy Regulations: Each ad refresh is a new ad request. This means you must ensure that user consent signals (like those from a TCFv2 CMP) are respected for every single refresh call. Failing to do so can lead to violations of GDPR, CCPA, and other regulations. Staying informed about privacy regulations is essential for any modern publisher.
  6. Forgetting Mobile and In-App: The principles of ad refresh also apply to app monetization. However, the technical implementation differs, often relying on the capabilities of the mobile ad SDK and ad mediation platform. The core tenets of viewability and user engagement remain paramount.

Conclusion: Refresh Your Revenue, Responsibly

Ad refresh is a potent tool in a modern publisher's arsenal. It represents a strategic shift from monetizing pageviews to monetizing user attention. By transforming a single ad slot into a source of multiple, high-value impressions, you can unlock significant new revenue streams from your most engaging content.

However, this power demands a sophisticated and responsible approach. The path to success is paved with a commitment to viewability, a focus on the user experience, and a data-driven mindset of continuous testing and optimization. By implementing a hybrid refresh strategy that combines time, viewability, and user-activity triggers, you can build a system that is both profitable and sustainable.

Implementing ad refresh can feel complex, and getting it right is crucial. If you're looking for an expert partner to help navigate the technical challenges and develop a custom strategy that maximizes your revenue without compromising compliance or user trust, our team is here to help. We encourage you to contact our team to discuss your specific needs, or book a demo to see how our technology can streamline this process for you. To learn more about our full suite of publisher solutions, feel free to explore our solutions.

Tags

ad refreshviewabilityrevenue optimizationuser experience

Ready to Maximize Your Ad Revenue?

Join thousands of publishers who trust Monetize Premium to optimize their monetization strategy.