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" >
   m[i].l=1*new Date();
   for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
   (window, document, "script", "", "ym");

   ym(96239559, "init", {
<noscript><div><img src="" 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.

1 Like

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