How to configure Yandex Metrika and Google Analytics Nuxt? Why the huge failure rate?

First used the plugin @nuxtjs/yandex-metrika

Then he wanted to connect to Google Analytics in the leadership Nuxt found code to connect.

Code GA:
export default ({ app }) => {
 if (process.env.NODE_ENV !== 'production') return;

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

 ga('create', 'UA-XXXXXX-X', 'auto');

 app.router.afterEach((to, from) => {
 ga('set', 'page', to.fullPath);
 ga('send', 'pageview');
})
}

Code YM:
export default ({ app }) => {

 if (process.env.NODE_ENV !== 'production') return;

(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
 m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
 (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");

 ym('XXXXXX', "init", {
clickmap:true,
trackLinks:true,
accurateTrackBounce:true,
 defer: true
});

 app.router.afterEach((to, from) => {
 ym('XXXXXX', 'hit', to.fullPath);
})
}

Connection code:
plugins: [
 { src: '~plugins/ga.js', mode: 'client' },
 { src: '~plugins/ym.js', mode: 'client' },
 ],

Visits are counted, and Yandex can not find the counter code, as evidenced by the red icon in the tab of all the counters

Also, the percentage of failures is huge - 40%. I have a website with the same theme (in PHP), so there failure rate is quite normal - from 8% to 12% on different days.

Comparing the facts I thought that the plugin is that this code just sends one-stage statistics, and further, very often there is simply a break of connection or I don't know how to explain what Yandex does not see the counter code and is the number of failures.

What would happen if a duplicate counter code in layouts Nuxt?

PS the refresh Button of the counter is clicked, instead of the XXXXX provided my data. (you never know)
April 3rd 20 at 18:24
1 answer
April 3rd 20 at 18:26
damn as a metric to incorporate normal???

Find more questions by tags Vue.jsNuxt.js