Ad

The Script Tag Contains Invalid JSON That Cannot Be Parsed On Custom AMP Pages

- 1 answer

I make custom AMP page on Laravel and today I got search console error: the script tag contains invalid json that cannot be parsed, but when I check on AMP validator, it shows that the code is valid.

Code:

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

After remove this code, I'm not getting warning and also sucessfully submit validation request.

Here is the URL: https://wordkosh.com/amp/english-hindi/administrator-meaning-hindi

Ad

Answer

I found the same error message and I solved by changing this:

<script type="application/json">

becomes..

<script type="application/ld+json">

Then submit validation request. This works for me.

Ad
source: stackoverflow.com
Ad