• About
    • History of Dallas SEO
    • SEO Expert Witness Service
  • 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.

traffic analysis tools

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

How to Install Google Analytics on AMP Pages

Posted By Bill Hartzer on July 6, 2017at 5:27 pm

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

traffic analysis tools

Listen to "Digital Marketing with Bill Hartzer" on Spreaker.

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

  • Andrew Muller on Testing Google Ads Using Facebook Ads January 15, 2021
  • Mike Rhodes from Web Savvy On Google Ads January 8, 2021
  • How to Opt Out of Google Analytics December 16, 2020
  • Majestic Just Changed SEO and Linking Forever December 15, 2020
  • Yext Consumer Search Trend Predictions for 2020 December 8, 2020
  • SearchBox Launches SearchAI SmartSuggest, SearchAI Answers and SearchAI Personalization December 7, 2020
  • Google Poly is Shutting Down December 2, 2020
  • Domain Name Brokers Put FFF.com and HHH.com Domains Up for Sale December 1, 2020
  • Google Webmaster Tools Moves Twitter Account November 11, 2020
  • Email Deliverability, Setting Up DMARC, DKIM, and SPF on Your Domain October 29, 2020
  • The Bing Search Engine is Now Microsoft Bing October 6, 2020
  • Beck Power on Building Authority on Social Media and Repurposing Content October 2, 2020
  • Naira Perez on Paid Media, and an Intro to Social Paid Media, and Audiences September 17, 2020
  • Fake Birth Date Used on Google and Apple Accounts Is on Credit Report August 17, 2020
  • What is Bill Hartzer Disease? July 20, 2020
  • Web Host Agents Sending Fake Invoices for Website Hosting July 17, 2020
  • Duane Forrester On Search Intent and Internal Site Search July 9, 2020
  • Google Loses Blogspot.In Domain Name July 8, 2020
  • Peter Leshaw on In-House Digital Marketing and Dashboards for Reporting July 2, 2020
  • Mark Traphagen on Schema, Schema Tools, and On Page SEO Tools June 29, 2020

DFWSEM logo

Bill Hartzer is a Brand Ambassador for:



Industry Friends

WTFSEO
SEO By the Sea
Jeff Lenney
Jeff Gabriel
Phil Drinkwater
Dixon Jones

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 (197)
  • Google (228)
  • Internet Marketing (24)
  • Internet Usage (84)
  • Link Building (52)
  • Local Search (38)
  • Marketing (176)
  • Marketing Foo (30)
  • Pay Per Click (1)
  • Podcast (8)
  • Public Relations (8)
  • Reputation Management (9)
  • Search Engine Marketing (44)
  • Search Engine Marketing Events (47)
  • Search Engine Marketing Firms (19)
  • Search Engine Marketing Jobs (33)
  • Search Engine Optimization (156)
  • Search Engines (202)
  • Social Media (187)
  • Tech (7)
  • Web Analytics (16)




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 © 2021 by Bill Hartzer and Hartzer Consulting, LLC.

Disclaimer - Privacy Policy - Terms of Use
Go to mobile version