在 Gatsby 站点中集成 Drift 聊天服务

Integrating Drift chat service within a Gatsby site

我正在尝试将 Drift 聊天服务功能添加到我的 Gatsby 网站。 Drift 教程指出在标签之间添加这段代码;

<!-- Start of Async Drift Code -->
<script>
"use strict";

!function() {
  var t = window.driftt = window.drift = window.driftt || [];
  if (!t.init) {
    if (t.invoked) return void (window.console && console.error && console.error("Drift snippet included twice."));
    t.invoked = !0, t.methods = [ "identify", "config", "track", "reset", "debug", "show", "ping", "page", "hide", "off", "on" ], 
    t.factory = function(e) {
      return function() {
        var n = Array.prototype.slice.call(arguments);
        return n.unshift(e), t.push(n), t;
      };
    }, t.methods.forEach(function(e) {
      t[e] = t.factory(e);
    }), t.load = function(t) {
      var e = 3e5, n = Math.ceil(new Date() / e) * e, o = document.createElement("script");
      o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + n + "/" + t + ".js";
      var i = document.getElementsByTagName("script")[0];
      i.parentNode.insertBefore(o, i);
    };
  }
}();
drift.SNIPPET_VERSION = '0.3.1';
drift.load('XYZXYZXYZXYZ');
</script>
<!-- End of Async Drift Code -->

但是我不确定在哪里添加它,因为我在我的项目中找不到标签。我的项目设置与此相同 - https://github.com/gatsbyjs/gatsby-starter-blog

我也知道 Drift 有一个 gatsby 插件,但我也不知道如何使用它。

我的问题是,我在哪里添加这个 javascript 以便它在我基于 gatsby 的网站上运行?

谢谢。

原来这个评论是我需要做的 -

希望这对其他人有帮助。

 <script
                  dangerouslySetInnerHTML={{
                      __html: `
            "use strict";

            !function() {
              var t = window.driftt = window.drift = window.driftt || [];
              if (!t.init) {
                if (t.invoked) return void (window.console && console.error && console.error("Drift snippet included twice."));
                              t.invoked = !0, t.methods = [ "identify", "config", "track", "reset", "debug", "show", "ping", "page", "hide", "off", "on" ],
                t.factory = function(e) {
                  return function() {
                    var n = Array.prototype.slice.call(arguments);
                              return n.unshift(e), t.push(n), t;
                            };
                }, t.methods.forEach(function(e) {
                                  t[e] = t.factory(e);
                }), t.load = function(t) {
                  var e = 3e5, n = Math.ceil(new Date() / e) * e, o = document.createElement("script");
                              o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + n + "/" + t + ".js";
                              var i = document.getElementsByTagName("script")[0];
                              i.parentNode.insertBefore(o, i);
                            };
                          }
                        }();
                        drift.SNIPPET_VERSION = '0.3.1';
                        drift.load('XYZXYZXYZ');
            `,}}/>