Long response to the first click of Yandex Metric

498 Views Asked by At

The site has Yandex Metric

<script type="text/javascript" data-skip-moving=true>
        (function (d, w, c) {
            (w[c] = w[c] || []).push(function() {
                try {
                    w.yaCounterXXXX = new Ya.Metrika2({
                        id:XXXX,
                        clickmap:true,
                        trackLinks:true,
                        accurateTrackBounce:true,
                        webvisor:true,
                        trackHash:true,
                        triggerEvent:true
                    });
                } catch(e) { }
            });

            var n = d.getElementsByTagName("script")[0],
                s = d.createElement("script"),
                f = function () { n.parentNode.insertBefore(s, n); };
            s.type = "text/javascript";
            s.async = true;
            s.src = "https://mc.yandex.ru/metrika/tag.js";

            if (w.opera == "[object Opera]") {
                d.addEventListener("DOMContentLoaded", f, false);
            } else { f(); }
        })(document, window, "yandex_metrika_callbacks2");
    </script>

The page loading is pretty fast, but the FIRST click is awfully long 1326ms Such a reaction to the first click is only on pages where there is a lot of everything (text, pictures, checkboxes). Here's what happens when you click screenshot

Most of the time it takes w.calcChildrenChecksum I already set false all options when calling Metrics and the ym-disable-clickmap classes I used. Nothing helped

1

There are 1 best solutions below

0
On

In general, reason of the problem is Webvisor 2.0. Because it works with full page. It is right, that w.calcChildrenChecksum loads processor if you page has a lot of elements in DOM. You can use another settings for Yandex.Metrika to solve the problem.

Try to use "Legacy code counter" and "Webvisor 1.0."

Example is here:

enter image description here

and here

enter image description here

I have got answer by Yandex.Support in russian language:

В большинстве случаев при правильной установке код Метрики загружается асинхронно и не должен существенно влиять на скорость загрузки сайта. Увеличение времени загрузки может наблюдаться для счетчиков, у которых включен Вебвизор 2.0. Специфика его работы требует полной обработки контента сайта и в некоторых случаях может выполняться медленнее. Если ваш сайт обладает множеством контентных элементов, вы можете переключиться на Вебвизор 1.0, выбрав галочку "Устаревший код счетчика" в Настройках: https://yandex.ru/support/metrica/general/counter-general.html#other. Не забудьте переустановить код счетчика Метрики на всех страницах сайта. Если вы не используете Вебвизор при анализе данных, удостоверьтесь, что он выключен и не вызывается в коде счетчика (код без строки webvisor:true). В свою очередь мы постоянно работаем над ускорением загрузки кода, и в следующих обновлениях кода счётчика представим более лёгкую версию.