Ads on AMP pages
Before you can put ads on AMP pages you need to know what AMP is. The AMP Project is an open-source initiative aiming to make the web better for all. The project enables the creation of websites and ads that are consistently fast, beautiful and high-performing across devices and distribution platforms. Web pages and ads published in the AMP open-source format load near instantly, giving users a smooth, more engaging experience on mobile and desktop.
Therefore, for AMP pages you need different ad codes. Ad Inserter supports insertion of ads on AMP pages, just make sure you are using ad codes for AMP and you have properly configured the plugin for ads on AMP pages as described below.
Use AMP validator to check if your AMP pages are valid.
The following AMP plugins have been tested with Ad Inserter:
- AMP for WP – Accelerated Mobile Pages (free, please check the warning below)
- AMP (free)
- WP AMP Ninja (free)
- Better AMP – WordPress Complete AMP (free)
- WP AMP – Accelerated Mobile Pages for WordPress (paid – you need to uncheck Remove third-party the_content hooks for better compatibility)
Ad Inserter can insert ads also on AMP pages. However, if you configure the plugin to insert wrong codes that are not designed for AMP pages, such codes may cause AMP validation errors. To prevent such errors AMP for WP – Accelerated Mobile Pages plugin provides extension AMPforWP Plugin Manager which can disable specific WordPress plugins on AMP pages in order to prevent validation errors. However, for Ad Inserter this is not required as you only need to configure it properly so on AMP pages only valid AMP code will be inserted. Please read this page and make sure you are inserting only valid AMP codes on AMP pages.
When you see warning notice AMPforWP Plugin Manager disabled Ad Inserter on AMP pages this only means that on AMP pages Ad Inserter will not be called to insert codes. You need to make sure that Ad Inserter is configured to insert only AMP codes on AMP pages and then you can go to AMPforWP Plugin Manager settings, uncheck Ad Inserter and click on Save Changes.
Ads on AMP pages
Ad Inserter is compatible with AMP pages and most AMP plugins and can insert ads also on AMP pages. However, AMP pages require different code for AMP ads. Read this page and make sure you are inserting only valid AMP codes on AMP pages.
Normally the code will not be inserted on AMP pages. There are two settings that can be used to insert code on AMP pages:
1. AMP pages checkbox (button Misc / tab Insertion) – If checked it enables insertion also on AMP pages.
Use this approach only if you need to insert the same code on normal and AMP pages. To insert different codes on AMP pages (e.g. for AdSense) leave AMP pages unchecked and use
[ADINSERTER AMP] separator as described below.
2. Separate the codes with
[ADINSERTER AMP] separator – the code above the separator will be inserted on normal pages, the code below the separator will be inserted on AMP pages. This separator can be used also for Header and Footer code.
You can use AdSense code generator to generate AdSense AMP code described below. Check also AdSense guide to creating AMP-compatible ad code
Example for AdSense ads on AMP pages:
Generating AdSense code for AMP pages
Ad Inserter has a simple code generator for AdSense ads which can be used also to generate AdSense code for AMP pages. Check AdSense impementation guide for details.
Paste normal AdSense code into the code window, click on Code tools button, then on Code generator button and then click on the Import code button to import the AdSense data from it.
AdSense ads need also a script in the header.
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
Put AMP head script in the Header code block, use
[ADINSERTER AMP] separator (the code above the separator will be inserted on normal pages, the code below the separator will be inserted on AMP pages), and enable header code (button with green dot next to PHP button).