Home » Guides » Google Adsense » How to Add Adsense AMP Auto ads to Your WordPress Site

How to Add Adsense AMP Auto ads to Your WordPress Site


The following guide shows you how to implement the Google Adsense AMP Auto ads. The feature is called AMP Auto ads – Text & display and it is easy to install on your WordPress website. Choose to do it using a plugin or not.

A new way to monetise your AMP pages. When you enable the feature in your Adsense Labs then text and display ads are placed on any AMP page that you’ve tagged with the AMP Auto ad code. Basically AMP Auto ads are ads that AdSense automatically places on your AMP pages.

Implement the AMP Auto ads without a plugin

First we show you how to implement the AMP Auto ad code on your AMP pages without a plugin.

Follow the steps below for each page you want to display AMP Auto ads. After you’ve published your AMP Auto ad code, ads will start appear within a few minutes.

You need to Copy and Paste the following AMP code snippets inside 2 different HTML sections of your AMP pages:

1. First, place the code below between the <head> and </head> tags of your AMP pages.

<script async custom-element="amp-auto-ads" src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js"></script>

2. Then place the code below immediately after the opening <body> tag.

<amp-auto-ads type="adsense" data-ad-client="ca-pub-123456789123456"></amp-auto-ads>

Remember to replace the ca-pub-123456789123456 with your own publisher ID.

Implement the AMP Auto ads using a plugin

First step is to install the plugin Ad Inserter – WordPress Ads Management with AdSense Header Integration
By Igor Funa

The plugin is available in free and paid versions. The free version is enough to get you started with Auto AMP ads. Google lists the Ad Inserter plugin as possible solution to place AdSense ad code into your WordPress site. Ad Inserter is the only WordPress plugin that can insert any code anywhere on the page.

You to create ad blocks and auto-insert each block multiple places. You can add it above, below or between post content etc. It is fairly easy to use and that’s why we recommend it.

Again there are two steps. Copy and Paste the following AMP code snippets inside 2 different HTML sections of your AMP pages using the plugin.

For the body code simply configure one block with adsense code

[ADINSERTER AMP]
<amp-auto-ads type="adsense" data-ad-client="ca-pub-123456789123456"></amp-auto-ads>

and set automatic insertion to Above Header. Inserting above the header needs special code processing and is available only when you enable Output buffering in the settings tab (tab * / General), this may not work with all themes. Again replace the ca-pub-123456789123456 with your own publisher ID.

Alternatively: you can pick Before post (if your theme does not support this position use Before content).

This position is not immediately after the <body> tag but is the topmost position available without modifying theme files. It should work normally.

Your ad block should look like this:

Last part is to place this code in between the <head> and </head> tags:

<script async custom-element="amp-auto-ads" src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js"></script>

Finally the image below shows when the code is inserted in the Header section of the Ad Inserter plugin:

Good to know about Amp Auto ads:

Only text and display ads are supported at the moment.
Any hard-coded AMP ads that you already have are taken into account.
Ads will only show when using a mobile device. So test your site on a mobile device.

Hope you found the post useful. Thanks for visiting our website.