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.
I spend many hours to find error reason, so I want to share it with other developers. I just remove extra space which I copied from their official page https://support.google.com/tagmanager/answer/9205783?hl=en, and it starts to work.
I just replace <script type="application/json ">
with <script type="application/json">