mirror of
https://github.com/kremalicious/gatsby-plugin-matomo.git
synced 2024-12-22 17:23:23 +01:00
add cookieDomain setting
This commit is contained in:
parent
86141a1f10
commit
0867187bec
@ -73,6 +73,7 @@ _NOTE: By default, this plugin only generates output when run in production mode
|
|||||||
| `exclude` | (optional) Specify an array of pathnames where tracking code will be excluded. The pathname `/offline-plugin-app-shell-fallback/` is excluded by default. |
|
| `exclude` | (optional) Specify an array of pathnames where tracking code will be excluded. The pathname `/offline-plugin-app-shell-fallback/` is excluded by default. |
|
||||||
| `requireConsent` | (optional) If true, tracking will be disabled until you call `window._paq.push(['setConsentGiven']);`. |
|
| `requireConsent` | (optional) If true, tracking will be disabled until you call `window._paq.push(['setConsentGiven']);`. |
|
||||||
| `disableCookies` | (optional) If true, no cookie will be used by Matomo. |
|
| `disableCookies` | (optional) If true, no cookie will be used by Matomo. |
|
||||||
|
| `cookieDomain` | (optional) Specify cookie domain. |
|
||||||
| `localScript` | (optional) If set, load local `piwik.js` script from the given path, instead of loading it from your `matomoUrl`. |
|
| `localScript` | (optional) If set, load local `piwik.js` script from the given path, instead of loading it from your `matomoUrl`. |
|
||||||
| `dev` | (optional) Activate dev mode by setting to `true`. Will load all scripts despite not running in `production` environment. Ignores your local browser's DNT header too. Outputs some information in console about what it is doing. Useful for local testing but careful: all hits will be send like in production. |
|
| `dev` | (optional) Activate dev mode by setting to `true`. Will load all scripts despite not running in `production` environment. Ignores your local browser's DNT header too. Outputs some information in console about what it is doing. Useful for local testing but careful: all hits will be send like in production. |
|
||||||
|
|
||||||
@ -88,6 +89,7 @@ plugins: [
|
|||||||
exclude: ['/offline-plugin-app-shell-fallback/'],
|
exclude: ['/offline-plugin-app-shell-fallback/'],
|
||||||
requireConsent: false,
|
requireConsent: false,
|
||||||
disableCookies: false,
|
disableCookies: false,
|
||||||
|
cookieDomain: '*.example.org',
|
||||||
localScript: '/piwik.js',
|
localScript: '/piwik.js',
|
||||||
dev: false
|
dev: false
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,8 @@ function buildTrackingCode(pluginOptions) {
|
|||||||
dev,
|
dev,
|
||||||
localScript,
|
localScript,
|
||||||
requireConsent,
|
requireConsent,
|
||||||
disableCookies
|
disableCookies,
|
||||||
|
cookieDomain
|
||||||
} = pluginOptions
|
} = pluginOptions
|
||||||
|
|
||||||
const script = localScript ? localScript : `${matomoUrl}/piwik.js`
|
const script = localScript ? localScript : `${matomoUrl}/piwik.js`
|
||||||
@ -19,6 +20,11 @@ function buildTrackingCode(pluginOptions) {
|
|||||||
window._paq = window._paq || [];
|
window._paq = window._paq || [];
|
||||||
${requireConsent ? "window._paq.push(['requireConsent']);" : ''}
|
${requireConsent ? "window._paq.push(['requireConsent']);" : ''}
|
||||||
${disableCookies ? "window._paq.push(['disableCookies']);" : ''}
|
${disableCookies ? "window._paq.push(['disableCookies']);" : ''}
|
||||||
|
${
|
||||||
|
cookieDomain
|
||||||
|
? `window._paq.push(['setCookieDomain', '${cookieDomain}']);`
|
||||||
|
: ''
|
||||||
|
}
|
||||||
window._paq.push(['setTrackerUrl', '${matomoUrl}/piwik.php']);
|
window._paq.push(['setTrackerUrl', '${matomoUrl}/piwik.php']);
|
||||||
window._paq.push(['setSiteId', '${siteId}']);
|
window._paq.push(['setSiteId', '${siteId}']);
|
||||||
window._paq.push(['enableHeartBeatTimer']);
|
window._paq.push(['enableHeartBeatTimer']);
|
||||||
|
Loading…
Reference in New Issue
Block a user