Adding Yandex Metrica counter to Discourse

I apologize for writing out of such stupidity, but my head is already boiling from this problem. I’ve tried a lot, but apparently I don’t know how to do it correctly.
I need to install the Yandex.Metrica counter code in the , but due to CSP it does not work. I tried to somehow configure Goofle Tags, but apparently I did everything wrong there too.

Please tell me step by step how I can do this. There are instructions from Yandex on this topic, but I’m stupid:

Here is the counter code that needs to be installed in :

<!-- 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(96239559, "init", {
        clickmap:true,
        trackLinks:true,
        accurateTrackBounce:true
   });
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/96239559" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->

You’ll likely need to allowlist the following URLs based on your code snippet:

The setting would be at https://YOUR-SITE-URL/admin/site_settings/category/security?filter=content%20security%20policy%20script%20src

3 Likes

I have now added these two links, but nothing has changed

UPD. Thank you. That helped. I just added more addresses.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.