E
E
E2015-08-25 19:50:58
JavaScript
E, 2015-08-25 19:50:58

How to insert the Yandex.Metrica code into a react component?

The question is:
How to insert the Yandex.Metrica code into a react component, which in turn is rendered on the server on top of the meteor OO
In general, we have a meteor application on the backend, a frontend on react, which is rendered on the server via FlowRouter. I don't think it matters, but still. Tell me how you can insert without resorting to npm or what to read?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
E, 2015-08-25
@aylo

I asked the question myself, got an answer, which I already tried, tried again, everything worked out.
Well, in general, everything is simple, maybe it will be useful to someone:

ym() {
    return (
      "<script src='https://mc.yandex.ru/metrika/watch.js' type='text/javascript'></script>\
      <script type='text/javascript'>\
            try {\
                  var yaCounterXXXXX = new Ya.Metrika({\
                  id:XXXXX,\
                  clickmap:true,\
                  trackLinks:true,\
                  accurateTrackBounce:true,\
                  webvisor:true,\
                  trackHash:true\
                  });\
            } catch(e) { }\
      </script>"
    );
  },

And we call:
<div dangerouslySetInnerHTML={{__html: this.ym()}}/>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question