Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
642 views
in Q2A Core by

Hello here i have a code of Yandex metrica analytic (same like Google analitics), How can i install it on Q2A? Where i should place the code? It is just html code of JS, but i don't know how to place it in php theme?

I use Flat box theme.

Yandex metrics code:


<!-- Yandex.Metrika counter -->
<script type="text/javascript">
(function (d, w, c) {
    (w[c] = w[c] || []).push(function() {
        try {
            w.yaCounterXXXXXXXX = new Ya.Metrika({id:XXXXXXXX,
                    webvisor:true,
                    clickmap:true,
                    trackLinks:true,
                    accurateTrackBounce:true,
                    trackHash: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 = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js";

    if (w.opera == "[object Opera]") {
        d.addEventListener("DOMContentLoaded", f, false);
    } else { f(); }
})(document, window, "yandex_metrika_callbacks");
</script>
<noscript><div><img src="//mc.yandex.ru/watch/xxxxxxx" style="position:absolute; left:0px;" alt="Metrika" /></div></noscript>
<!-- /Yandex.Metrika counter -->

2 Answers

+2 votes
by
 
Best answer
The best solution is to go to the Admin > Layout page, and put it in one of the custom HTML boxes. Probably "Custom HTML in <head> section" is the best.
0 votes
by

Or you could use the Google Analytics plugin. It is basically the same, as with html box, but you could exclude admin's visits from the stats, if you'd like.

...