Ad OperationCodingGoogle Ad Manager

How to Refresh ad based on Scroll percentage?

Plenty of publishers want to increase the yield or revenue for their ads. So, they will decide to refresh ads but refreshing the ad will really increase revenue?

Will refreshing ad slot makes revenue?

No and Yes !!!

Why “No”?

Refreshing ad slot will increase impressions but negatively it will affect the viewabilty. If viewabilty is not good, then will directly affect the publisher revenue.

Also, refresh rate should adhere to the policy mentioned on the ADX or Adsense. Publisher should not refresh the ad slot within 30 seconds.

Why “Yes”?

Refreshing ad slot based on the specific interval is allowed. But this refreshing should be used on user trigger so that , you will not end up with the policy violation.

How it relates to “Yes”?

Refresh should be used on the specific ad slots like sticky ad units. Generally sticky ad units are always in a viewable area so that refreshing ad at the specific scroll percentage will definitely increase the Yield or Revenue to the publisher.

What is code for refreshing ad slot on scroll?

function getScrollPosition () {
var refreshed = false;  
var get_window_height = window.innerHeight || 
           document.documentElement.clientHeight ||
           document.body.clientHeight || 0;

var get_window_Yscroll = window.pageYOffset || 
           document.body.scrollTop ||
           document.documentElement.scrollTop || 0;

var get_doc_height = Math.max(
        document.body.scrollHeight || 0, 
        document.documentElement.scrollHeight || 0,
        document.body.offsetHeight || 0, 
        document.documentElement.offsetHeight || 0,
        document.body.clientHeight || 0, 
        document.documentElement.clientHeight || 0
    );

var get_scroll_percentage = Math.round((
        (get_window_Yscroll + get_window_height) / get_doc_height
    ) * 100);
  console.log(get_scroll_percentage);
  if((get_scroll_percentage >= 50)) {
    googletag.cmd.push(function() {
            googletag.pubads().refresh([TopLeaderboard]);
        });
    alert("Ad Refreshed");
    window.onscroll = null;
    
  }
    }

window.onscroll = function(){
  var p = getScrollPosition();
    
  }

To adjust percentage of scroll , change the value (50) in the code as below

get_scroll_percentage >= 50

See the working example Below

Hope this helps!!!. Thank You !!!

*The information contained in this post is for general information purposes only. The information is provided by How to Refresh ad based on Scroll percentage? and while we endeavor to keep the information up to date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services, or related graphics contained on the post for any purpose.

Enable Notifications OK No thanks