Ad code implementation
Implementation guide for AMP Auto ads (beta)
AMP Auto ads are ads that AdSense automatically places on your AMP pages. This guide shows you how to implement the AMP Auto ad code on your AMP pages.
<amp-auto-ads>ad code once on each page that you want to show AMP anchor and/or text and display ads.
Before you get started
- Prepare your pages for discovery with
<link>tags to pair non-AMP and AMP content.
<link>tags in the
<head>of each AMP and non-AMP page to indicate which content belongs together.
In the non-AMP example.com/news page:
<link rel="amphtml" href="http://example.com/amp/news">
In the AMP example.com/amp/news page:
<link rel="canonical" href="http://example.com/news">
If you host your AMP content on a separate site, you must add a
<link> tag to any non-AMP pages so AdSense can discover the related AMP pages.
How to implement AMP Auto ads
Follow the steps below for each page you want to display AMP Auto ads. After you’ve published your
<amp-auto-ads> ad code, AMP Auto ads will appear within a few minutes.
- Place the
amp-auto-adsscript in the
<head>of your page.
<title>My AMP Page</title>
- Place the
amp-auto-adsad code immediately after the opening
<amp-auto-ads type="adsense" data-ad-client="ca-pub-123456789123456"></amp-auto-ads>
Important: Make sure you replace ca-pub-123456789123456 in the code above with your own publisher ID.
- Only text and display ads are supported at this time.
- Amp Auto ads will show an appropriate number of ads based on the amount of content on your page, taking into account any hard-coded
<amp-ad>s you already have.
- Amp Auto ads will currently only show for users using a mobile device. Please test your site in a mobile device to see AMP auto ads.
How to track the performance of AMP Auto ads
You can track the performance of your AMP Auto ads by viewing the Ad behavior report on the Performance reports tab. AMP Auto ads are shown under the "AMP Auto banner ads" label in the report.