$6.25

Can't add AMP Variable for Google Tag Manager

Ask a question+
3

I am using Google Analytics with Google Tag Manager for a website, I am trying to add a custom dimension for my AMP pages, I found solution for that https://support.google.com/tagmanager/answer/6164990?hl=en (Step 2) and for AMP pages I am using AMP variables as described here https://support.google.com/tagmanager/answer/9205783?hl=en.

<amp-analytics config="https://www.googletagmanager.com/amp.json?id=Tag Manager-XXXXXX;Tag Manager.url=SOURCE_URL" data-credentials="include">
  <script type="application/json ">
      {
          "vars" : {
              "type": "shoes",
              "color": "red"
          }
      }
  </script>
</amp-analytics>

But after adding AMP variables on my page I get AMP error “Custom JavaScript is not allowed” and Tag manager does not capture my variables.

sometimes the extra space inside the code can take a lot of time and energy :)

Arthur Dilanyan
add comment

1 Answer

2

I spend many hours to find error reason, so I want to share it with other developers. I remove extra space, which I copied from its official page, and it starts to work.
I just replace <script type="application/json "> with <script type="application/json">

add comment

Your Answer