Overview

We retired AMP support in Q4 of 2021, and will be removing this documentation at the end of March 2022. 

AMP — Accelerated Mobile Pages — is an open-source technology for creating fast-loading, beautiful, high-performing mobile web experiences. It is HTML, with some restrictions for reliable performance.

Twitter supports AMP in our mobile clients. When you publish a page with a linked AMP edition, we will present the best available version of your article to users. This helps people read more of your content through Twitter.

You can learn more about the AMP technology at ampproject.org.

How to publish AMP on Twitter

Follow the guides from the AMP Project to publish content using AMP, and ensure that your articles include the AMP discovery element.

Twitter supports the standard AMP discovery mechanism. When a link is shared on Twitter, the Twitter crawler (user agent: Twitterbot/1.0) will look for a <link rel="amphtml"> element in your document. If a valid AMP document is referenced, Twitter mobile clients will direct users to that AMP edition of your page.

For example, the link https://example.com/news/fast-bird-sighted is shared in a Tweet. Twitter crawls this page and extracts metadata for AMP, user account attribution, and for displaying Cards.

      <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Fast Bird Sighted — example.com</title>
  <link rel="amphtml" href="https://amp.example.com/amp/news/fast-bird-sighted">
  <!-- … -->
</html>
    

Now, when using one of Twitter's mobile clients, users will be sent to the amphtml URL in their browser, instead of the link that was shared in the Tweet. Users will load this link directly, not via a page cache.

Note: AMP versions of pages are not invoked from Promoted Tweets at this time.

Ensure your content is consistent

Twitter will redirect users to the AMP edition of the article in the same context and circumstance as the original link. If the content differs, you may confuse your readers.

You must ensure that the amphtml URL referenced by your article presents the same main content as your original page.

How to update AMP references in your articles

If your CMS changes, or if the wrong AMP URL is associated with a page by mistake, you must tell Twitter to recrawl your article page to reflect updates.

To do this, use the Card Validator tool. Enter the URL of your article and choose “Preview Card”. This will trigger a recrawl of your page. If the AMP reference has changed, Twitter's mobile clients will begin directing to the updated URL within approximately 5 minutes of previewing.

Understanding your AMP audience

The AMP specification requires that valid articles be loaded directly, not via any redirects. This helps articles load faster, with minimal network overhead.

However, this has a side-effect of bypassing some analytics tools that depend on HTTP redirects. Also, unique referral parameters added to shared URLs may not be present on the AMP platform. Twitter's implementation of AMP includes features to help ensure you can understand your audience on Twitter.

Original URL Ping

When users are presented with the optimized AMP version of your page, Twitter instructs the AMP runtime to also ping your original article URL. This allows your analytics software to record a visit as if the original article were viewed.

For these ping requests, Twitter appends an additional query parameter to your URL —  __twitter_impression=true — which you can use to distinguish these AMP views from organic traffic. (For example, to understand the impact of AMP on your audience, or filter these impressions if you already instrument AMP elsewhere.)

For example: The URL https://www.example.com/articles/peregrine-falcon-facts is shared on Twitter. It references a valid AMP edition. Twitter’s mobile clients will present the AMP edition directly, after which the AMP runtime will make a request to https://www.example.com/articles/peregrine-falcon-facts?__twitter_impression=true.

Advice for analytics tools and URL handling services

When implementing a publisher analytics tool, or any kind of link management service, you should include the __twitter_impression=true query parameter in redirects, so it can be consumed on next hop as well.

Advice for content management tools and publishing platforms

When receiving a request for an article including the __twitter_impression=true parameter, you should return an HTTP 204 response, with no response body. While a regular HTTP 200 response is valid, it is wasteful. You can improve performance and save your and your user's bandwidth by omitting it, the response body will be ignored by Twitter and the AMP runtime.

Social referral parameters within AMP

The AMP URL referenced in an article will be used explicitly by Twitter. Developers are encouraged to mirror referral or source context query parameters into the amphtml element to make them available in the AMP runtime.

To make this easier, the parameters from the original redirect link will be automatically exposed in the AMP environment, allowing you to consume them with the amp-analytics or amp-pixel components, via the QUERY_PARAM(foo,bar) platform variable, or ${queryParam(foo,bar)} analytics variable.

For example: The URL https://example.com/news/tracking-swift-migrations?utm_source=twitter&utm_medium=social is shared on Twitter, and has a corresponding AMP document https://amp.example.com/news/tracking-swift-migrations. The AMP runtime will automatically expose the utm_ parameters to the AMP runtime after the page loads. You can record utm_source=twitter and utm_medium=social through the amp-analytics component.


Note: Only parameters from the first-hop are included in this way. Parameters appended by subsequent redirects will not be accessible through AMP.