diff --git a/elcri.men/gatsby-browser.js b/elcri.men/gatsby-browser.js index 5066bd60..1373a782 100644 --- a/elcri.men/gatsby-browser.js +++ b/elcri.men/gatsby-browser.js @@ -26,3 +26,22 @@ // // ) // } + +import React from 'react'; + + +export const onRouteUpdate = ({ location }) => { + if (process.env.NODE_ENV !== 'production') { + return null; + } + + const pagePath = location ? location.pathname + location.search + location.hash : undefined; + + setTimeout(() => { + if (typeof window.gtag === 'function') { + window.gtag('event', 'page_view', { page_path: pagePath }); + } + }, 100); + + return true; +}; diff --git a/elcri.men/src/components/Footer.js b/elcri.men/src/components/Footer.js index c8112cc7..d405b9fc 100644 --- a/elcri.men/src/components/Footer.js +++ b/elcri.men/src/components/Footer.js @@ -113,18 +113,6 @@ function Footer(props) { {intl.formatMessage({ id: '© All rights reserved' })}
- - ) diff --git a/elcri.men/src/components/layout.js b/elcri.men/src/components/layout.js index 83a6de7c..503e11ff 100644 --- a/elcri.men/src/components/layout.js +++ b/elcri.men/src/components/layout.js @@ -16,7 +16,7 @@ const Layout = ({ locale, children, path, wide }) => { window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments)}; gtag('js', new Date()); - gtag('config', 'G-SMLSV8EVFV', { page_path: location ? location.pathname + location.search + location.hash : undefined }) + gtag('config', 'G-SMLSV8EVFV', { send_page_view: false }) `}