Answer the question
In order to leave comments, you need to log in
Yandex.Metrika and react-router. How to decide?
The essence of the question is this: there is a SPA application, to which the code of the same metric with parameters is connected to the static index.html file:
new Ya.Metrika({
id:xxx,
clickmap:true,
trackLinks:true,
accurateTrackBounce:true,
webvisor:true,
trackHash:true
})
Answer the question
In order to leave comments, you need to log in
import { YMInitializer } from 'react-yandex-metrika';
class MyComponent extends React.Component {
render() {
return (
<div>
// SNIP
<YMInitializer accounts={[987654321]} />
// SNIP
</div>
);
}
});
// Потом подписываемся на событие истории и делаем что-то вроде:
import ym from 'react-yandex-metrika';
history.listen((location) => {
ym('hit', localhost.pathname);
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question