Hello Everyone
I was wondering how to add yandex metrica to self host site.
I did some search but i need more info
<!-- Yandex.Metrika counter -->
<script type="text/javascript" >
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
ym(MY-CODE, "init", {
clickmap:true,
trackLinks:true,
accurateTrackBounce:true,
webvisor:true,
ecommerce:"dataLayer"
});
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/MY-CODE" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->
My idea is edit the theme, or create a new component. in the Head
section because this is there instructions
/admin/customize/themes/1/common/head_tag/edit
When installing the tag in the site HTML code, place the code as close to the top of the page as possible. For example, within the or tags.
then i may serve the tag.js
from my S3 to avoid ads blockers. i know this is not good idea, they may change the tag.js
any time.
Is this the best way to do it?
Ali