How can I enable event-based ad refresh?

Freestar tags usually come with an automatic 30-second refresh. The refresh is set to count up to 30 seconds as long as the browser tab is active and the ad is 50% or more in-view. For every second that these criteria are met, the counter will increment. Once the counter hits 30 seconds, the refresh event is triggered. This typically works great out of the box, but we can also account for instances where you want to refresh ads with other events that occur on the page such as a slideshow or perhaps after a video has ended. Below are two methods that can be used to trigger event-based refreshes.

Refresh One or More Ads

To keep viewability high, use the method described here to refresh specific ads that are in-view when the event happens. This keeps CPMs as high as possible by making the inventory more valuable to ad buyers.

The code below consists of a Javascript API call to the Freestar Pubfig.js. You are able to pass a string, or an array of strings, to this call. This event should only be triggered once in a 10 second time period because triggering it more often could devalue the ad slot. Please see below for some common best practices for slideshows/galleries with refresh enabled.

// Method one, passing a single slot through
freestar.freestarReloadAdSlot("ad_unit_1_300x250");

// Method two, passing multiple slots through
freestar.freestarReloadAdSlot(["ad_unit_1_300x250", "ad_unit_2_728x90"]);

Slideshow Suggestions

  • Always try to have the ads in-view when you call the refresh method. If the slideshow is scrolling or the layout changes based on screen size, you can use JavaScript logic to determine if an ad is in-view and only allow it to be refreshed if that is the case.
  • For navigation button triggers, we recommend you implement a pause in between the ad refresh so that the users are not able to just scroll through the entire gallery and cause you to miss out on the ads you are trying to monetize.
    • Discrepancies and revenue will be much better if you use a one (1) second delay before the user can click the “Next” button after an ad refresh is called.
  • Keeping the timing between an ad refresh to 10 seconds or more should keep the first few ad refreshed CPMs as high as possible. After a while, refreshed ads become less valuable based on the user’s session and cookie data.

Refresh All Ads

If all of the ads on the page are in-view, then you can use this method to easily reload all the ad slots on the page. This method has no params it will accept; it just simply refreshes all slots defined on the page.

// Refresh all ad slots on page
freestar.freestarReloadAllAdSlots();

Turn off Automatic Refresh

If you have an ad slot you don’t want the auto refresh to apply to, you can modify the ad tag html to accommodate. This might be useful if you want to turn off the refresh for ads that you are going to trigger your own refresh on. Below is an example of an Ad Tag we provide with refresh turned off. You can turn off refresh by adding the data refresh time attribute as shown in the example below. If you set that value to a negative number (like -1), it will disable the refresh.

<div align="center" id="ad_tag_1" data-refresh-time="-1">
<script data-cfasync="false" type='text/javascript'>
freestar.queue.push(function () { googletag.display('ad_tag_1'); });
</script>
</div>