Adding Yandex Metrica counter to Discourse

AI-generated summary

In a support thread titled ‘Adding Yandex Metrica counter to Discourse’, Gonerdot seeks help installing the Yandex.Metrica tracking code in the section, which fails due to Content Security Policy (CSP) restrictions. After sharing the code snippet and a link to Yandex’s CSP documentation, nat advises adding the URLs https://mc.yandex.ru/metrika/tag.js and https://mc.yandex.ru/watch/96239559 to the CSP script-src allowlist via the site settings. Gonerdot initially reports no change after adding those URLs, but later confirms in an update Gonerdot that the issue was resolved after adding additional domains to the allowlist, as shown in a screenshot. The thread demonstrates a common CSP configuration challenge when integrating third-party tracking scripts into 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

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

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