When Google rolled out its accelerated mobile pages (AMP) project last year, and Automattic came out with an AMP plugin for WordPress, I hopped onboard. One thing I wanted to see was how much AMP traffic I had, so I added Google Analytics to the AMP single.php template. A recent AMP update replaced that template, so I repeated the process. This time it didn’t take and I received an e-mail this morning from Google Webmaster that I was getting a lot of AMP errors.
When I went to check on it, I was getting errors but the Webmaster page didn’t help me figure out what they were. Instead, I had to use an AMP page test tool. Type in the URL of your normal page, and it will prompt you to test the underlying AMP page. In my case, I was getting a syntax error on most pages and it didn’t like the analytics code any longer.
Analytics and the AMP Plugin
I tried dropping in a variation of the analytics code, but even with that, it was warning that a script call was missing. This was new from last fall, and I couldn’t find a reference to this script anywhere:
<script async custom-element="amp-analytics"
Inserting it manually didn’t fix the error either. After poking around for awhile, I realized that the AMP plugin had a space for the information that I had previously embedded in the single.php template. Where previously, I’d put in:
now I would just put in the code without the <amp-analytics> and <script> tags. Go to the left menu from your Dashboard, select AMP, and Analytics, and fill out the form like this, so that the type is the same as in your amp-analytics tag and that the text in the main box starts (and ends) with braces:
See that UA-nnnnn-n? Make sure you put your own Google Analytics tracking ID code in there. This fixed the problem. When I retested the page, it came up trumps.
Missing Schema Elements
The test flagged that some schema.org metadata was missing as well. In particular, it said that I was missing a logo. What I can’t tell is whether this was something that has been broken since last fall, or if it’s a new problem. In any event, I searched for a plugin to fill the whole.
There are lots of SEO plugins that will provide schema.org metadata support but I wanted one simple. The Schema plugin from Hesham fit the bill. It comes with a couple of simple forms and enables you to designate, and upload, a logo as well as some other metadata elements. The logo is a 60px high by 600px wide image to go with your AMP pages. I’d just relied on the text label for my site in the past but that appears not to be acceptable now. I created a simple image and added it through the Schema plugin. When I retested the site, all of my error messages were gone.
There are complaints about the role of AMP and how it’s impacting web sites and traffic. For me, these issues aren’t as important. Most of the content on my site is stuff that reflects my own noodling around. If someone is able to find it better using mobile pages and it solves a question they had, all the better.