From c3d9fd9de152d2758846bc55daabb94806fa2888 Mon Sep 17 00:00:00 2001 From: Constantin Dumitrescu Date: Wed, 13 Jul 2022 14:50:09 +0300 Subject: [PATCH 1/3] feat: add tracking option to extend matomo config --- README.md | 4 ++++ src/index.js | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 92265d3..c00fe1e 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ module.exports = { siteId: 'ID', phpLoader: 'matomo.php', jsLoader: 'matomo.js', + // optional matomo methods + tracking: [ + ["enableHeartBeatTimer"] + ] }, }, }; diff --git a/src/index.js b/src/index.js index fe87ddd..4075cb4 100644 --- a/src/index.js +++ b/src/index.js @@ -19,6 +19,7 @@ module.exports = function (context) { } const phpLoader = matomo.phpLoader || 'matomo.php'; const jsLoader = matomo.jsLoader || 'matomo.js'; + const tracking = matomo.tracking || []; const isProd = process.env.NODE_ENV === 'production'; @@ -46,13 +47,11 @@ module.exports = function (context) { tagName: 'script', innerHTML: ` var _paq = window._paq = window._paq || []; - _paq.push(['setRequestMethod', 'POST']); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); - _paq.push(['enableHeartBeatTimer']); + ${tracking.map(x => `_paq.push(${JSON.stringify(x)})`).join(';')}; (function() { var u="${matomoUrl}"; - _paq.push(['setRequestMethod', 'POST']); _paq.push(['setTrackerUrl', u+'${phpLoader}']); _paq.push(['setSiteId', '${siteId}']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; From 11f219c89e45d2590a6be73cb144b5c30f86b462 Mon Sep 17 00:00:00 2001 From: Constantin Dumitrescu Date: Thu, 14 Jul 2022 17:40:30 +0300 Subject: [PATCH 2/3] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c00fe1e..5af35b0 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ module.exports = { jsLoader: 'matomo.js', // optional matomo methods tracking: [ - ["enableHeartBeatTimer"] + ["enableHeartBeatTimer"], + ['setRequestMethod', 'POST'] ] }, }, From 137f5681f6d2fda64ebcfd7a43168f048830e6a7 Mon Sep 17 00:00:00 2001 From: Constantin Dumitrescu Date: Thu, 14 Jul 2022 17:41:44 +0300 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5af35b0..878688b 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ module.exports = { jsLoader: 'matomo.js', // optional matomo methods tracking: [ - ["enableHeartBeatTimer"], + ['enableHeartBeatTimer'], ['setRequestMethod', 'POST'] ] },