Installing multiple tags on a site

Sometimes you may need to put multiple tags on a page at once. In this case, it is preferable not to duplicate the entire tag initialization code. It is better to group the code for creating all objects of the Ya.Metrika class inside the try ... catch section, using the complete code of one of the tags as a template. Similarly, you can put the image insertion code that is used when JavaScript is disabled inside a single noscript element.

<!-- Yandex.Metrikatag -->
<script type="text/javascript">
    (function (d, w, c) {
        (w[c] = w[c] || []).push(function() {
            try {
                w.yaCounterXXXXXX = new Ya.Metrika({id: XXXXXX});
                w.yaCounterYYYYYY = new Ya.Metrika({id: YYYYYY, webvisor: true});
            } catch(e) { }

    })(document, window, "yandex_metrika_callbacks");
    <img src="//" style="..." alt="" />
    <img src="//" style="..." alt="" />
<!-- /Yandex.Metrika tag -->

Here XXXXXX and YYYYYY are the numbers of Yandex.Metrica tags.