• About
    • History of Dallas SEO
  • Contact
  • Topics
    • Domain Security and Recovery
    • GoDaddy
    • ICANN and New gTLDs
    • AI Search
    • Google Search Updates
    • Google Ads and PPC
    • Google Business Profile and Local Search
    • Online Reputation Management
    • 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

19 YearsSince 2007

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

  • Google Flags Google Analytics Code as Critical Error in AMP Pages
  • How to Make Your WordPress Site Google AMP Compatible
  • Should You Implement Google AMP?
  • Hackers Hijack Google Results: Bybit Exposes AI-Powered macOS Malware Targeting Claude Code Searches
  • Brandpoint: 60% of Google Searches End Without Clicks

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

Semrush 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

  • 1.2 Million Brand Posts Say Stop Opening Videos With a Question
  • Shoppers Can’t Spot Fake Stores. Retailers Have to Stop Them First
  • I Rebuilt Bruce Clay’s Search Engine Chart. Bing Feeds 11 Engines.
  • XYZ Applied for the .SEO Domain. The Price Will Decide Who Uses It
  • Goodfirms Says Organic Traffic Grew for 66.3%. Nobody Checked.
  • adMarketplace Says AI Chat Ad Conversions Rose 156%. From What?
  • ICANN Opens Comments on 1,606 New gTLDs. A Comment Is Not an Objection
  • LinkedIn Leads at 5.8%, but Vista Social’s Own Data Says Don’t Compare
  • The FBI Just Put SEO in a Ransomware Alert. Site Owners Should Listen
  • My GA4 Showed 215,440 Sessions. About 680 Were Real People.

Bill Hartzer

News and analysis on search, marketing, tech and domain names since 2001.

Hartzer Consulting

Topics

  • Google Search Updates
  • AI Search
  • Google Ads and PPC
  • Google Business Profile and Local Search
  • Domain Security and Recovery
  • ICANN and New gTLDs
  • GoDaddy
  • Online Reputation Management

Site

  • About Bill Hartzer
  • Contact
  • Services
  • Advertise
  • All Topics

Legal

  • Disclaimer
  • Privacy Policy
  • Terms of Use
  • Entity Map

Copyright 2026 by Bill Hartzer and Hartzer Consulting, LLC.

Website, Content, and Marketing by Hartzer Consulting, LLC.