import Script from "next/script"

const GoogleAnalytics = ({ ga_id }) => (
  <>
    <Script
      async
      defer
      strategy="afterInteractive"
      src={`https://www.googletagmanager.com/gtag/js? 
      id=${ga_id}`}
    ></Script>
    <Script
      id="google-analytics"
      defer
      strategy="afterInteractive"
      dangerouslySetInnerHTML={{
        __html: `
          window.dataLayer = window.dataLayer || [];
          function gtag(){dataLayer.push(arguments);}
          gtag('js', new Date());

          gtag('config', '${ga_id}');
        `
      }}
    ></Script>
  </>
)
export default GoogleAnalytics
