Content Marketing, Marketing & Sales Videos, Mobile and Tablet Marketing, Organic Search, Publishing, Search Marketing, User Experience, WordPress

Accelerated Mobile Pages are a Must, But Don’t Forget Analytics!

Mobile SEO

to This last month I’ve been working with a client that’s seen a noticeable decline in organic search traffic over the last year. We’ve fixed quite a few issues with the site that could impact rankings; however, I was missing one key factor in reviewing their analytics – Accelerated Mobile Pages (AMP).

What is AMP?

With responsive websites becoming the norm, the size and speed of mobile sites is greatly impacted, often slowing down the sites and providing user experiences that aren’t uniform. Google developed AMP to correct this, significantly pairing down the pages to have a similar look and feel and significantly less size; therefore, providing a similar user experience and outstanding page speed for organic search engine users. It’s a format that competes with Facebook Instant Articles and Apple News.

Sites with AMP configured are seeing three to five times the organic traffic they were seeing without the format  Tweet This!, so I highly recommended that you integrate AMP immediately. Some people were complaining that AMP sites are displayed via Google’s URL on a mobile device, something that could negatively impact linking and sharing. Google has responded by offering a direct link to the article as well. I honestly believe the benefits far outweigh the risks.

If you’re utilizing WordPress, Automattic released a very robust WordPress AMP plugin that outputs the appropriate format and applies the necessary permalink path. As an example, you’ll see that this article is at:

https://martech.zone/accelerated-mobile-pages/

And the AMP version of the article is available at:

https://martech.zone/accelerated-mobile-pages/amp/

I implemented AMP quickly on my site and many of my clients, but neglected to notice one critical issue. The AMP plugin didn’t support third-party Analytics integrations like Google Analytics. So, like my client, we were getting quite a bit of organic traffic going to our AMP pages but not seeing any of that traffic in Google Analytics. The decline we were seeing wasn’t a decline at all, it was just Google indexing and displaying our AMP pages instead. Very frustrating!

How to manually implement Google Analytics with WordPress AMP

The difficult means of implementing Google Analytics with AMP is to add code in your theme’s functions.php file that inserts the necessary JavaScript in your header and the call to Google Analytics in the body of your AMP page. Your header script:

add_action('amp_post_template_header','amp_custom_header');
function amp_custom_header($amp_template) {
?>
<script async custom-element="amp-analytics"
src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
<?php
}

Then your body script for adding your call to Google Analytics (be sure to replace UA-XXXXX-Y with your analytics account identifier:

add_action('amp_post_template_footer','amp_custom_footer');
function amp_custom_footer($amp_template) {
?>
<amp-analytics type="googleanalytics">
<script type="application/json">
{
"vars": {
"account": "UA-XXXXX-Y"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
}
}
}
</script>
</amp-analytics>
<?php
}

How to easily implement Google Analytics with WordPress AMP

The easier way to implement Google Analytics with WordPress AMP is to utilize the following three plugins:

  1. WordPress AMP
  2. Yoast SEO
  3. Glue for Yoast SEO & AMP

The Glue for Yoast SEO & AMP plugin let’s you both modify the look and feel of your AMP output as well as add the Analytics code snippet (above for the body) directly into the plugin settings.

Glue Yoast SEO AMP Analytics

How to Test Your AMP Page

Once you’ve fully implemented AMP, be sure to utilize Google’s AMP Test to ensure you don’t have any format issues.

Test my AMP Page

Your result of testing should be:

Valid AMP Page

Download a Sponsored Marketing Whitepaper:
How to Increase Your SEO Traffic in 30 Days

How to Increase Your SEO Traffic in 30 Days

Step up your SEO game with this 30-day planner. Download Now

This site uses Akismet to reduce spam. Learn how your comment data is processed.