• About Us
  • Contributors
  • Guides
  • Speaking Engagements
  • Write for The SEM Post
  • Submit a tip or contact us!
  • Newsletters

The SEM Post

Latest News About SEO, SEM, PPC & Search Engines

  • Google
  • SEO
  • Mobile
  • Local
  • Bing
  • Pay Per Click
  • Facebook
  • Twitter
  • State of the Industry
You are here: Home / Google / Analytics / How to Add Google Analytics to AMP Pages in Wordpress

How to Add Google Analytics to AMP Pages in WordPress

February 26, 2016 at 5:00 am PST By Jennifer Slegg

  • Facebook
  • Twitter
  • Google+
  • Pinterest
  • LinkedIn
  • Email
  • WhatsApp
  • Evernote
  • SMS

amp pages analyticsIf you have implemented the official AMP plugin for WordPress, you have probably discovered that the plugin strips out the Google Analytics code from all AMP pages.  But even though the plugin strips it out, AMP pages will still validate with Google Analytics code, but you need to add it manually.

First, make sure your AMP plugin is up to date, since the modifications can be stripped out when it is updated.

Next, select the Plugins option within the WordPress admin dashboard, then select Editor.  From the drop down on the right, select AMP, then hit the select button.

On the right hand sidebar you will see all the AMP related pages available for editing.  Towards the bottom you will find “amp/templates/single.php” and then click on it.

Scroll down to the end, then place your Analytics javascript code above the </body> tag.  Then choose the “update file” button and it will save your analytics code into your AMP pages.

Now visit any of your AMP pages and you should see the page you test in your Google Analytics.

wordpress amp1

For those questioning whether this is allowed, it does properly validate for AMP when you run it through the Structured Data Testing Tool.

wordpress amp2

This also means you can track just how popular (or not) the use of AMP is on your site.

For those who want to get really technical, Google Analytics has a lot more of the technical details on using Google Analytics on AMP pages.

  • Facebook
  • Twitter
  • Google+
  • Pinterest
  • LinkedIn
  • Email
  • WhatsApp
  • Evernote
  • SMS
The following two tabs change content below.
  • Bio
  • Latest Posts
My Twitter profileMy Facebook profileMy Google+ profileMy LinkedIn profile

Jennifer Slegg

Founder & Editor at The SEM Post
Jennifer Slegg is a longtime speaker and expert in search engine marketing, working in the industry for almost 20 years. When she isn't sitting at her desk writing and working, she can be found grabbing a latte at her local Starbucks or planning her next trip to Disneyland. She regularly speaks at Pubcon, SMX, State of Search, Brighton SEO and more, and has been presenting at conferences for over a decade.
My Twitter profileMy Facebook profileMy Google+ profileMy LinkedIn profile

Latest posts by Jennifer Slegg (see all)

  • 2022 Update for Google Quality Rater Guidelines – Big YMYL Updates - August 1, 2022
  • Google Quality Rater Guidelines: The Low Quality 2021 Update - October 19, 2021
  • Rethinking Affiliate Sites With Google’s Product Review Update - April 23, 2021
  • New Google Quality Rater Guidelines, Update Adds Emphasis on Needs Met - October 16, 2020
  • Google Updates Experiment Statistics for Quality Raters - October 6, 2020

Filed Under: Analytics, Google, SEO

Sign up for our newsletter


Comments

  1. B says

    February 28, 2016 at 2:57 pm

    I am disappointed to see that no mention was made of using AMP specific of highly optimized Analytics tracking code. Kinda pointless if you’re going to include the scripts they removed in the first place. https://developers.google.com/analytics/devguides/collection/amp-analytics/

    • Jennifer Slegg says

      February 29, 2016 at 9:56 am

      I did include that link in the article as well. Unfortunately, the learning curve for some is a little high, especially those who used the easy mode AMP plugin that didn’t require actually understanding how AMP works.

  2. B says

    February 28, 2016 at 5:30 pm

    Update to my previous comment (just saw it at the bottom). However it should be mentioned that it is important that that be the preferred snippet of code over the traditional excerpt.

Founder & Editor

Jennifer Slegg (2052)

Sign up for our daily news recap & weekly newsletter.


Follow us online

  • Facebook
  • Google+
  • Linkedin
  • Pinterest
  • Twitter

Latest News

2022 Update for Google Quality Rater Guidelines – Big YMYL Updates

We finally have the first Google Quality Rater Guidelines update of 2022, and like usual, it is … [Read More...]

Recent Posts

  • 2022 Update for Google Quality Rater Guidelines – Big YMYL Updates
  • Google Quality Rater Guidelines: The Low Quality 2021 Update
  • Rethinking Affiliate Sites With Google’s Product Review Update
  • New Google Quality Rater Guidelines, Update Adds Emphasis on Needs Met
  • Google Updates Experiment Statistics for Quality Raters
  • Analyzing “How Google Search Works” Changes from Google
  • Google Quality Rater Guidelines Update: New Introduction, Rater Bias & Political Affiliations
  • Google Updates Quality Rater Guidelines: Reputation for News Sites; Video Content Updates; Quality for Information Sites
  • Google Makes Major Changes to NoFollow, Adds Sponsored & UGC Tags
  • Google Updates Quality Rater Guidelines Targeting E-A-T, Page Quality & Interstitials

Categories

  • Affiliate Marketing
  • Amazon
  • Apple
  • Bing
  • Branding
  • Browsers
  • Chrome
  • Content Marketing
  • Design
  • Domains
  • DuckDuckGo
  • Email
  • Facebook
  • Firefox
  • Foursquare
  • Google
    • Analytics
    • Google RankBrain
    • Quality Rater's Guidelines
  • History of Search
  • Industry Spotlight
  • Instagram
  • Internet Explorer
  • Links
  • Local
  • Mobile
  • Native Advertising
  • Other Search Engines
  • Pay Per Click
  • Pinterest
  • Publishers
  • Security
  • SEO
  • Snapchat
  • Social Media
  • State of the Industry
  • The SEM Post
  • Tools
  • Twitter
  • Uncategorized
  • User Experience
  • Video Marketing
  • Week in Review
  • Whitepapers
  • Wordpress
  • Yahoo
  • Yelp
  • YouTube
March 2023
MTWTFSS
« Aug  
 12345
6789101112
13141516171819
20212223242526
2728293031 

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Copyright © 2023 · News Pro Theme On Genesis Framework · WordPress · Log in