How to: Refresh ads between slides

On long slideshows you may want to periodically refresh ads.  One way to do this is to trigger the ads to refresh when a user clicks the next button.

To refresh the ads between slides you will need to create a variable that listens for an event on the page, and use it with a rule to trigger a tag containing the refresh code.



First we need to create the variable.  The easiest way to do this is to create a new click type variable and specify the selector of the next arrow:



The more advanced version would be to create a DOMEvent type variable, which allows you to specify the type of event to listen for.  For our current example this is a click event, but you can use this to refresh on a variety of events.



Next we need to create the rule to store the variable.  Add a new activation rule with the variable we just created as the activation trigger.


You may also want to ensure you the ads do not refresh too quickly.  You can use the rate limiting option to specify a required amount of time before the ads refresh.



Now you can create the tag itself.  The tag code will be the googletag.pubads().refresh() call, which by default refreshes all ads on the page.  To increase viewability scores, you may want to only refresh the ad slots that will be onscreen during the slideshow.  In this case you would need a refresh call for each slot.  

Set the tag's activation rule to be the rule we created previously.


Finally set the tag to active and add it to your container.  You should see it start to function a few minutes after saving the change.

Have more questions? Submit a request


Please sign in to leave a comment.