---
import { ANALYTICS } from '../consts';
const ym = ANALYTICS.yandexMetrika;
const ga = ANALYTICS.googleGtag;
---

{ym && (
  <script type="text/plain" data-cookieconsent="statistics" is:inline define:vars={{ ym }}>
    (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");
    window.ym(ym, "init", { clickmap:true, trackLinks:true, accurateTrackBounce:true, webvisor:true });
  </script>
)}
{ga && (
  <script type="text/plain" data-cookieconsent="statistics" is:inline src={`https://www.googletagmanager.com/gtag/js?id=${ga}`}></script>
)}
{ga && (
  <script type="text/plain" data-cookieconsent="statistics" is:inline define:vars={{ ga }}>
    window.dataLayer = window.dataLayer || [];
    function gtag(){ dataLayer.push(arguments); }
    gtag('js', new Date());
    gtag('config', ga);
  </script>
)}
