nlr_p nlr_p - 1 year ago 47
HTML Question

How to include HTML tags in amphtml

This is my script tag when trying to add amp to it, validator says script tags are not allowed except in some cases.Can someone help me out please.

<script >
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
ga('create', 'UA-71734474-1', 'auto');
ga('send', 'pageview');


Answer Source

in amp, analytics are surrounded by extra tags

<amp-analytics type="googleanalytics" id="analytics1">


but google analytics do not generally take the same format

its's usually something like this

"vars": {
    "account": "UA-XXXXX-Y" //your ga number
  "triggers": {
    "trackPageview": {
      "on": "visible",
      "request": "pageview"

See the amp developers page for more info