How to Implement Anchor Ads in AMP with Fallback and Ad Refresh via Google Ad Manager(GAM)
How to Implement Anchor Ads in AMP with Fallback and Ad Refresh via google ad manager gam

AMP (Accelerated Mobile Pages) is a popular framework for creating fast-loading, mobile-optimized web pages. One of the key features of AMP is its ability to serve ads efficiently while maintaining a seamless user experience. In this article, we’ll walk you through how to create sticky AMP ads at the bottom of the page using Google Ad Manager, as well as how to implement ad refresh, key-value targeting, and passback tags.

1. Creating Sticky AMP Ads at the Bottom of the Page

Sticky ads are ads that remain fixed at the bottom of the screen as the user scrolls through the content. To create a sticky AMP ad using Google Ad Manager, follow these steps:

Step 1: Set Up the AMP Ad Tag

First, create an AMP ad tag in Google Ad Manager. Here’s an example of how to define a sticky AMP ad:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<amp-sticky-ad layout="nodisplay">
<amp-ad width="320" height="50" type="doubleclick" data-slot="/1234567/amp_sticky_ad" data-multi-size="320x50,300x50" data-multi-size-validation="false" data-loading-strategy="prefer-viewability-over-views">
<div fallback="">No ad to display</div>
</amp-ad>
</amp-sticky-ad>
<amp-sticky-ad layout="nodisplay"> <amp-ad width="320" height="50" type="doubleclick" data-slot="/1234567/amp_sticky_ad" data-multi-size="320x50,300x50" data-multi-size-validation="false" data-loading-strategy="prefer-viewability-over-views"> <div fallback="">No ad to display</div> </amp-ad> </amp-sticky-ad>




No ad to display

2. Adding Ad Refresh to AMP Ads

Ad refresh allows you to reload ads after a specific time interval, which can help increase impressions and revenue. To enable ad refresh in your AMP ad tag, use the data-enable-refresh attribute:.

AMP Ad Refresh

AMP Ad Refresh allows Google Ad Manager slots to periodically fetch and display new ads.

Key Features:

Viewability-Based Refresh: Refresh requests are only triggered after the current ad has been viewed (50% of its pixels visible for one continuous second).
Page-Level Control:
Enable refresh for specific networks using the meta tag:
HTML

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<meta name="amp-ad-enable-refresh" content="network1=refresh_interval1,network2=refresh_interval2,...">
<meta name="amp-ad-enable-refresh" content="network1=refresh_interval1,network2=refresh_interval2,...">

refresh_interval: Time in seconds between refreshes (minimum 30 seconds).
Individual slots can be opted-out using data-enable-refresh=false.
Slot-Level Control:
Enable refresh for individual slots:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<amp-ad ...="" data-enable-refresh="refresh_interval"></amp-ad>
<amp-ad ...="" data-enable-refresh="refresh_interval"></amp-ad>

refresh_interval: Time in seconds between refreshes (minimum 30 seconds) or false to disable.
Compatibility:
Currently not supported for SRA-enabled slots.
Supported within amp-sticky-ad and amp-carousel containers.
Note: Refresh intervals begin only after the current ad is viewable.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<amp-sticky-ad layout="nodisplay">
<amp-ad width="320" height="50" type="doubleclick" data-slot="/1234567/amp_sticky_ad" data-multi-size="320x50,300x50" data-multi-size-validation="false" data-enable-refresh="30" data-loading-strategy="prefer-viewability-over-views">
<div fallback="">No ad to display</div>
</amp-ad>
</amp-sticky-ad>
<amp-sticky-ad layout="nodisplay"> <amp-ad width="320" height="50" type="doubleclick" data-slot="/1234567/amp_sticky_ad" data-multi-size="320x50,300x50" data-multi-size-validation="false" data-enable-refresh="30" data-loading-strategy="prefer-viewability-over-views"> <div fallback="">No ad to display</div> </amp-ad> </amp-sticky-ad>

  
      













No ad to display

3. Implementing Key-Value Targeting

Key-value targeting allows you to serve specific ads based on user behavior, demographics, or other criteria. To add key-value targeting to your AMP ad tag, use the json attribute:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<amp-ad width="320" height="50" type="doubleclick" data-slot="/4119129/mobile_ad_banner" json="{&quot;targeting&quot;:{&quot;sport&quot;:[&quot;rugby&quot;,&quot;cricket&quot;]},&quot;categoryExclusions&quot;:[&quot;health&quot;],&quot;tagForChildDirectedTreatment&quot;:1}">
</amp-ad>
<amp-ad width="320" height="50" type="doubleclick" data-slot="/4119129/mobile_ad_banner" json="{&quot;targeting&quot;:{&quot;sport&quot;:[&quot;rugby&quot;,&quot;cricket&quot;]},&quot;categoryExclusions&quot;:[&quot;health&quot;],&quot;tagForChildDirectedTreatment&quot;:1}"> </amp-ad>

4. Adding Passback Tags

Passback tags are used as a fallback mechanism when no ad is available from the primary demand source. To add a passback tag to your AMP ad, use the fallback attribute:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<amp-ad width="100vw" height="320" type="doubleclick" data-slot="/1234567/amp_sticky_ad" data-multi-size="320x50,300x50" data-multi-size-validation="false" data-enable-refresh="30" data-loading-strategy="prefer-viewability-over-views">
<div fallback="">
<amp-ad width="100vw" height="320" type="doubleclick" data-slot="/1234567/fallback_ad">
</amp-ad>
</div>
</amp-ad>
<amp-ad width="100vw" height="320" type="doubleclick" data-slot="/1234567/amp_sticky_ad" data-multi-size="320x50,300x50" data-multi-size-validation="false" data-enable-refresh="30" data-loading-strategy="prefer-viewability-over-views"> <div fallback=""> <amp-ad width="100vw" height="320" type="doubleclick" data-slot="/1234567/fallback_ad"> </amp-ad> </div> </amp-ad>





Tags:

©2025 AdTagMacros - Everything About Advertising

We improve our products and advertising by using Microsoft Clarity to see how you use our website. By using our site, you agree that we and Microsoft can collect and use this data. Our privacy statement has more details.

Log in with your credentials

Forgot your details?