Hướng dẫn Cách Sửa Lỗi Link zalo.me/{sđt} trên Website

Tính đến ngày 07/10/2023, vấn đề liên quan đến việc truy cập link zalo.me/{sđt} trên các trang web vẫn chưa được giải quyết, gây ra sự phiền toái lớn cho lượng khách hàng của các trang web sử dụng liên kết này. Khi khách hàng nhấp vào liên kết để chat trên Zalo, họ không thể kết nối được, dẫn đến việc khách hàng rời khỏi trang web mà không thực hiện được chức năng mong muốn, điều này dẫn đến việc mất khách hàng.

Sau nhiều nỗ lực tham khảo và kiểm tra, Enweb đã tìm ra một giải pháp tạm thời cho vấn đề này, trong khi chờ đợi Zalo giải quyết. Dưới đây là hướng dẫn chi tiết để sửa lỗi link zalo.me/{sđt} trên website của bạn.

Hướng Dẫn Sửa Lỗi:

Bước 1: Tận Dụng Mã QR Code của Zalo

Trong giải pháp này, chúng ta sẽ sử dụng mã QR code của Zalo để truy cập trực tiếp Zalo App mà không thông qua trình duyệt web của Zalo. Điều này giúp tránh lỗi khi chuyển hướng từ liên kết zalo.me/{sđt} trên trình duyệt web.

Bước 2: Truy Cập Trực Tiếp Zalo App qua Deep Link

Thay vì chuyển hướng từ trang web, chúng ta sẽ sử dụng deep link để truy cập trực tiếp Zalo App. Deep link này sẽ mở Zalo App ngay lập tức và chuyển đến trò chuyện với số điện thoại tương ứng.

Ưu Điểm Của Giải Pháp Này:

  • Tương thích với mọi nút/link zalo.me/{sđt} trên các trang web đã có.
  • Không yêu cầu chỉnh sửa mã nguồn của nút/link Zalo đang được sử dụng trên trang web.
  • Hỗ trợ một hoặc nhiều số điện thoại Zalo trên trang web một cách linh hoạt.
  • Không cần tạo trang trung gian hoặc chuyển hướng qua các trang khác.
  • Hỗ trợ các thiết bị và hệ điều hành như iOS, Android, PC và các trình duyệt web chưa cài đặt ứng dụng Zalo.

Hướng Dẫn Chi Tiết:

1. Đoạn Mã Sửa Lỗi Link zalo.me/{sđt}

