Notice about collecting statistics

You can notify your site users that statistics will be collected, and defer loading the code snippet for the Yandex.Metrica tag on site pages.

If the user agrees to have information transmitted, the code snippet loads normally. Without the user's consent, the snippet won't load. The user's one-time choice can be applied to all the other pages on the site or domain.

To enable the alert and implement delayed loading of the code snippet, contact your webmaster.

  1. Alert example
  2. Example of implementing an alert about collecting statistics

Alert example

You can use any text to inform users of statistics collection. We recommend using the text written by Yandex legal experts.

This website uses Yandex.Metrica web analytics provided by YANDEX LLC, 16, Leo Tolstoy St., Moscow, 119021, Russia (hereinafter referred to as the “Yandex”).

Yandex.Metrica uses “cookies,” small text files placed on users’ computers to analyze user activity.

Information collected by cookies does not reveal your identity, but it can help us to improve our website performance. Information about your use of this website collected by cookies will be transferred to Yandex and stored on Yandex’s server in the EU and the Russian Federation. Yandex will process this information to assess how you use the website, compile reports for us on our website operation, and provide other services. Yandex processes this information as specified in the Terms of Use of Yandex.Metrica Service.

You can stop using cookies be making relevant adjustments in browser settings. You can also use the tool https://yandex.com/support/metrika/general/opt-out.html. However, it can affect some website functions. By using this website, you agree that Yandex can process your data in the above manner and for the above purposes.

Example of implementing an alert about collecting statistics

Example of code implementation:

...
<head>
    <meta charset="UTF-8">
    <title>Page title</title>
    <!--This example uses the reset.css style. You can use your own approach.-->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
    <!--The example uses the js-cookie library for working with cookies. You can use your own approach-->
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.2/js.cookie.js"></script>
    <style>
        * {
            box-sizing: border-box;
        }
        body {
            width: 100%;
            height: 100%;
        }
        .cookie-notification {
            position: fixed;
            background-color: rgba(0, 0, 0, .8);
            bottom: 0;
            width: 100%;
            color: white;
            padding: 15px;
        }
        .cookie-notification_hidden_yes {
            display: none;
        }
        .cookie-notification__header {
            margin-bottom: 10px;
            font-size: 23px;
        }
        .cookie-notification__body {
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
    Контент сайта
    <div class="cookie-notification cookie-notification_hidden_yes">
        <div class="cookie-notification__header">Мы используем Яндекс.Метрику</div>
        <div class="cookie-notification__body">
            <p>This site uses the Yandex.Metrica web analytics service provided by the company Yandex, 16 Lev Tolstoy street, Moscow, Russia 119021</p>
	     <p>The Yandex.Metrica service uses "cookie" technology, which consists of small text files placed on users' computers for the purpose of analyzing user activity levels.</p>
            <p>The information collected using cookies does not identify you. However, it can help us improve how our site functions. Information about your use of this website collected by cookies will be transferred to Yandex and stored on Yandex’s server in the EU and the Russian Federation. Yandex will process this information to assess how you use the website, compile reports for us on our website operation, and provide other services. Yandex processes this information in the manner prescribed in the Yandex.Metrica terms of use.</p>
<p>You can refuse to use cookie files by choosing the corresponding settings in your browser. You can also use the tool https://yandex.com/support/metrika/general/opt-out.html. However, this might affect how some of the site features work. By using this site, you agree to allow Yandex to process data about you in the manner and for the purposes described above..</p>
        </div>
        <div class="cookie-notification__buttons">
            <button class="cookie-notification__button" id="yes">I agree</button>
        </div>
    </div>
    <script type="text/javascript">
        var messageElement = document.querySelector('.cookie-notification');
        // If there aren't any cookies, show a placeholder
        if (!Cookies.get('agreement')) {
            showMessage();
        } else {
            initCounter();
        }
        // Load the code snippet immediately
        (function (d, w) {
            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/watch.js";
            if (w.opera == "[object Opera]") {
                d.addEventListener("DOMContentLoaded", f, false);
            } else { f(); }
        })(document, window);
        // This function adds the class to the DOM element. You can use the jQuery library or another framework
        function addClass (o, c) {
            var re = new RegExp("(^|\\s)" + c + "(\\s|$)", "g");
            if (!o || re.test(o.className)) {
                return;
            }
            o.className = (o.className + " " + c).replace(/\s+/g, " ").replace(/(^ | $)/g, "");
        }
        // This function removes the class from the DOM element. You can use the jQuery library or another framework.
        function removeClass (o, c) {
            var re = new RegExp('(^|\\s)' + c + '(\\s|$)', 'g');
            if (!o) {
                return;
            }
            o.className = o.className.replace(re, '$1').replace(/\s+/g, ' ').replace(/(^ | $)/g, '');
        }
        // Function that hides the alert.
        function hideMessage () {
            addClass(messageElement, 'cookie-notification_hidden_yes');
        }
        // Function that shows the alert.
        function showMessage () {
            removeClass(messageElement, 'cookie-notification_hidden_yes');
        }
        function saveAnswer () {
            // Hide the alert.
            hideMessage();

            // Set cookies.
            Cookies.set('agreement', '1');
        }
        function initCounter () {
            (function (w, c) {
                function _createCounter () {
                    try {
                        w.yaCounterXXXXXX = new Ya.Metrika({
                            id:XXXXXX,
                            clickmap:true,
                            trackLinks:true,
                            accurateTrackBounce:true,
                            webvisor:true
                        });
                    } catch (e) {}
                }
                // If the code snippet has loaded, initialize the tag immediately.
                if (w.Ya && Ya.Metrika) {
                    _createCounter();
                } else {
                    // Otherwise, use the standard approach.
                    (w[c] = w[c] || []).push(function () {
                        _createCounter();
                    });
                }
                saveAnswer();
            })(window, "yandex_metrika_callbacks");
        }
        // Clicked the "I agree" button.
        document.querySelector('#yes').addEventListener('click', function () {
            initCounter();
        });
    </script>
</body>
...

where

  • XXXXXX is your tag ID.