Answer the question
In order to leave comments, you need to log in
How to add counter scripts to React pages?
It is necessary to integrate several services into react and react-narive applications. The instructions provide for adding scripts to each page.
For example, the code
<script>(function(w, d, s, p) { var f = d.getElementsByTagName(s)[0], j = d.createElement(s); j.async = true; j.src = '//cdn.rutarget.ru/static/tag/tag.js'; f.parentNode.insertBefore(j, f); w[p] = {rtgNoSync: false, rtgSyncFrame: true}; })(window, document, 'script', '_rtgParams');</script>
var _rutarget = window._rutarget || [];
_rutarget.push({'event': 'showOffer'});
Answer the question
In order to leave comments, you need to log in
1. Add a script to the html template to which the application is attached.
2. We initialize an empty array at the entry point:
3. We use it in any part of the application:
You can write your own wrapper:
window._rutarget = [];
const AdService = {
showOffer() {
window._rutarget.push({'event': 'showOffer'});
},
};
export default AdService;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question