AMP (Accelerated Mobile Pages) is a way to build pages that render fast, almost instantly on mobile.
Accelerated mobile pages (AMP) are essentially stripped down HTML copies of existing webpage content that offer faster load times than standard HTML5 documents. Websites can serve AMP pages by implementing the rel=amphtml tag into their HTML.
From a technical point of view, pages with AMP code contain a three-step AMP configuration.
HTTPS is a prerequisite for using AMP. Indeed, when creating AMP pages and content, you should strongly consider using the HTTPS protocol (vs. HTTP). Although, HTTPS is not required for the AMP document itself or for images and fonts, there are many AMP features that require HTTPS (e.g., video, iframes, and more). To ensure your AMP pages take full advantage of all AMP features, use the HTTPS protocol. You can learn more about HTTPS in "Why HTTPS Matters".
Google has created its own tutorial to help you create AMP pages
The following markup is a decent starting point or boilerplate. Copy this and save it to a file with a .html extension.
<!doctype html>
<html amp lang="en">
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<title>Hello, AMPs</title>
<link rel="canonical" href="https://amp.dev/documentation/guides-and-tutorials/start/create/basic_markup">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"headline": "Open-source framework for publishing content",
"datePublished": "2015-10-07T12:02:41Z",
"image": [
"logo.jpg"
]
}
</script>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
</head>
<body>
<h1>Welcome to the mobile web</h1>
</body>
</html>
AMP HTML documents MUST:
RuleDescription
<!doctype html>
doctype.<html ⚡>
tag. (<html amp>
is accepted as well). It is a way for Google to Identify the page as AMP content.<head>
and <body>
tags (Optional in HTML but not in AMP)<meta charset="utf-8">
tag as the first child of their <head>
tag ( to identify the encoding for the page)<script async src="https://cdn.ampproject.org/v0.js"></script>
tag inside their <head>
tag. As a best practice, you should include the script as early as possible in the <head>
. It will load the AMP JS library.<link rel="canonical" href="$SOME_URL">
tag inside their <head>
. It will point to the regular HTML version of the AMP HTML document or to itself if no such HTML version exists. Learn more in Make Your Page Discoverable.<meta name="viewport" content="width=device-width,minimum-scale=1">
tag inside their <head>
tag. It's also recommended to include initial-scale=1
. It will specify a responsive viewport. Learn more in Create Responsive AMP Pages.<head>
tag. Tutorial HERE
Tutorial HERE
Tutorial HERE
Tutorial HERE
To verify if your AMP page is valid, here is another Google tool you can look at: https://search.google.com/u/1/test/amp?pageId=none
In some cases, you may need two versions (non-AMP and AMP) of the same page. To avoid duplicate content, add information about the AMP page on the non-AMP page and vice versa, using <link> tags in the <head> section as follows:
Add the following on the non-AMP page:
<link rel = "amphtml" href = "https://www.example.com/url/to/amp/document.html">And what follows on the AMP page:
<link rel = "canonical" href = "https://www.example.com/url/to/canonical/document.html">If you only have one page, and this page is an AMP page, you still have to add the canonical link, which in this case simply points to the page itself:
<link rel = "canonical" href = "https://www.example.com/url/to/canonical/document.html">If you do not really need a Google Analytics property or Google Analytics view dedicated to monitor your AMP pages, you'll need to change your tracking code in a way that does not use JavaScript directly.
We will modify the 'triggers' element by adding variables to it to allow it to define custom dimensions / metrics or other values such as the virtual URLs of pages.
The Google Analytics for AMP documentation that allow you to scan all cases.
Then at the beginning of the <body> tag, insert the following code:
<! - Google Tag Manager -><amp-analytics config = "https://www.googletagmanager.com/amp.json?id=GTM-XXXXX>m.url=SOURCE_URL" data-credentials = "include"> </ amp-analytics>Remember to replace in the above block the GTM-XXXXX with your GTM container ID.
There are several ways to classify your pages in Google Analytics.
==> In the admin/settings of your Google Analytics view, you go to the management of content groups.
Create a new AMP group that will contain 2 setups: AMP and No AMP.
Start with the 1st setup for Non AMP pages:
For the 2nd setup (AMP pages) we create the same setup as the previous one by replacing "does not contain" with "contains" and voila! Since this method does not require tagging, content groups are automatically populated by Google Analytics on every saved page view.
Thanks to this method, you can get segmented reports by content group value.
All we need now is to go back to Behavior > Site Content> All Pages and activate the Content Grouping option above the data table. Choose your AMP group and you will see 2 inputs: AMP and No AMP with a clear view of the performance of each type of page.
With these two entries in the content group, you can click the boxes on the left at the top of the line and click 'Draw lines' to see the performance of AMP pages compared to non-AMP pages.