https://github.com/mpolinowski/amp_google_analytics
Accelerated Mobile Pages and Google Analytics
https://github.com/mpolinowski/amp_google_analytics
accelerated-mobile-pages amp-analytics amp-html analytics analytics-tracking google
Last synced: 6 months ago
JSON representation
Accelerated Mobile Pages and Google Analytics
- Host: GitHub
- URL: https://github.com/mpolinowski/amp_google_analytics
- Owner: mpolinowski
- Created: 2017-09-26T07:38:22.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-26T08:23:06.000Z (over 8 years ago)
- Last Synced: 2025-01-28T19:17:58.288Z (over 1 year ago)
- Topics: accelerated-mobile-pages, amp-analytics, amp-html, analytics, analytics-tracking, google
- Size: 352 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# How to add Google Analytics to your AMP Webpage
01. [Set up Google Analytics](#01-set-up-google-analytics)
02. [Tracking ID](#02-tracking_id)
03. [amp-analytics](#03-amp-analytics)
04. [Search Console](04-search-console)
05. [Search Console link to Google Analytics](05-search-console-link-to-google-analytics)
## 01 Set up Google Analytics
Create a Gmail account and log in to [Google Analytics](https://analytics.google.com). Open the admin panel and add a new property:
---

---
## 02 Tracking ID
Fill out the form and click to generate a Tracking ID - which will look something like this "UA-88888888-1":
---

---
## 03 amp-analytics
Now we need to add the [AMP Analytics](https://www.ampproject.org/docs/reference/components/amp-analytics) script to our website inside the \ tag:
```html
```
The tracking ID can now be implemented inside the \ tag of your AMP page, by adding the \ component:
```html
{
"vars": {
"account": "UA-88888888-1"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
}
}
}
```
## 04 Search Console
Now we want to link our new property to the [Search Console](https://www.google.com/webmasters/tools/search-analytics) to get access to reports (e.g. you get information about AMP Errors and general tips to improve your HTML structure /SEO) and a list of keywords that lead Google Search users to your website.
Go back Property Settings:
---

---
And scroll down to "Adjust Search Console":
---

---
Click on "Edit":
---

---
And add your new property to your Search Console (this page will **stay open in the background** and you will have to refresh it after you added your new property - **see final step**):
---



---
You will then be asked to download an HTML file and upload it to the public /root directory of your website - to verify your ownership. Click on Verify and you are DONE!
## 05 Search Console link to Google Analytics
Now return to the previous page (still open in the background), refresh and select your new property - then click save:
---


---
As seen above, your Property is now linked in Google Analytics and you will start to see search results in your reports.
It might take a while for crawling information and potential Error Reports to arrive - give it a month... You will be notified by email if something was found in the need of fixing.