AMP offers two main components for analytics tracking: amp-pixel
, and amp-analytics
. With amp-pixel
, we can do simple pixel-tracking pageview analytics. If we want to do anything more advanced, such as click- or scroll-tracking, then we need to look at amp-analytics
.
The amp-pixel
component offers simple pixel-tracking analytics. It's a core component, so there's no need to include any script. With amp-pixel
you simply provide a URL that will register a pageview, for example:
<amp-pixel src="https://a.theampbook.com/?idsite=1&rec=1&action_name=TITLE&url=CANONICAL_URL&rand=RANDOM">
Note the following:
- The
src
attribute URL must be HTTPS enabled - Standard variable substitutions are supported, so
TITLE
,CANONICAL_URL
, andRANDOM
will all be replaced above
We'll see shortly that the amp-analytics
component has built-in support for Google Analytics, but if you wanted to keep things super-lightweight, and if you have...