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.

Note that you only need to place the <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

For example, let's say you have a site and you host the AMP versions of each page under You'd add <link> tags in the <head> of each AMP and non-AMP page to indicate which content belongs together.

In the non-AMP page:
<link rel="amphtml" href="">

In the AMP page:
<link rel="canonical" href="">

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.

  1. Place the amp-auto-ads script in the <head> of your page.
       <script async 

    <title>My AMP Page</title>

  2. Place the amp-auto-ads ad code immediately after the opening <body> tag.

       <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.

Was this article helpful?
How can we improve it?