javascript - Google Tag Manager noscript tag appears as string, why? (using react-gtm-module) - Stack Overflow

I use react-gtm-module to place the Google Tag Manager Tags in a reactnext.js app hosted with netlify.

I use react-gtm-module to place the Google Tag Manager Tags in a react/next.js app hosted with netlify.

The gtm script tag in the head renders perfectly. But the noscript tag in the body is rendered falsely with the iframe as string:

<body>
  <noscript>
    "
          <iframe src=".html?id=GTM-XXXXXXX&gtm_auth=&gtm_preview=&gtm_cookies_win=x"
            height="0" width="0" style="display:none;visibility:hidden" id="tag-manager"></iframe>"
  </noscript>
  ...
</body> 

react-gtm-module code:

import TagManager from 'react-gtm-module'
...
ponentDidMount(){
const tagManagerArgs = { gtmId: 'GTM-NCGQVKQ' }
TagManager.initialize(tagManagerArgs);
}

Has anybody an idea what might be the cause?

Thanks a lot!

I use react-gtm-module to place the Google Tag Manager Tags in a react/next.js app hosted with netlify.

The gtm script tag in the head renders perfectly. But the noscript tag in the body is rendered falsely with the iframe as string:

<body>
  <noscript>
    "
          <iframe src="https://www.googletagmanager./ns.html?id=GTM-XXXXXXX&gtm_auth=&gtm_preview=&gtm_cookies_win=x"
            height="0" width="0" style="display:none;visibility:hidden" id="tag-manager"></iframe>"
  </noscript>
  ...
</body> 

react-gtm-module code:

import TagManager from 'react-gtm-module'
...
ponentDidMount(){
const tagManagerArgs = { gtmId: 'GTM-NCGQVKQ' }
TagManager.initialize(tagManagerArgs);
}

Has anybody an idea what might be the cause?

Thanks a lot!

Share Improve this question edited May 20, 2020 at 16:15 aaRitsch asked May 20, 2020 at 8:00 aaRitschaaRitsch 831 silver badge6 bronze badges 2
  • Hi, could be great if you can post also how the piece of code where you insert the noscript gtm part. – Pierfrancesco Commented May 20, 2020 at 8:05
  • I just added it : ) – aaRitsch Commented May 20, 2020 at 16:15
Add a ment  | 

2 Answers 2

Reset to default 3

When scripting is enabled, the noscript element will only contain plain text. Try disabling JS in your browser, then the text in the noscript tag should be parsed as HTML

https://html.spec.whatwg/multipage/scripting.html#the-noscript-element

If your app is only on the client side (no server-side rendering involved), then the noscript part is useless and will never be triggered, since it is loaded using javascript and it is only meant in case javascript is disabled.

From the package's README:

Disabling javascript in the browser can prevent the correct operation of this library if React is only being rendered on the client side.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744325406a4568625.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信