Dưới đây là đoạn mã JavaScript giúp giải quyết vấn đề trên:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
* Code sửa lỗi link zalo.me/{sđt}
* Author: levantoan.com
*/
var zalo_acc = {
        "sdtzalo1" : "mã qr code 1",
        "sdtzalo2" : "mã qr code 2",
    };
    function devvnCheckLinkAvailability(link, successCallback, errorCallback) {
        var hiddenIframe = document.querySelector("#hiddenIframe");
        if (!hiddenIframe) {
            hiddenIframe = document.createElement("iframe");
            hiddenIframe.id = "hiddenIframe";
            hiddenIframe.style.display = "none";
            document.body.appendChild(hiddenIframe);
        }
        var timeout = setTimeout(function () {
            errorCallback("Link is not supported.");
            window.removeEventListener("blur", handleBlur);
        }, 2500); // Đặt timeout (2.5 giây) để kiểm tra liên kết. Thay đổi số này lên 5000 nếu bạn chưa chạy được
        var result = {};
        function handleMouseMove(event) {
            if (!result.x) {
                result = {
                    x: event.clientX,
                    y: event.clientY,
                };
            }
        }
        function handleBlur() {
            clearTimeout(timeout);
            window.addEventListener("mousemove", handleMouseMove);
        }
        window.addEventListener("blur", handleBlur);
        window.addEventListener(
            "focus",
            function onFocus() {
                setTimeout(function () {
                    if (document.hasFocus()) {
                        successCallback(function (pos) {
                            if (!pos.x) {
                                return true;
                            }
                            var screenWidth =
                                window.innerWidth ||
                                document.documentElement.clientWidth ||
                                document.body.clientWidth;
                            var alertWidth = 300;
                            var alertHeight = 100;
                            var isXInRange =
                                pos.x - 100 < 0.5 * (screenWidth + alertWidth) &&
                                pos.x + 100 > 0.5 * (screenWidth + alertWidth);
                            var isYInRange =
                                pos.y - 40 < alertHeight && pos.y + 40 > alertHeight;
                            return isXInRange && isYInRange
                                ? "Link can be opened."
                                : "Link is not supported.";
                        }(result));
                    } else {
                        successCallback("Link can be opened.");
                    }
                    window.removeEventListener("focus", onFocus);
                    window.removeEventListener("blur", handleBlur);
                    window.removeEventListener("mousemove", handleMouseMove);
                }, 500);
            },
            { once: true }
        );
        hiddenIframe.contentWindow.location.href = link;
    }
    Object.keys(zalo_acc).map(function(sdt, index) {
        let qrcode = zalo_acc[sdt];
        const zaloLinks = document.querySelectorAll('a[href*="zalo.me/'+sdt+'"]');
        zaloLinks.forEach((zalo) => {
            zalo.addEventListener("click", (event) => {
                event.preventDefault();
                const userAgent = navigator.userAgent.toLowerCase();
                const isIOS = /iphone|ipad|ipod/.test(userAgent);
                const isAndroid = /android/.test(userAgent);
                let redirectURL = null;
                if (isIOS) {
                    redirectURL = 'zalo://qr/p/'+qrcode;
                    window.location.href = redirectURL;
                } else if (isAndroid) {
                    redirectURL = 'zalo://zaloapp.com/qr/p/'+qrcode;
                    window.location.href = redirectURL;
                } else {
                    redirectURL = 'zalo://conversation?phone='+sdt;
                    zalo.classList.add("zalo_loading");
                    devvnCheckLinkAvailability(
                        redirectURL,
                        function (result) {
                            zalo.classList.remove("zalo_loading");
                        },
                        function (error) {
                            zalo.classList.remove("zalo_loading");
                            redirectURL = 'https://chat.zalo.me/?phone='+sdt;
                            window.location.href = redirectURL;
                        }
                    );
                }
            });
        });
    });
    //Thêm css vào site để lúc ấn trên pc trong lúc chờ check chuyển hướng sẽ không ấn vào thẻ a đó được nữa
    var styleElement = document.createElement("style");
    var cssCode = ".zalo_loading { pointer-events: none; }";
    styleElement.innerHTML = cssCode;
    document.head.appendChild(styleElement);

Chú ý: Thay thế "sdtzalo1", "sdtzalo2" bằng số điện thoại Zalo tương ứng và mã QR code của chúng. Hãy đảm bảo rằng bạn đã thay thế đúng thông tin liên quan đến số điện thoại và mã QR code.

2. Hướng Dẫn Lấy Mã QR Code từ Zalo

  • Đăng nhập vào ứng dụng Zalo của bạn.
  • Nhấn vào biểu tượng quét mã QR ở góc trên bên phải màn hình.
  • Chọn “Mã QR của tôi” và tải xuống mã QR code.
  • Sử dụng ứng dụng quét mã QR hoặc camera trên điện thoại để lấy link QR code và mã tương ứng.

3. Hướng Dẫn Chèn Mã vào Website WordPress

Nếu bạn không biết cách chèn mã JavaScript vào website của mình, bạn có thể sử dụng các phương pháp sau:

Chèn vào functions.php của WordPress:

