amp.dev icon indicating copy to clipboard operation
amp.dev copied to clipboard

boilerplate generator leaves out the opening tag for amp-analytics when Google is selected

Open adamread opened this issue 7 years ago • 0 comments

AMP boilerplate generator leaves out opening amp-analytics tag when Google Analytics is selected and does not replace the Tracking ID in the resulting code

  • Page link: https://amp.dev/boilerplate/

When selecting Google Analytics in the boilerplate generator, the opening amp-analytics tag is not inserted in to the resulting code.

i.e. the code produced is:

<script type="application/json">
    {
      "vars" : {
        "gtag_id": "",
        "config" : {
          "": {
            "groups": "default"
          }
        }
      }
    }
    </script>
    </amp-analytics>

There should be a line like <amp-analytics type="gtag" data-credentials="include"> inserted before the code currently being inserted.

Also, when the Tracking ID field is filled in, the code is not inserted into the code.

Generation for Adobe Analytics seems to do both of these things correctly.

The resulting code, when using the tracking ID UA-1234567-1, should be something like

<amp-analytics type="gtag" data-credentials="include">
  <script type="application/json">
    {
      "vars" : {
        "gtag_id": "UA-1234567-1",
        "config" : {
          "UA-1234567-1": {
            "groups": "default"
          }
        }
      }
    }
  </script>
</amp-analytics>

How do we reproduce the issue?

  1. Open the boilerplate generator.
  2. Select Google Analytics from the options under Analytics on the right of the page.
  3. Enter a value into the Tracking ID input field that is shown after selecting Google Analytics in step 2.

The issue can be seen using Chrome 73 on Linux and Android, as well as Firefox 60 on Linux.

adamread avatar Apr 16 '19 12:04 adamread