Print

How to Create AdSense Link Ads in AMP

Accelerated Mobile Pages (AMP) is a standard for building mobile optimized pages that render very fast compared to regular pages.
If you’d like to show AdSense ads on your AMP pages, follow this tutorial to learn how to create AMP-compatible ad unit.

AMP pages are written in a specific form of HTML which is called AMP HTML. It’s like default HTML with some strict limitations.  AMP ad units require different ad tags from the usual AdSense tags which you already know.

You have several options to create an AMP ad with WP QUADS.

Create a 300 x 250 image / text ad

If you like to create a default 300 x 250 image / text ad just enable the AMP option in the ad code settings:

Create an AMP link / text ad

Creating an AMP link ad and not a regular image / text ad needs a little bit more effort.

Login to your AdSense account and create a new responsive ad unit.

Make sure the Ad type is set to Text ads only.
Create the ad code and write down the information from your responsive ad code:

  • Your publisher ID (data-ad-client), for example,
    ca-pub-1234567891234567.
  • Your ad unit’s ID (data-ad-slot), for example, 1234567890.

You’ll need these two values to generate AMP-compatible ad code.

Now use the following AMP ad code templates and fill in there your publisher ID and the ad unit ID.

Template 1 – AMP Ad Above the Fold

For ad placements that are above the fold, Google recommends that you use a fixed height AMP ad unit. For best results, fix the height of the ad unit as 100px and leave the width as responsive so it fits naturally with the rest of your page layout.

<amp-ad
layout="fixed-height"
height=100
type="adsense"
data-ad-client="ca-pub-1234567891234567"
data-ad-slot="1234567890">
</amp-ad>

Template 2 – AMP Ad Below the Fold

For ad placements that are mostly below the fold, Google recommends that you use a 300×250 responsive AMP ad unit. Using the AMP responsive layout option means your ad unit will automatically resize itself for the size of the device it’s being viewed on.

<amp-ad
layout="responsive"
width=300
height=250
type="adsense"
data-ad-client="ca-pub-1234567891234567"
data-ad-slot="1234567890">
</amp-ad>

Copy this code into the AMP custom ad code option below the AMP checkbox:

That’s it. If you like to customize the width and height of the text link ad you can customize the values to your need and play around with them.