【问题标题】:Is this the correct way to use Google Tag Manager for Gatsby这是为 Gatsby 使用 Google Tag Manager 的正确方法吗
【发布时间】: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


    【解决方案1】:

    这是 noscript 标签,它只对不运行 Javascript 的人显示。由于 Gatsby 是一个 Javascript 框架,没有 Javascript 的人将看不到您的网站,所以我有根据的猜测是,该插件的开发人员认为没有必要包含 noscript 标签(也是在没有 Javascript 的 GTM 中工作的唯一标签/事件是页面加载上的自定义图像标签,因此拥有它们通常没有多大意义)。

    我看不出这与 SEO 有什么关系。我认为你不需要这个。

    【讨论】:

      猜你喜欢
      • 2019-03-23
      • 1970-01-01
      • 2012-05-11
      • 2018-12-31
      • 2021-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多