diff --git a/apps/nextjs-website/src/app/layout.tsx b/apps/nextjs-website/src/app/layout.tsx index 35f5586b5..9689c1a7c 100644 --- a/apps/nextjs-website/src/app/layout.tsx +++ b/apps/nextjs-website/src/app/layout.tsx @@ -3,6 +3,7 @@ import { cookieDomainScript, isChatbotActive, isProduction, + matomoScriptSrc, } from '@/config'; import { Metadata } from 'next'; import 'swiper/css'; @@ -23,22 +24,16 @@ import { Titillium_Web } from 'next/font/google'; import NextIntlContext from '@/components/atoms/NextIntlContext/NextIntlContext'; import ChatbotProvider from '@/components/organisms/ChatbotProvider/ChatbotProvider'; -const MATOMO_SCRIPT = ` -var _paq = (window._paq = window._paq || []); -/* tracker methods like "setCustomDimension" should be called before "trackPageView" */ -_paq.push(["trackPageView"]); -_paq.push(["enableLinkTracking"]); -(function () { - var u = "https://pagopa.matomo.cloud/"; - _paq.push(["setTrackerUrl", u + "matomo.php"]); - _paq.push(["setSiteId", "8"]); - var d = document, - g = d.createElement("script"), - s = d.getElementsByTagName("script")[0]; - g.async = true; - g.src = "//cdn.matomo.cloud/pagopa.matomo.cloud/matomo.js"; - s.parentNode.insertBefore(g, s); -})(); +const MATOMO_SCRIPT = + ` +var _mtm = window._mtm = window._mtm || []; + _mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'}); + (function() { + var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; + g.async=true; g.src='` + + matomoScriptSrc + + `'; s.parentNode.insertBefore(g,s); + })(); `; const titilliumWeb = Titillium_Web({ diff --git a/apps/nextjs-website/src/components/atoms/ChatButton/ChatButton.tsx b/apps/nextjs-website/src/components/atoms/ChatButton/ChatButton.tsx index af13446d3..5fe1dfcaf 100644 --- a/apps/nextjs-website/src/components/atoms/ChatButton/ChatButton.tsx +++ b/apps/nextjs-website/src/components/atoms/ChatButton/ChatButton.tsx @@ -20,9 +20,10 @@ const ChatButton = ({ isChatOpen, onOpenChat, size }: ChatButtonProps) => { return ( { - matomoEvent(); + //matomoEvent(); onOpenChat(e); }} size={size} diff --git a/apps/nextjs-website/src/config.ts b/apps/nextjs-website/src/config.ts index 41113bf41..cf4a62217 100644 --- a/apps/nextjs-website/src/config.ts +++ b/apps/nextjs-website/src/config.ts @@ -8,6 +8,7 @@ See BrowserConfig.ts and BrowserEnv.ts as examples. // TODO: Add environment parser export const docsPath = process.env.PATH_TO_GITBOOK_DOCS; export const cookieDomainScript = process.env.NEXT_PUBLIC_COOKIE_DOMAIN_SCRIPT; +export const matomoScriptSrc = process.env.NEXT_PUBLIC_MATOMO_SCRIPT_SRC; export const environment = process.env.ENVIRONMENT; export const docsAssetsPath = '/gitbook/docs'; export const allowCrawler = process.env.ALLOW_CRAWLER === 'true';