Jump to content

IPS4 Как добавить IP в счетчик Яндекс Метрики на форум


Recommended Posts

Мы уже разобрали, как добавить счетчик Яндекс-Метрики на форум. Теперь о том, как сделать, чтобы Яндекс Метрика показывала IP-адреса посетителей. 

 

1. Зайдите в админке в файл, куда вы добавляли код счетчика, перед ним добавьте следующий код:

<!-- получаем ip адрес -->
<script type="text/javascript" src="https://www.l2.io/ip.js?var=userip"></script>

2. Добавьте строчку params:{'ip': userip} в код счетчика яндекс метрики, например:

 

Цитата

<!-- Yandex.Metrika counter -->
<script type="text/javascript" >
    (function (d, w, c) {
        (w[c] = w[c] || []).push(function() {
            try {
                w.yaCounter99999999 = new Ya.Metrika2({
                    id:99999999,
                    clickmap:true,
                    trackLinks:true,
                    accurateTrackBounce:true,
                    webvisor:true,
                    params:{'ip': userip}
                });
            } 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 = "https://mc.yandex.ru/metrika/tag.js";

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

 

3. Настройте в вебвизоре показывание "Параметров визита":

 

Вебвизор-параметры-визита.png
Включение показа IP в метрике

 

4. Подождите немного, теперь новые посетители будут показываться с IP в вебвизоре.


Если у вас код Яндекс Метрики в одну строчку и неясно куда совать код "params:{'ip': userip}", то в настройках метрики выберите тип кода в несколько строчек и заново скопируйте его в файл форума. Будьте внимательны, "params:{'ip': userip}" необходимо выделить запятой, которая ставится на строчке выше (типо перечисление через запятую).

Link to post
Share on other sites
 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Powered by Invision Community
Поддержка Invision Community в России

×
  • Create New...