I
I
Ivan Nesterovich2015-11-04 15:29:32
Ruby on Rails
Ivan Nesterovich, 2015-11-04 15:29:32

How to correctly configure Yandex.metrics to work with turbolinks?

There is a turbo link on the site, I inserted the metric code. But the statistics do not take into account internal transitions. The webview is the same - it shows that there was a click, but the page is not updated. Although everything works on the site and transitions occur.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Sidorov, 2015-11-05
@morr

I didn’t try the webvisor in the metric, but everything else is tracked like this:

$(document).on('page:before-change', function() {
  window.turbolinks_referer = location.href;
});

$(document).on('page:load', function() {
  if (window.turbolinks_referer) {
    // yandex metrika
    if (window.yaCounter7915231) {
      window.yaCounter7915231.hit(location.href, $('title').html(), window.turbolinks_referer);
    }
    // google analytics
    if (window.ga) {
      window.ga('send', 'pageview');
    }
  }
});

M
mystdeim, 2016-01-15
@mystdeim

Tell me, do you manage to reproduce user actions in your webvisor? I have such an error:
"It is impossible to reproduce the visit on this page. Possible reasons:
The counter code is not set .
A ban on displaying the page in the frame has been set."
I set 'X-Frame-Options' => 'ALLOWALL' in the header, but it still doesn't work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question