index.tsx 819 B

1234567891011121314151617181920212223242526272829303132
  1. import Script from "next/script";
  2. import React from "react";
  3. const isDevelopment = process.env.NODE_ENV === "development";
  4. export const GoogleAnalytics = () => {
  5. if (isDevelopment) return null;
  6. return (
  7. <>
  8. <Script
  9. id="google-tag-manager"
  10. strategy="afterInteractive"
  11. src={`https://www.googletagmanager.com/gtag/js?id=G-JKZEHMJBMH`}
  12. />
  13. <Script
  14. id="gtag-script"
  15. strategy="afterInteractive"
  16. dangerouslySetInnerHTML={{
  17. __html: `
  18. window.dataLayer = window.dataLayer || [];
  19. function gtag(){dataLayer.push(arguments);}
  20. gtag('js', new Date());
  21. gtag('config', 'G-JKZEHMJBMH', {
  22. page_path: window.location.pathname,
  23. });
  24. `,
  25. }}
  26. />
  27. </>
  28. );
  29. };