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.
amp-pixel is a built-in component and does not require loading an extension.
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>
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>
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 src="https://ampbyexample.com/tracker/foo" layout="nodisplay" referrerpolicy="no-referrer"></amp-pixel>
If the explanations on this page don't cover all of your questions feel free to reach out to other AMP users to discuss your exact use case.Go to Stack OverflowAn unexplained feature?
The AMP project strongly encourages your participation and contributions! We hope you'll become an ongoing participant in our open source community but we also welcome one-off contributions for the issues you're particularly passionate about.Edit sample on GitHub
Written by @jmadler