amp-pixel
Introduction
amp-pixel
is a lightweight mechanism for measuring pageviews. It provides functionality similar to amp-analytics
, but only includes a single event (views), and offers fewer transport mechanisms and variables.
Setup
amp-pixel
is a built-in component and does not require loading an extension.
Basic usage
The amp-pixel
issues a simple GET request to the given URL and ignores the result. This is a fast way to track pageviews.
<amp-pixel src="https://ampbyexample.com/tracker/foo" layout="nodisplay"></amp-pixel>
Variable substitution
The variables noted in amp-var-substitutions will be interpolated in the URL as a way to capture some meaningful data.
<amp-pixel src="https://ampbyexample.com/tracker/foo?redirectTime=REDIRECT_TIME&sourceHost=SOURCE_HOSTNAME&viewer=VIEWER" layout="nodisplay"></amp-pixel>
Referrer Policy
The optional referrerpolicy
attribute allows you to strip the 'Referrer' header in the outbound HTTP request. Other values of referrerpolicy
that are valid for other tags (e.g. amp-img
) are not available for amp-pixel
.
<amp-pixel src="https://ampbyexample.com/tracker/foo" layout="nodisplay" referrerpolicy="no-referrer"></amp-pixel>
このページの説明でご質問のすべてを解消できない場合は、あなたの実際の使用事例について他の AMP ユーザーに問い合わせて話し合ってください。
Stack Overflow にアクセスする 説明されていない機能ですか?AMP プロジェクトでは皆さんの参加と貢献を強くお勧めしています!当社はオープンソースコミュニティに継続的にご参加いただくことを希望しますが、特に熱心に取り組んでいる問題があれば1回限りの貢献でも歓迎します。
GitHub でサンプルを編集する-
Written by @jmadler