Tagged: 

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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/&#8221; + 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 –>

    #1474042

    Hey 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,
    Ismael

    #1474053

    Thank 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

    #1474057

    Hi,

    You can compare Ismaels code to what you posted initially:

    drift.load('gyfkru6m6cb63');

    Best regards,
    Rikard

    #1474094

    Hi @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

    #1474099

    Hi,

    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,
    Rikard

    #1474108

    Thank 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

    #1474111

    Hi,

    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,
    Rikard

    #1474113

    Thank 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…

    #1474116

    I think I made it, thank you. Now it shows on the site.
    Kindest regards

    Antonio

    #1474120

    Hi,

    Great, I’m glad to hear that you got things working. Please let us know if you should need any further help on the topic, or if we can close it.

    Best regards,
    Rikard

    #1474140

    You can close the thread, thank you :)
    Merry Xmas

    Antonio

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Where/how to install JS correctly?’ is closed to new replies.