• About
    • History of Dallas SEO
  • Contact
  • Topics
    • Bing
    • Blogging
    • Branding
    • Domain Names
    • Google
    • Internet Marketing
    • Link Building
    • Local Search
    • Marketing
    • Public Relations
    • Reputation Management
    • Search Engine Marketing
    • Search Engine Optimization
    • Search Engines
    • Social Media
  • Tech
  • Advertise
  • Services
    • Search Engine Optimization
    • Ongoing SEO Services
    • SEO Expert Witness
    • Google Penalty Recovery
    • Mini SEO Audit
    • Link Audit
    • Keyword Research
    • Combine Websites SEO Services
    • PPC Management
    • Online Reputation Management
    • Domain Name Consultant
    • Domain Names & Expired Domains
    • Domain Name Appraisal

Bill Hartzer

..
Home » Google » How to Install Google Analytics on AMP Pages

How to Install Google Analytics on AMP Pages

Posted on July 6, 2017 Written by Bill Hartzer

A while back I noticed an error in Google Search Console that was flagging Google Analytics code. The error looks like this:

Google amp error

As I mentioned in my post about the Google AMP pages error, on my site, this site, I want to track how many visitors are coming to my site’s AMP pages. Well, it turns out that there is, in fact, an answer to this problem.

Elena Legeros, a Google product specialist for Google News and the AMP Project, replied to my Tweet about the issue:

Hi Bill, you have to use @amphtml analytics code on AMP pages. Check out this doc on adding Google Analytics to AMP. https://t.co/IIPPDPzYiM

— Elena Legeros (@elenalegeros) July 6, 2017

Google AMP Error Google Analytics

In the Google Analytics Help section, there is a page that explains how to add AMP Analytics to your AMP pages. If you go to that help topic page, you’ll see the sample code and how to implement it in AMP.

Have questions on implementing AMP pages? Feel free to get in touch with me.

Jump To

Toggle
  • The Easy Version of Installing Google Analytics on AMP Pages
  • Related Posts

The Easy Version of Installing Google Analytics on AMP Pages

So, here’s the shorter version of how to install Google Analytics code on your AMP Pages. I’m using the WordPress AMP plugin, so you’ll need to edit one of the template files.

1. First, you’ll need to use the editor option in WordPress, or you’ll need to go to cPanel for your site and log in there.

2. Then, find the File Manager and find the Plugins directory, then the AMP directory. Look in Templates and you’ll see a file called single.php. It should be located here for most sites: public_html/wp-content/plugins/amp/templates/single.php

3. Once you’ve got that file open, and have the ability to edit it, look for the end of the “head” (just before / head).

4. Add the AMP analytics functionality to your page. This code:

5. Then, you can put put the AMP analytics code on your page (since it’s a short page I put it at the end of the page right after the end body tag. But you can put it, technically, in the head or anywhere else on the page.

The AMP analytics code sample is shown in the Google support doc here:
https://developers.google.com/analytics/devguides/collection/amp-analytics/

Or, you can view the source code of my AMP page (put /amp/ at the end of the URL of this post) and you’ll see the code. You’ll want to change your UA- number from my number to your number.

6. Finally, go ahead and test your AMP page URL to see if it’s valid code. Use Google’s AMP Test to test your page. It should look like this if it’s valid AMP code:

google amp test

Related Posts

  • Hackers Hijack Google Results: Bybit Exposes AI-Powered macOS Malware Targeting Claude Code Searches
  • Brandpoint: 60% of Google Searches End Without Clicks
  • Google’s New Discover Update Is Live
  • Google Is Shutting Down Its Dark Web Report
  • After Years of Resistance, Google Agrees to South Korea’s Strict Mapping Rules

Filed Under: Google

About Bill Hartzer

Bill Hartzer is the CEO of Hartzer Consulting and founder of DNAccess, a domain name protection and recovery service. A recognized authority in digital marketing and domain name strategy, Bill is frequently called upon as an Expert Witness in internet-related legal cases. He's been sharing his insights, expertise, and research here on BillHartzer.com for over two decades.

Bill Hartzer on Search, Marketing, Tech, and Domains.

Hartzer Domains

DFWSEM logo

 

 

Brand Ambassador for:

Majestic logo

Oncrawl logo

Industry Friends

  • David Daniels
  • WTFSEO
  • SEO By the Sea
  • Jeff Lenney
  • Jeff Gabriel
  • Scott Hendison
  • Dixon Jones
  • Brian Hartzer
  • Navah Hopkins
  • DNAccess
  • Hartzer on IT.com
  • Jason Olson

Connect With Bill Hartzer

  • Bill Hartzer on X
  • Bill Hartzer on BlueSky
  • Bill Hartzer on Instagram
  • Hartzer Consulting on Facebook
  • Bill Hartzer on Facebook
  • Bill Hartzer on YouTube

Recent Posts

  • Semrush Studied 1,094 ChatGPT Categories. The Number That Matters Is Not 53.7%.
  • Study: Home Service Companies That Track Profit Instead of Leads Get 38% More From Their Ad Spend
  • LinkedIn Reach Is Up 14% For Executives. The Same Report Says Organic Reach Is Collapsing.
  • The Dental SEO Playbook Is Changing: Identity Dental Marketing Releases AEO vs. SEO Study
  • Link Freedom Group Just Bet Tens of Millions on the Future of the Internet
  • The .ORG Impact Awards Just Named 35 Global Changemakers—and the Finalists Are Remarkable
  • Marlow Launches Its AI Software Builder
  • Brands Keep Killing Their Best Ads Too Early—New Agentio Report Says Here’s What They Should Do Instead
  • accessiBe Launches AI Accessibility Assistant
  • Viral Nation Launches AI Discovery as Brands Face a New Problem: Getting Recommended by AI
Note: All product names, logos, and brands are property of their respective owners. All company, product and service names used in this website are for identification purposes only, and are mentioned only to help my readers. All other trademarks cited herein are the property of their respective owners. Use of these names, logos, and brands does not imply endorsement.

  Hartzer Consulting

Website, Content, and Marketing by Hartzer Consulting, LLC.
Disclaimer - Privacy Policy - Terms of Use - AI Instructions - Entity Map

Copyright © 2026 ·