'use strict'; const mountGoogleAnalytics = (id) => { if (window.dataLayer && window.gtag) { return; } const gtagScript = document.createElement("script"); gtagScript.src = `https://www.googletagmanager.com/gtag/js?id=${id}`; gtagScript.async = true; document.head.appendChild(gtagScript); window.dataLayer = window.dataLayer || []; window.gtag = function() { dataLayer.push(arguments); }; gtag("js", new Date()); gtag("config", id); }; const index = ({ id }) => { if (process.env.NODE_ENV === "production" && id && typeof window !== "undefined") { mountGoogleAnalytics(id); } }; module.exports = index;