【发布时间】:2018-12-12 06:41:03
【问题描述】:
我最初只是添加了 Gatsby 谷歌标签管理器插件并将 GTM-XXXX 添加到我的配置中。但是我的 SEO 家伙说他想要这段代码在
的正文中<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
所以我将默认的 html.js 复制到 src 中,如下所示:$ cp .cache/default-html.js src/html.js 然后将此 jsx 放入 html.js 中
<body {...this.props.bodyAttributes}>
{this.props.preBodyComponents}
<div
key={`body`}
id="___gatsby"
dangerouslySetInnerHTML={{ __html: this.props.body }}
/>
{/* Google Tag Manager (noscript) */}
<noscript>
<iframe
src="https://www.googletagmanager.com/ns.html?id=GTM-XXXX"
height="0"
width="0"
style={{ display: 'none', visibility: 'hidden' }}
/>
</noscript>
{/* End Google Tag Manager (noscript) */}
{this.props.postBodyComponents}
</body>
我的 SEO 人员告诉我这样做是否正确?为什么 Google Tag Gatsby 插件不能单独工作?
【问题讨论】:
标签: javascript reactjs google-tag-manager gatsby