Tagged: Drift chat
-
AuthorPosts
-
December 19, 2024 at 10:19 pm #1474030
Hi there, I’m trying to install a chat on the site (I did it a few times on different sites a few years ago) but I can’t make it work now.
Can you please help me out, where can I add this Javascript in Enfold to make it work?
——————-
<!– 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(‘gyfkru6m6cb6’);
</script>
<!– End of Async Drift Code –>December 20, 2024 at 5:59 am #1474042Hey Antonio,
Thank you for the inquiry.
You can install a snippet plugin or use the wp_head hook.
Example:
function av_add_drift_code_to_head() { ?> <!-- 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('XXXXX'); </script> <!-- End of Async Drift Code --> <?php } add_action('wp_head', 'av_add_drift_code_to_head');
Make sure to update this line:
drift.load('XXXXX');
Best regards,
IsmaelDecember 20, 2024 at 10:55 am #1474053Thank you @Ismael,
may I ask what do you mean when you say: Make sure to update this line: drift.load(‘XXXXX’);
How should I updated it?
Thank you for your help
Antonio
December 20, 2024 at 12:32 pm #1474057Hi,
You can compare Ismaels code to what you posted initially:
drift.load('gyfkru6m6cb63');
Best regards,
RikardDecember 20, 2024 at 10:17 pm #1474094Hi @Rikard,
Thank you. I added the code as you explained yet the drift chat still doesn’t seem to show up.
I added the snippet via the WP Code snippet plugin but no success.Any idea what else could I do?
Thank you
December 21, 2024 at 9:57 am #1474099Hi,
If you are going to use that plugin then you would need remove the PHP code:
"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('XXXXX');
Best regards,
RikardDecember 21, 2024 at 3:14 pm #1474108Thank you @Rikard,
I did copy/paste the code you posted above and adjusted the las line with
drift.load(‘gyfkru6m6cb63’);
still nothing happens, the chat doesn’t show on the site.
What else could I do?
I add the site access admin in the private area below, in case you can see if I made any mistake there.
Thank you so much
Antonio
December 21, 2024 at 4:17 pm #1474111Hi,
Then I would suggest that you reach out to the authors of the code you are looking to use, or add it using the function that Ismael posted earlier.
Best regards,
RikardDecember 21, 2024 at 5:38 pm #1474113Thank you @Rikard,
I’d like to use the function that @Ismael posted earlier but I’m not sure if I’m doing it right or not :)
I installed a snippet (WP Code Snippet) plugin and copied Ismael’s code into a new snippet, then published it, but nothing happened.Alternatively, what is “use the wp_head hook” and how do I go about it/ how do I do it?
I’ll now try to add the code of another live chat service (tawk.to) to see if that show up or not and understand at this point if it’s a chat software issue, a mistake I’m making somewhere inside Enfold or…
December 21, 2024 at 9:44 pm #1474116I think I made it, thank you. Now it shows on the site.
Kindest regardsAntonio
-
AuthorPosts
- You must be logged in to reply to this topic.