• About
    • History of Dallas SEO
    • SEO Expert Witness Services
  • 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
  • Email Newsletter

Bill Hartzer

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

SEMrush

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.

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

Filed Under: Google

SEMrush

About Bill Hartzer

Bill Hartzer is CEO of Hartzer Consulting, LLC, an SEO Consulting firm that includes services such as search engine optimization, technical SEO audits, domain name consulting, and online reputation management.

Recent Posts

  • dotDB is Not Shutting Down February 1, 2023
  • Someone Stole My Domain Name: Here’s What You Do January 4, 2023
  • Web Hosting Services Market to Grow to $254.86 Billion by 2029 December 13, 2022
  • This SEO Blog Post Was Written by ChatGPT December 8, 2022
  • Facebook Rolling Out Facebook Articles December 7, 2022
  • Doing SEO is Better Than… December 6, 2022
  • Tucows and GoDaddy Report Q3 2022 Results November 6, 2022
  • How to Measure App Events Sourced by Organic Search and SEO September 20, 2022
  • Google Allegedly Eavesdrops and Monitors the Brain 24 hours a Day to Control Humanity September 14, 2022
  • Why You Shouldn’t Hire SEOs Based on An Email September 13, 2022
  • Global SEO Market to Reach $122.11 Billion by 2028 September 9, 2022
  • Bluehost Launches New Commerce Solutions for WordPress September 8, 2022
  • Which CMS? How to Choose the Best CMS for Your Purposes August 29, 2022
  • Accidental SEO Manager: Interview with Ash Nallawalla August 15, 2022
  • Sometimes Google Isn’t Family Friendly August 1, 2022
  • Something’s Seriously Wrong with Facebook Notifications July 12, 2022
  • Facebook Internet Tracking Settlement June 24, 2022
  • RankSense Acquired by SEOClarity June 1, 2022
  • LinkedIn Links, Digital Marketing News, and SEO Questions Answered May 9, 2022
  • GoDaddy Ending Forwarding of Existing Shortened Links May 5, 2022

US Agency Awards Judge

DFWSEM logo

Bill Hartzer is a Brand Ambassador for:



Industry Friends

I Love SEO
WTFSEO
SEO By the Sea
Jeff Lenney
Jeff Gabriel
Phil Drinkwater
Dixon Jones
Brian Hartzer
Navah Hopkins

Connect With Bill Hartzer

Bill Hartzer on Twitter
Bill Hartzer on Instagram
Hartzer Consulting on Facebook
Bill Hartzer on Facebook
Bill Hartzer on YouTube

Categories

  • Advertising (19)
  • Bing Search Engine (6)
  • Blogging (42)
  • Branding (12)
  • Domain Names (210)
  • Google (236)
  • Internet Marketing (25)
  • Internet Usage (85)
  • Link Building (53)
  • Local Search (39)
  • Marketing (180)
  • Marketing Foo (30)
  • Pay Per Click (3)
  • Podcast (18)
  • Public Relations (8)
  • Reputation Management (9)
  • Search Engine Marketing (44)
  • Search Engine Marketing Events (48)
  • Search Engine Marketing Firms (19)
  • Search Engine Marketing Jobs (33)
  • Search Engine Optimization (164)
  • Search Engines (204)
  • Social Media (192)
  • Tech (7)
  • Web Analytics (17)
  • Webinars (1)

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.

Copyright © 2023 ·