Track ad views
Within AMPHTML ads, you can track metrics by using the amp-pixel
or amp-analytics
components. In our basic sample, we'll add the ability to track pageviews with the amp-pixel
component and point to a URL that logs the pageviews (in this case, a fictious URL):
<body> <a target="_blank" href="https://www.amp.dev"> <amp-img width="300" height="250" alt="Learn amp" src="/static/img/docs/ads/amp-300x250.png"></amp-img> </a> <amp-pixel src="https://www.amp.dev/tracker/foo"></amp-pixel> </body>
That's it, you've created your AMPHTML ad!
Before uploading your ad to your ad server, there's one last step you should take—ensuring your syntax is valid.