Utilisation du composant amp-analytics (googleanalytics)

<amp-analyticstype="googleanalytics"id="analytics1"><scripttype="application/json">{"vars":{"account":"UA-XXXXX-Y"// Replace with your property ID.},"triggers":{"trackPageview":{// Trigger names can be any string. trackPageview is not a required name."on":"visible","request":"pageview"}}}</script></amp-analytics>

Envoi de données à une URL spécifiée

<amp-analytics><scripttype="application/json">{"requests":{"event":"https://example.com/analytics?eid=${eventId}&elab=${eventLabel}&acct=${account}"},"vars":{"account":"ABC123"},"triggers":{"trackAnchorClicks":{"on":"click","selector":"a","request":"event","vars":{"eventId":"42","eventLabel":"clicked on a link"}}}}</script></amp-analytics>

Envoi de données à une URL spécifiée

<amp-analytics><scripttype="application/json">{"requests":{"event":"https://example.com/analytics?eid=${eventId}&elab=${eventLabel}&acct=${account}"},"vars":{"account":"ABC123"},"triggers":{"trackClickOnTwitterLink":{"on":"click","selector":"#tweet-link","request":"event","vars":{"eventId":"43","eventLabel":"clicked on a tweet link"}}}}</script></amp-analytics>