Các bạn có thể dùng code sau để chèn vào functions.php của theme đang kích hoạt nhé. Nhớ đổi thông tin cho đúng

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* Code sửa lỗi link zalo.me/{sđt}
* Author: levantoan.com
*/
add_action('wp_footer', 'devvn_fix_zalome', 999);
function devvn_fix_zalome(){
    ?>
    <script>
        var zalo_acc = {
            "sdtzalo1" : "mã qr code 1",
            "sdtzalo2" : "mã qr code 2",
        };
        function devvnCheckLinkAvailability(link, successCallback, errorCallback) {
            var hiddenIframe = document.querySelector("#hiddenIframe");
            if (!hiddenIframe) {
                hiddenIframe = document.createElement("iframe");
                hiddenIframe.id = "hiddenIframe";
                hiddenIframe.style.display = "none";
                document.body.appendChild(hiddenIframe);
            }
            var timeout = setTimeout(function () {
                errorCallback("Link is not supported.");
                window.removeEventListener("blur", handleBlur);
            }, 2500);
            var result = {};
            function handleMouseMove(event) {
                if (!result.x) {
                    result = {
                        x: event.clientX,
                        y: event.clientY,
                    };
                }
            }
            function handleBlur() {
                clearTimeout(timeout);
                window.addEventListener("mousemove", handleMouseMove);
            }
            window.addEventListener("blur", handleBlur);
            window.addEventListener(
                "focus",
                function onFocus() {
                    setTimeout(function () {
                        if (document.hasFocus()) {
                            successCallback(function (pos) {
                                if (!pos.x) {
                                    return true;
                                }
                                var screenWidth =
                                    window.innerWidth ||
                                    document.documentElement.clientWidth ||
                                    document.body.clientWidth;
                                var alertWidth = 300;
                                var alertHeight = 100;
                                var isXInRange =
                                    pos.x - 100 < 0.5 * (screenWidth + alertWidth) &&
                                    pos.x + 100 > 0.5 * (screenWidth + alertWidth);
                                var isYInRange =
                                    pos.y - 40 < alertHeight && pos.y + 40 > alertHeight;
                                return isXInRange && isYInRange
                                    ? "Link can be opened."
                                    : "Link is not supported.";
                            }(result));
                        } else {
                            successCallback("Link can be opened.");
                        }
                        window.removeEventListener("focus", onFocus);
                        window.removeEventListener("blur", handleBlur);
                        window.removeEventListener("mousemove", handleMouseMove);
                    }, 500);
                },
                { once: true }
            );
            hiddenIframe.contentWindow.location.href = link;
        }
        Object.keys(zalo_acc).map(function(sdt, index) {
            let qrcode = zalo_acc[sdt];
            const zaloLinks = document.querySelectorAll('a[href*="zalo.me/'+sdt+'"]');
            zaloLinks.forEach((zalo) => {
                zalo.addEventListener("click", (event) => {
                    event.preventDefault();
                    const userAgent = navigator.userAgent.toLowerCase();
                    const isIOS = /iphone|ipad|ipod/.test(userAgent);
                    const isAndroid = /android/.test(userAgent);
                    let redirectURL = null;
                    if (isIOS) {
                        redirectURL = 'zalo://qr/p/'+qrcode;
                        window.location.href = redirectURL;
                    } else if (isAndroid) {
                        redirectURL = 'zalo://zaloapp.com/qr/p/'+qrcode;
                        window.location.href = redirectURL;
                    } else {
                        redirectURL = 'zalo://conversation?phone='+sdt;
                        zalo.classList.add("zalo_loading");
                        devvnCheckLinkAvailability(
                            redirectURL,
                            function (result) {
                                zalo.classList.remove("zalo_loading");
                            },
                            function (error) {
                                zalo.classList.remove("zalo_loading");
                                redirectURL = 'https://chat.zalo.me/?phone='+sdt;
                                window.location.href = redirectURL;
                            }
                        );
                    }
                });
            });
        });
        //Thêm css vào site để lúc ấn trên pc trong lúc chờ check chuyển hướng sẽ không ấn vào thẻ a đó được nữa
        var styleElement = document.createElement("style");
        var cssCode = ".zalo_loading { pointer-events: none; }";
        styleElement.innerHTML = cssCode;
        document.head.appendChild(styleElement);
    </script>
    <?php
}

