mirror of
https://github.com/kremalicious/gatsby-plugin-matomo.git
synced 2024-12-22 17:23:23 +01:00
Make PHP and JS script names configurable
This commit is contained in:
parent
e899e371d3
commit
12a4ebed8d
@ -4,6 +4,8 @@ import React from 'react'
|
|||||||
function buildTrackingCode(pluginOptions) {
|
function buildTrackingCode(pluginOptions) {
|
||||||
const {
|
const {
|
||||||
matomoUrl,
|
matomoUrl,
|
||||||
|
matomoPhpScript = 'piwik.php',
|
||||||
|
matomoJsScript = 'piwik.js',
|
||||||
siteId,
|
siteId,
|
||||||
dev,
|
dev,
|
||||||
localScript,
|
localScript,
|
||||||
@ -12,7 +14,7 @@ function buildTrackingCode(pluginOptions) {
|
|||||||
cookieDomain
|
cookieDomain
|
||||||
} = pluginOptions
|
} = pluginOptions
|
||||||
|
|
||||||
const script = localScript ? localScript : `${matomoUrl}/piwik.js`
|
const script = localScript ? localScript : `${matomoUrl}/${matomoJsScript}`
|
||||||
|
|
||||||
const html = `
|
const html = `
|
||||||
window.dev = ${dev}
|
window.dev = ${dev}
|
||||||
@ -21,11 +23,11 @@ function buildTrackingCode(pluginOptions) {
|
|||||||
${requireConsent ? "window._paq.push(['requireConsent']);" : ''}
|
${requireConsent ? "window._paq.push(['requireConsent']);" : ''}
|
||||||
${disableCookies ? "window._paq.push(['disableCookies']);" : ''}
|
${disableCookies ? "window._paq.push(['disableCookies']);" : ''}
|
||||||
${
|
${
|
||||||
cookieDomain
|
cookieDomain
|
||||||
? `window._paq.push(['setCookieDomain', '${cookieDomain}']);`
|
? `window._paq.push(['setCookieDomain', '${cookieDomain}']);`
|
||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
window._paq.push(['setTrackerUrl', '${matomoUrl}/piwik.php']);
|
window._paq.push(['setTrackerUrl', '${matomoUrl}/${matomoPhpScript}']);
|
||||||
window._paq.push(['setSiteId', '${siteId}']);
|
window._paq.push(['setSiteId', '${siteId}']);
|
||||||
window._paq.push(['enableHeartBeatTimer']);
|
window._paq.push(['enableHeartBeatTimer']);
|
||||||
window.start = new Date();
|
window.start = new Date();
|
||||||
@ -52,7 +54,7 @@ function buildTrackingCode(pluginOptions) {
|
|||||||
|
|
||||||
function buildTrackingCodeNoJs(pluginOptions, pathname) {
|
function buildTrackingCodeNoJs(pluginOptions, pathname) {
|
||||||
const { matomoUrl, siteId, siteUrl } = pluginOptions
|
const { matomoUrl, siteId, siteUrl } = pluginOptions
|
||||||
const html = `<img src="${matomoUrl}/piwik.php?idsite=${siteId}&rec=1&url=${siteUrl +
|
const html = `<img src="${matomoUrl}/${matomoPhpScript}?idsite=${siteId}&rec=1&url=${siteUrl +
|
||||||
pathname}" style="border:0" alt="tracker" />`
|
pathname}" style="border:0" alt="tracker" />`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user