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.Metrika counter -->
<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");
</script>
<noscript>
  <div>
    <img src="//mc.yandex.ru/watch/XXXXXX?ut=noindex" style="..." alt="" />
    <img src="//mc.yandex.ru/watch/YYYYYY?ut=noindex" style="..." alt="" />
  </div>
</noscript>
<!-- /Yandex.Metrika counter -->

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