Chèn vào Trình chỉnh sửa mã nguồn của Theme Flatsome:

  • Vào Flatsome > Advanced > Global Settings > BODY SCRIPTS – BOTTOM
  • Dán đoạn mã JavaScript vào ô “BODY SCRIPTS – BOTTOM” và lưu lại.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<script>
    var zalo_acc = {
        //"sdtzalo" : "mã qr code"
        '09824154xx': 'hj8as2ynszxx',
    };
    function devvnCheckLinkAvailability(link, successCallback, errorCallback) {
        var hiddenIframe = document.querySelector("#hiddenIframe");
        if (!hiddenIframe) {
            hiddenIframe = document.createElement("iframe");
            hiddenIframe.id = "hiddenIframe";
            hiddenIframe.style.display = "none";
            document.body.appendChild(hiddenIframe);
        }
        var timeout = setTimeout(function () {
            errorCallback("Link is not supported.");
            window.removeEventListener("blur", handleBlur);
        }, 2500);
        var result = {};
        function handleMouseMove(event) {
            if (!result.x) {
                result = {
                    x: event.clientX,
                    y: event.clientY,
                };
            }
        }
        function handleBlur() {
            clearTimeout(timeout);
            window.addEventListener("mousemove", handleMouseMove);
        }
        window.addEventListener("blur", handleBlur);
        window.addEventListener(
            "focus",
            function onFocus() {
                setTimeout(function () {
                    if (document.hasFocus()) {
                        successCallback(function (pos) {
                            if (!pos.x) {
                                return true;
                            }
                            var screenWidth =
                                window.innerWidth ||
                                document.documentElement.clientWidth ||
                                document.body.clientWidth;
                            var alertWidth = 300;
                            var alertHeight = 100;
                            var isXInRange =
                                pos.x - 100 < 0.5 * (screenWidth + alertWidth) &&
                                pos.x + 100 > 0.5 * (screenWidth + alertWidth);
                            var isYInRange =
                                pos.y - 40 < alertHeight && pos.y + 40 > alertHeight;
                            return isXInRange && isYInRange
                                ? "Link can be opened."
                                : "Link is not supported.";
                        }(result));
                    } else {
                        successCallback("Link can be opened.");
                    }
                    window.removeEventListener("focus", onFocus);
                    window.removeEventListener("blur", handleBlur);
                    window.removeEventListener("mousemove", handleMouseMove);
                }, 500);
            },
            { once: true }
        );
        hiddenIframe.contentWindow.location.href = link;
    }
    Object.keys(zalo_acc).map(function(sdt, index) {
        let qrcode = zalo_acc[sdt];
        const zaloLinks = document.querySelectorAll('a[href*="zalo.me/'+sdt+'"]');
        zaloLinks.forEach((zalo) => {
            zalo.addEventListener("click", (event) => {
                event.preventDefault();
                const userAgent = navigator.userAgent.toLowerCase();
                const isIOS = /iphone|ipad|ipod/.test(userAgent);
                const isAndroid = /android/.test(userAgent);
                let redirectURL = null;
                if (isIOS) {
                    redirectURL = 'zalo://qr/p/'+qrcode;
                    window.location.href = redirectURL;
                } else if (isAndroid) {
                    redirectURL = 'zalo://zaloapp.com/qr/p/'+qrcode;
                    window.location.href = redirectURL;
                } else {
                    redirectURL = 'zalo://conversation?phone='+sdt;
                    zalo.classList.add("zalo_loading");
                    devvnCheckLinkAvailability(
                        redirectURL,
                        function (result) {
                            zalo.classList.remove("zalo_loading");
                        },
                        function (error) {
                            zalo.classList.remove("zalo_loading");
                            redirectURL = 'https://chat.zalo.me/?phone='+sdt;
                            window.location.href = redirectURL;
                        }
                    );
                }
            });
        });
    });
    //Thêm css vào site để lúc ấn trên pc trong lúc chờ check chuyển hướng sẽ không ấn vào thẻ a đó được nữa
    var styleElement = document.createElement("style");
    var cssCode = ".zalo_loading { pointer-events: none; }";
    styleElement.innerHTML = cssCode;
    document.head.appendChild(styleElement);
</script>

Sử dụng Plugin (Đối với người không biết lập trình):

Có một plugin được cung cấp để giải quyết vấn đề này. Bạn chỉ cần tìm và cài đặt plugin để giải quyết lỗi liên kết Zalo trên trang web của bạn.

Chúc bạn thành công! Nếu bạn có bất kỳ góp ý hoặc yêu cầu nào, hãy để lại bình luận dưới đây.