javascriptreloadadsadsensegoogle-dfp

Reload Adsense ads, or have to use DFP?


I've found a number of sites that explain how to make a DFP ad reload/refresh after 30-120 seconds, but none of them explain if it's possible to do with an Adsense ad.

I've tried DFP - it's very confusing compared to Adsense.

My current Adsense code:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- MYSITE- Responsive - #1 -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-123456789..."
     data-ad-slot="123456789"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

Solution

  • AdSense's TOS disallow the sort of automatic refreshing you're referring to. This does not mean that you cannot automatically refresh AdSense Tags programmatically. It does mean that you will almost certainly get banned for doing so.

    On the other hand, this behavior is allowed when using AdSense + Doubleclick for publishers (DFP). This documentation should point you in the right direction, and you'd want to call something like this to refresh your ads:

    googletag.pubads().refresh();

    The following tutorials should give you enough information to figure out how to use AdSense + DFP:

    1. General Tutorial #1 (Outdated, but still useful)
    2. General Tutorial #2 (Also outdated, but useful nonetheless)
    3. Linking AdSense + DFP (This doesn't work if you're using DFP for Small Business; instead, you'll just want to add you Adsense embed code as a third-party creative

    If you are adamant about automatically refreshing ads without DFP, you could do the following wrapped in a timer function:

    document.getElementById('FrameID').contentWindow.location.reload(true);

    Be advised: This will get you banned from AdSense if you are not using the service through DFP