diff --git a/src/gatsby-ssr.js b/src/gatsby-ssr.js index d8e9e15..b8cb2c4 100644 --- a/src/gatsby-ssr.js +++ b/src/gatsby-ssr.js @@ -4,6 +4,8 @@ import React from 'react' function buildTrackingCode(pluginOptions) { const { matomoUrl, + matomoPhpScript = 'piwik.php', + matomoJsScript = 'piwik.js', siteId, dev, localScript, @@ -12,7 +14,7 @@ function buildTrackingCode(pluginOptions) { cookieDomain } = pluginOptions - const script = localScript ? localScript : `${matomoUrl}/piwik.js` + const script = localScript ? localScript : `${matomoUrl}/${matomoJsScript}` const html = ` window.dev = ${dev} @@ -21,11 +23,11 @@ function buildTrackingCode(pluginOptions) { ${requireConsent ? "window._paq.push(['requireConsent']);" : ''} ${disableCookies ? "window._paq.push(['disableCookies']);" : ''} ${ - cookieDomain - ? `window._paq.push(['setCookieDomain', '${cookieDomain}']);` - : '' - } - window._paq.push(['setTrackerUrl', '${matomoUrl}/piwik.php']); + cookieDomain + ? `window._paq.push(['setCookieDomain', '${cookieDomain}']);` + : '' + } + window._paq.push(['setTrackerUrl', '${matomoUrl}/${matomoPhpScript}']); window._paq.push(['setSiteId', '${siteId}']); window._paq.push(['enableHeartBeatTimer']); window.start = new Date(); @@ -52,7 +54,7 @@ function buildTrackingCode(pluginOptions) { function buildTrackingCodeNoJs(pluginOptions, pathname) { const { matomoUrl, siteId, siteUrl } = pluginOptions - const html = `tracker` return (