gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 19:12:52 25 4
gpt4 key购买 nike

我正在尝试将漂移聊天服务功能添加到我的 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 的网站上运行?

谢谢。

最佳答案

原来这个评论是我需要做的 - https://stackoverflow.com/a/54835129/5443318

希望这对其他人有帮助。

 <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');
`,}}/>

关于javascript - 在 Gatsby 站点中集成 Drift 聊天服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58302405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com